[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
Re: checking for numeric chars
- Subject: Re: checking for numeric chars
- From: George Jansen <GJANSEN@AFLCIO.ORG>
- Date: Tue, 12 Feb 2002 09:12:43 -0500
Why not use generalize and use arrays? You could tuck the logic into an
sqc.
#define min-printable 32
#define max-us-printable 127 ! Ascii('~')
#define min-8-bit 128
#define max-ascii 255
#define zero 48 ! Ascii('0')
#define nine 58 ! Ascii('9')
#define A 65 ! Ascii('A')
#define Z 90 !Ascii('Z')
#define a 97 ! Ascii('a')
#define z 122 ! Ascii('z')
begin-setup
create-array
name=char_attributes size=256
field=class:char
end-setup
begin-report
do init-array
let #j = Ascii(' ')
while #j <= Ascii('~')
get $class from char_attributes(#j)
let $zap = Chr(#j) || ' is ' || $class
show $zap
let #j = #j + 1
end-while
end-report
begin-procedure init-array-slice (#low, #high, $class)
let #i = #low
while #i <= #high
put $class into char_attributes(#i)
let #i = #i + 1
end-while
end-procedure init-array-slice
begin-procedure init-array
do init-array-slice ({min-ascii},{max-control}, 'control')
do init-array-slice ({min-printable}, {max-us-printable},
'printable')
do init-array-slice ({min-8-bit}, {max-ascii}, '8-bit')
do init-array-slice ({zero}, {nine}, 'numeric')
do init-array-slice ({A}, {Z}, 'alpha')
do init-array-slice ({a}, {z}, 'alpha')
end-procedure print-array