character value
Bob Comeau
bcomeau@crossley.ca
Thu, 25 Jul 2002 14:14:25 -0300
Ok using the get/setsystemval did work.
But I ran across a curious problem.
Part of my original problem was that I only needed give special handling to values in the upper half of value range (128-255). I
thought a simple test for less than or equal to "~" (126) would work for a close enough to see if the character was in the normal
range or the extended range. Some tests worked others did not. I thought I was losing it.
I condensed the problem down to this small test and ran it repeatedly. The output has been condensed by deleting the extra heading
and prompt lines between the GO's, showing only the resulting detail line. The first value is what I gave to the prompt.
> set default
> set nostatistics
> set page length 0
> cancel clear
> define ascval int*2 = parm prompt "Test ASCII value: "
> define showval char*1=characters(ascval)[2:1]
> define lowchar char*1 = "Y" if showval <="~" else "N"
> define lowval char*1 = "Y" if ascval <=126 else "N"
> define highchar char*1 = "Y" if showval > "~" else "N"
> define highval char*1 = "Y" if ascval > 126 else "N"
> report all
> go
Test ASCII value: 65
ASCVAL SHOWVAL LOWCHAR LOWVAL HIGHCHAR HIGHVAL
65 A Y Y N N
66 B Y Y N N
67 C Y Y N N
126 ~ Y Y N N
160 N N Y Y
161 À N N Y Y
162 Â Y N N Y
163 È Y N N Y
164 Ê N N Y Y
165 Ë N N Y Y
166 Î Y N N Y
167 Ï Y N N Y
168 ´ N N Y Y
169 ` N N Y Y
170 ^ Y N N Y
171 ¨ Y N N Y
172 ~ N N Y Y
173 Ù N N Y Y
If you look closely the values in the normal range behave as expected. All tests using the character value "~" match those against
the numeric ascii value. Half of those in the upper range are right, the others are wrong with regard to the character test. The
numeric test is consistently right. I didn't run through the entire range but there seems to be a pattern emerging.
For my application I went with the numeric test, but I would be curious to see an explanation of this phenomenon.
Can anyone explain this?
Bob Comeau
Systems Programmer Analyst
Crossley Carpet Mills Ltd.
(902)895-5491 ex 139
-----Original Message-----
From: Knox, Dave (Dallas, CSC) [mailto:KnoxDa01@unisourcelink.com]
Sent: Wednesday, July 24, 2002 3:23 PM
To: 'Bob Comeau'; powerh-l@lists. swau. edu
Subject: RE: character value
Bob
What's you're environment ?
The following works on HP3000 . It parses out the item "X" to MPE and uses the HP ord() function.
I would hope similar could be done on any platform.
def X char*1 = "A" ;or fieldname of choice...
def Y int*2 = ncon(getsystemval("XY")) &
if setsystemval("XY","![ord('" + X + "')]")
rep X Y
go
X Y
A 65
Regards
Dave Knox
-----Original Message-----
From: Bob Comeau [mailto:bcomeau@crossley.ca]
Sent: Wednesday, July 24, 2002 12:47 PM
To: powerh-l@lists. swau. edu
Subject: character value
Does anyone know of a way in quiz to get the ASCII value of a single character returned as a number?
I know how to get from a displayable character from an integer, I need to go the other way.
For instance if a variable contains the letter "A" I would like to be able to that converted to the number 65.
Bob Comeau
Systems Programmer Analyst
Crossley Carpet Mills Ltd.
(902)895-5491 ex 139
= = = = = = = = = = = = = = = = = = = = = = = = = = = =
Mailing list: powerh-l@lists.swau.edu
Subscribe: "subscribe" in message body to powerh-l-request@lists.swau.edu
Unsubscribe: "unsubscribe" in message body to powerh-l-request@lists.swau.edu
http://lists.swau.edu/mailman/listinfo/powerh-l
This list is closed, thus to post to the list you must be a subscriber.