Re: ASCII problem
Re: ASCII problem
- Subject: Re: ASCII problem
- From: Richard 23 <email@hidden>
- Date: Thu, 26 Apr 2001 06:04:53 -0700
Aptly titled post. Depending on the length of the encoded data
you're processing you may indeed have an ASCII problem-- mainly
it's really SLOW!
I would approach this using Programmer's Tool if I didn't feel
like hacking out a solution in C.
>
i have a small problem here, where i can't find the answer on. The
>
script might speak for itself;
<snip>
well it doesn't to me anyway.
>
This is an script wich will generate an checksum, i'm not sure if it
>
will work, but i'm close :-)
>
hereby also it's Visual basic original:
>
>
SCCF = 19110027900059
>
temp = SCCF
>
for i = 1 To Len(SCCF) / 2
>
chunk = left(temp, 2)
>
if val (chunk) < 90 then
>
temp2 = temp2 + chr(val(chunk) + 33)
>
else
>
temp2 = temp2 + chr(val(chunk) + 71)
>
end if
>
temp = right(temp, len(temp) - 2)
>
next i
>
>
hereby variable temp2 gets converted to ascii with an special program
if you indeed need ascii values for
every character of temp I would use programmer's tool like this:
"19110027900059"
-- cast result using template decimal byte -- my own custom term
cast result using template "DBYT"
--> {49, 57, 49, 49, 48, 48, 50, 55, 57, 48, 48, 48, 53, 57}
Now at least you have the ascii values for any length of string
in one step. This will speed things up considerably.
If processing the input as a series of pairs, this may be even
better:
-- ---------------------------------------------------------
-- Preprocessed by Convert Script 1.0d5
-- ---------------------------------------------------------
-- author: Richard 23, date: Thursday, April 26, 2001
-- ---------------------------------------------------------
-- shown with custom terms in case you're not familiar with
-- the 4 character type codes:
-- ---------------------------------------------------------
-- property Chunk_Tmpl : cast {{"Chunk Count", one count}, ==>
-- {"*****", counted list}, {"Byte1", decimal byte}, ==>
-- {"Byte2", decimal byte}, {"*****", list end}} to "TMPL"
-- ---------------------------------------------------------
property Chunk_Tmpl : cast {{"Chunk Count", "OCNT"}, ==>
{"*****", "LSTC"}, {"Byte1", "DBYT"}, {"Byte2", "DBYT"}, ==>
{"*****", "LSTE"}} to "TMPL"
set temp to "19110027900059"
cast result using template Chunk_Tmpl
--> {{|Byte1|:49, |Byte2|:49}, {|Byte1|:48, |Byte2|:48}, ...}
cast temp using template Chunk_Tmpl without label
--> {{49, 49}, {48, 48}, {50, 55}, {57, 48}, {48, 48}, {53, 57}}
-- ---------------------------------------------------------
the rest is left as an excercise for the reader. ;)
R23