English 中文(简体)
How to write a HEX string into a file as HEX using REXX
原标题:

I have a string RAJA which should be written into a file as HEX data. Here are sample codes which help me to describe the issue. Case(a)

name =  RAJA    
name = C2X(name) /* Hex value =  52414A41  */
QUEUE name.

Output to the file: 52414A41

But if we use HEX data directly to write into file it s working fine Case(b)

name =  52414A41 X
QUEUE name.

Output to the file: RAJA

Issue: In case(a) when the string was converted into HEX using C2X, it returns a HEX data string not a HEX data. But in case(b) as HEX data was written to file. My question is how to let REXX interpreter know that the variable name in case(a) has HEX data and to be written it as HEX. Hope i made the issue clear. Lemme tread towards a solution.

最佳回答

Finally, I could resolve MYSELF issue described top. There is built-in function in REXX called INTERPRET , which helps us in building dynamic REXX commands. Here is the single statement, made me run the module successfully:

INTERPRET name_hex "=  " || name || " X"

It dynamically creates a REXX statement:

name_hex =  name X

which will tell REXX interpreter the string in name as HEX data.

Awesome right! Hope I made you clear.. Do get back to me with your questions..

问题回答

You could also use the x2c function

say x2c(52414A41)

displays RAJA

For most of the functions like c2x reversing the characters does the reverse

i.e.

say d2c(c2d(10))

say c2d(d2c(10))

say x2d(d2x(10))

all display 10

I don t think you have a strong grasp of what you are trying to do here... Run the following REXX program and then figure out why it displays what it does. Once you have managed that, you can probably come up with a better solution to your hex/character problem.


name =  RAJA 
say name            /* RAJA */
name = C2X(name)
say name            /* 52414A41 */
name = X2C(name)
say name            /* RAJA */
name =  52414A41 x
say name            /* RAJA */
name = X2C( 52414A41 )
say name            /* RAJA */
name =  52414A41 
INTERPRET "name =  " || name || " X"
say name            /* RAJA */




相关问题
C#: Integer value being returned as hexadecimal in VS 2008

I have a c# code snippets where i am creating a list of my custom class objects.When i am taking the count of that,its showing me a hexadecimal value in the quickwatch window. alt text http://img509....

What is the HEX code for Transparent color?

I want to set color as transparent. In RGB 255 0 255 with alpha 5 may work as transparent, But How to get it in HEX ? What is the HEX code for Transparent color

How to test a byte against a hex value?

I want to test if the byte I read from a data file is 0xEE, what should I do? I tried if (aChar == 0xEE) but doesn t seems working.

need help writing hexadecimals to an exe file

can somone tell me how to write these hexadecimals to an exe file while still having it exec 4D 5A 50 00 02 00 00 00 04 00 0F 00 FF FF 00 00 B8 00 00 00 00 00 00 00 40 00 1A 00 00 00 00 00 00 00 00 ...

how to show hex code char?

i have a file contains numbers like FB8E,FB8F,FB90 on each line. i want in my program to load this file and take each line and print the character corresponded to that number/line. for expamle, my ...

Storing hexadecimal values as binary in MySQL

I was thinking about how I m storing passwords in my database : appropriately salted SHA1 strings in a CHAR(40) field. However, since the character data in there is actually just a hex representation ...

热门标签