Re: Hex String Handlers
Re: Hex String Handlers
- Subject: Re: Hex String Handlers
- From: Axel Luttgens <email@hidden>
- Date: Wed, 01 Jan 2003 15:16:26 +0100
Arthur J. Knapp wrote:
>
>Date: Mon, 30 Dec 2002 10:54:25 -0500
>
>Subject: Re: Hex String Handlers
>
>From: "Arthur J. Knapp" <email@hidden>
>
>
>
>
I wrote:
>
>
>
> [snip]
>
>
>
>
It has recently been brought to my attention that some versions
>
of AppleScript are not going to behave as I would expect them to
>
in the above. It is safer to explictly coerce the "c" from the
>
"c in s" statment to a string before assigning it to the text
>
item delimiters:
>
>
repeat with c in s
>
set AppleScript's text item delimiters to (c as string)
>
>
Right: without the coercion, the TIDs are set to a reference.
Given AppleScript's tendency to sometimes choke on references, I believe
I would have had the reaction to dereference in such a case; but I
would have done it in the more "academic" way:
set AppleScript's text item delimiters to contents of c
possibly avoiding an unneeded coercion. So, just by curiosity, is there
a precise reason I would be missing to use "c as string" instead?
Now, I nevertheless tried your original script -that is, without the
coercion- here (OS 10.2.3, AS 1.9.1).
It works.
Do you have more info about the versions of AppleScript that could be
affected? And about the contexts (just the TIDs, or more general)?
>
>[snip]
>
>
>
>
I neglicted to mention a very obvious limitation of the above,
>
namely, that a Pascal string can only contain 255 characters of
>
text, so:
>
>
on StringToHex(s)
>
>
set c to s as C string
>
>
try
>
err of c
>
on error msg
>
end try
>
>
return msg's text -((s's length) * 2 + 4) thru -5
>
>
end
>
>
I would appreciate any feed back from users of OSX as to whether
>
or not this StringToHex() handler works for them, thank you.
>
>
>
It works for me, and very well/fast!
As a side note, the structure of the error message issued in French is
the same as the one in English: no need to adjust the script in this case.
I tried it with strings up to 70000 characters, just to check the usual
limits, if any, of 32K and 64K. I wonder if there could be a hard-coded
limit, such as an error message buffer's maximal length?.
This is the opportunity to ask about the following.
The "error trick" often proves to be very useful, but I tended to fear
using it for regular purposes.
I remember having encountered since the earliest versions of AppleScript
memory leaks problems with (some?) error conditions. Sufficiently bad
that, for example, stay-opens finally crashed unless I carefully
designed them to avoid any "try...on error" construct. But I never could
find systematic reports on such matters.
Are my fears still justified?
TIA,
Axel
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.