Guidance Forums / Reginald Rexx / Conversion of character

Search 搜索
Home Home

Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Conversion of character
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
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.
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)
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
© Thu 2024-5-30  Guidance Laboratory Inc. Hits:0