Re: even better coerce to record with usrf
Re: even better coerce to record with usrf
- Subject: Re: even better coerce to record with usrf
- From: Arthur J Knapp <email@hidden>
- Date: Fri, 14 Dec 2001 10:21:00 -0500
>
Subject: RE: even better coerce to record with usrf
>
Date: Fri, 14 Dec 2001 01:10:05 +0000
>
From: Nigel Garvey <email@hidden>
>
Olof Hellman wrote on Wed, 12 Dec 2001 17:42:11 -0800:
>
> Can anyone figure out how to get rid of the other run script?
>
Well, if you don't mind exploiting the bug that was being discussed the
>
other day (and which Arthur used to good effect in a couple of scripts),
>
you can use the following. It looks long, it is crude, but it's quite
>
fast.
>
>
to usrf(theList)
>
to extract_record_field(theRecord, theField)
Good stuff. :)
>
-- Convert an integer to a 4-byte value
>
-- that can be included in a string
>
on numAs4bytes(n)
>
set binaryStr to ""
>
repeat with i from 4 to 1 by -1
>
set binaryStr to binaryStr & (ASCII character (n mod (256 ^ i) div
>
(256 ^ (i - 1))))
>
end repeat
>
return binaryStr
>
end numAs4bytes
I see that you didn't care for my faster method: ;-)
on IntegerToBytes(n)
return ({{a:n}} as string)'s text -4 thru -1
end IntegerToBytes
I admit, you choose a better name... ;-)
{ Arthur J. Knapp, of <
http://www.STELLARViSIONs.com>
<
mailto:email@hidden>
try
<
http://www.VivaLaData.com/>
on error number -128
end try
}