Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

display HEX variable with the SAY command

822 views
Skip to first unread message

Douglas Rodd

unread,
Aug 27, 1998, 3:00:00 AM8/27/98
to
Using REXX for MVS, how can I display a variable that contains
unprintable characters in it's HEX equivilant.

var1 may contain the first 4 bytes of a record in a file (x'00234577')
and I want to display the contents of var1 in character format.

I want to display 00234567.

D. Rodd
NBTel
dar...@nbtel.nb.ca
506 694-6393

Ian Collier

unread,
Aug 27, 1998, 3:00:00 AM8/27/98
to
In article <35E561...@nbtel.nb.ca>, dar...@nbtel.nb.ca wrote:
>Using REXX for MVS, how can I display a variable that contains
>unprintable characters in it's HEX equivilant.

say c2x(avariable)
--
---- Ian Collier : i...@comlab.ox.ac.uk : WWW page (including REXX section):
------ http://www.comlab.ox.ac.uk/oucl/users/ian.collier/imc.html

New to this group? Answers to frequently-asked questions can be had from
http://rexx.hursley.ibm.com/rexx/ .

Douglas Rodd

unread,
Aug 27, 1998, 3:00:00 AM8/27/98
to
Tried that and that prints the hex for the string not the value
contained in the variable. If the variable var1 contains 0123 then I
want to display the value 0123 not E5C1D9F1 which is var1.

D Rodd

Mark Short

unread,
Aug 27, 1998, 3:00:00 AM8/27/98
to
I am thinking you have it backwards maybe,
does the file contain hex chars, like a hex dump or something.
You do the opposite in this case
say x2c(ahexcharstring)
say ahexstring
would show the converted string and show original on next line
However if any of the resultant characters are unprintable you won't see
them.

Douglas Rodd

unread,
Aug 27, 1998, 3:00:00 AM8/27/98
to
The file contains as the first record:
----+----1----+----2----+----3----+----4----+
********************************* TOP OF DATA
q I3209
0009000040000000000000000000000000000000CFFFF
00F800000000000000000000000000000000000193209

If I use
var1 = substr(r.1,3,2)
var2 = substr(r.1,41,5)
say var1
will display a blank followed by a lower case q
say var2
will display I3209 which is good.
What I want to display with var1 is 0F98
How do I do that?

D Rodd

Mark Short

unread,
Aug 27, 1998, 3:00:00 AM8/27/98
to
say c2x(var1)
should work

Douglas Rodd

unread,
Aug 27, 1998, 3:00:00 AM8/27/98
to
I wish it was that simple, but it isn't. That displays the hex
equivilant of var1 not the contents of var1. Have you actually tried
this?
D Rodd

Mark Short

unread,
Aug 27, 1998, 3:00:00 AM8/27/98
to
I'm afraid it is that simple.
You mean it is displaying hex values of VAR1
Either you have quotes around the variable name or you haven't made an
assignment to the variable name VAR1 yet.
If nothing is assigned to var1, it would have value of VAR1.
I just tried the equivalent it in kedit (don't have access to MVS), it
works fine,

var1 = '0f98'x
say var1
say c2x(var1)


Ian Collier

unread,
Aug 27, 1998, 3:00:00 AM8/27/98
to
In article <35E577...@nbtel.nb.ca>, dar...@nbtel.nb.ca wrote:
>Ian Collier wrote:
>> say c2x(avariable)

>Tried that and that prints the hex for the string not the value
>contained in the variable. If the variable var1 contains 0123 then I
>want to display the value 0123 not E5C1D9F1 which is var1.

I assure you that if var1 contains '0123' then "say c2x(var1)" will
produce 'F0F1F2F3' as you desire and not 'E5C1D9F1'.

If it says 'E5C1D9F1' then var1 has not been set properly (either that
or there is a peculiar bug in the Rexx interpreter). Try replacing it
with "say var1" and you should see that it says 'VAR1'.

imc

Doug McKibbin

unread,
Aug 27, 1998, 3:00:00 AM8/27/98
to
On Thu, 27 Aug 1998 12:14:50 -0300, Douglas Rodd wrote:

>Ian Collier wrote:
>>
>> In article <35E561...@nbtel.nb.ca>, dar...@nbtel.nb.ca wrote:
>> >Using REXX for MVS, how can I display a variable that contains
>> >unprintable characters in it's HEX equivilant.
>>
>> say c2x(avariable)
>> --
>> ---- Ian Collier : i...@comlab.ox.ac.uk : WWW page (including REXX section):

>Tried that and that prints the hex for the string not the value
>contained in the variable. If the variable var1 contains 0123 then I
>want to display the value 0123 not E5C1D9F1 which is var1.
>

>D Rodd

Try say c2x(value(variable)) and see what that gives you.


Regards,
Doug McKibbin
(remove NOSPAM from address when emailing)

Dennis Bareis

unread,
Aug 30, 1998, 3:00:00 AM8/30/98
to
"Metz, Seymour" <sm...@NSF.GOV> wrote:

}The hex equivalent of 0123 is C0C1C2C3. See the results of executing a test
}case:
}
} 3 *-* var1 = '0123'
} >L> "0123"
} 4 *-* say c2x(var1)
} >V> "0123"
} >F> "F0F1F2F3"
} F0F1F2F3
}
}I suspect that you misspelled the name of the variable and that it was
}uninitialized.
}
}Shmuel (Seymour J.) Metz

I don't know how all this started but ASCII for '0123' is '30313233' and
EBCDIC is 'F0F1F2F3'.

Bye
Dennis

--------------------------------
Dennis Bareis
Melbourne, AUSTRALIA.
email : d...@anz.com
HomePage: http://www.ozemail.com.au/~dbareis
- Contains heaps of FREE OS/2, DOS & WIN32 programs.
- Heaps of COMMENTED OS/2, HTML, Java and other links
- Some source code and programmers links. Regina Information (including porting from OS/2)
- Examples of the freeware (you won't find it elsewhere):
* PPWIZARD (HTML/REXX/generic preprocessor - #define, #include, #import, #if)
You WILL NOT find an easier to use or more powerful preprocessor than PPWIZARD.
So far everyone who has said "PPWIZARD can't do this" has been wrong!
* Icon for single OS/2 archive on following boot
* REXX compiler
* PM/Program manipulation by Window or Switch list title
* Prevent a floppy in drive stopping boot off hard disk
* About 20 more...
--------------------------------

Douglas Rodd

unread,
Aug 31, 1998, 3:00:00 AM8/31/98
to Mark Short
Hey. That works great. I had a hard time getting my thinking around the
fact that I had a hex value to display and the function is for convert
character to hex. My logic is thinking I want to convert hex to
character.
Anyway I finally have it working and I thank you for putting me straight
on this as well for all the help from all the other people who have
helped me with this problem.

Regards and thanks again
D Rodd

0 new messages