OK, maybe I need a little more detail.
I have some C functions called from Pascal that write to a pointer to packed array of chars. Alot of what they write is 0x80 0x3a, etc. When it comes back into pascal, I would like to run the result through an IF statement to check the hex value in the character. With the old compiler we were allowed to do this: IF (character = '/8a') THEN blah;
But I can't seem to get anythign like this to work here, and I think its because it is actually comparing a hex value to / (at least that is what I can gather from all the assignments I made from my early post and how Pascal stored those values).
Any suggestions?
Thanks, Adam
-----Original Message----- From: Steve Loft [mailto:steve@nybbles.co.uk] Sent: Friday, February 09, 2001 11:21 AM To: gpc@gnu.de Subject: Re: Syntax Question
On Friday 09 February 2001 3:54 pm, Oldham, Adam wrote:
Hello, I'm currently switching compilers from an old proprietary Pascal compiler to GPC. I've got a problem assigning a hex value to a character. This is easy in c, you can say char a ='0xa0'; and be
I think what you want is CHR(16#a0).
On Friday 09 February 2001 4:29 pm, Oldham, Adam wrote:
OK, maybe I need a little more detail.
I have some C functions called from Pascal that write to a pointer to packed array of chars. Alot of what they write is 0x80 0x3a, etc. When it comes back into pascal, I would like to run the result through an IF statement to check the hex value in the character. With the old compiler we were allowed to do this: IF (character = '/8a') THEN
Like I said, use CHR:
IF character = CHR(16#8a) THEN
Or am I misunderstanding you?
Oldham, Adam wrote:
OK, maybe I need a little more detail.
I have some C functions called from Pascal that write to a pointer to packed array of chars. Alot of what they write is 0x80 0x3a, etc. When it comes back into pascal, I would like to run the result through an IF statement to check the hex value in the character. With the old compiler we were allowed to do this: IF (character = '/8a') THEN blah;
Well, this would be incompatible to just about every Pascal standard and compiler I know, where strings enclosed in single quoted are always interpreted verbatim. So, while we usually try to implement as many compatibility features to other compilers as possible, this one is not a good candidate.
Besides the suggestions already made, GPC also supports the BP syntax (#$8a) and a C-ish syntax ("\x8a") -- note the double quotes (at least that's for fairly recent GPC versions, with previous ones you needed a compiler swich {$char-escapes}).
Frank