Re: Routines for review: Hex <-> String
Re: Routines for review: Hex <-> String
- Subject: Re: Routines for review: Hex <-> String
- From: "Arthur J. Knapp" <email@hidden>
- Date: Fri, 17 Jan 2003 11:53:40 -0500
>
Date: Fri, 17 Jan 2003 14:58:49 +0100
>
From: Emmanuel <email@hidden>
>
Subject: Re: Routines for review: Hex <-> String
>
At 1:18 PM +0100 17/01/03, julifos wrote:
>
> on hextoString(t)
>
> set z to z & (run script "<<data cstr" & t's characters i thru
>
> (i + 251) & "00>> as string")
>
1. Hexa -> String
>
>
We have been making a very similar (vanilla) script which uses ...
>
"pstr" instead of your "cstr"!
A Pascal is string is limited to 255 characters, of course, but that is
alright since the "run script" method is limited by how many characters
it can compile for a single line anyway. Does this sound familiar? :
error "Way too long, dude."
I would really like to meet the programmer who wrote this message ;-)
>
Ours has been available since a rather long time now at:
>
<http://www.satimage-software.com/downloads/VanillaHexToString.sit.hqx>
Wow, I don't think I've noticed it before. It's good stuff. :)
>
2. String -> Hexa
>
>
We did not want to use the "return excerpt from error message"
>
method, which is rather fragile I think. Thus, we were not able to
>
produce any simple "vanilla" method. We use:
>
>
display (theChunk as Pascal string)
I find it annoying that the error message is returned as styled text,
I often like to use something like this:
-- replace << and >> with option-\ and option-shift-\
on RawDataToString(v)
try
err of v
on error styled_text
end try
(* Coerce styled error text to plain text
*)
set {text:plain_text} to styled_text
(* Allow for messages in multiple-languages ???
*)
set o to AppleScript's text item delimiters
set AppleScript's text item delimiters to "<<"
set plain_text to plain_text's text item 2
set AppleScript's text item delimiters to ">>"
set plain_text to plain_text's text item 1
set AppleScript's text item delimiters to o
return ("<<" & plain_text & ">>")
end RawDataToString
RawDataToString(<<data iMac00AAFF>>) --> "<<data iMac00AAFF>>"
{ Arthur Knapp, of <
http://www.STELLARViSIONs.com>
a r t h u r @ s t e l l a r v i s i o n s . c o m
"Safe the Nature" - political graffiti in Prague
}
_______________________________________________
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.