Guidance
指路人
g.yi.org
Guidance Forums / Reginald Rexx / Conversion of character

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Conversion of character
#12684
Posted by: Michael S 2009-02-06 00:44:55 Last edited by: Michael S 2009-02-06 00:47:11 (Total edited 1 time)
Stupid question really, but I can't figure this out. I have a byte in a file on my PC that (using a hex editor) is shown as '43'x. This is in fact a length of a record and should convert to 67 (43 hex = 67 decimal).

I've read the data n using CHARIN, but for the life of me, can't figure out how to "convert/use" the hex character so that it becomes a valid decimal, such that I can do something like

rec_length = conversion(my_byte)
record = SUBSTR(record,2)   /* Throw away length indicator */
actual_record = LEFT(record,rec_length)
any help much appreciated
Message2.
#12685
Posted by: Jeff Glatt 2009-02-06 01:24:31
Use the VALUEIN function to read in that byte and automatically convert it to a REXX number. VALUEIN is essentially a call to CHARIN and then C2D.
Message3.
#12688
Posted by: Doug Arndt 2009-02-06 08:34:55
The C2D function should do what you want, however, like Jeff said, the valuein function does it all.   Here's an example from reading the beginning of a .wav file, where the format is  RIFFnnnnWAVE  where nnnn is file length.

        /* Read the RIFF chunk */
        Riff = charin(inFN,,4)
        RiffLength = VALUEIN(inFN,, 4)
        Wave = charin(inFN,,4)
Doug
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Thu 2024-5-30  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0