Re: AppleScript Suite
Re: AppleScript Suite
- Subject: Re: AppleScript Suite
- From: Arthur J Knapp <email@hidden>
- Date: Thu, 18 Oct 2001 14:39:22 -0400
>
Date: Wed, 17 Oct 2001 15:21:23 -0700
>
From: Jon Pugh <email@hidden>
>
Subject: Re: AppleScript Suite
>
At 9:47 PM +0200 10/17/2001, JJ wrote:
>
> set C_String_Example to "example string" as C string
>
> --> <<data cstr6578616D706C6520737472696E6700>>
>
> set Example_2 to C_String_Example as string
>
> --> returns the script object itself, as "me"
I think some version information is needed. In both Script Debugger
and Apple's Script Editor, I get back a string, as expected.
>
> How can I "set Converted_To_String to C_String as string"
>
These are for use in C code, not in AppleScript itself. There is no sensible
>
way to use these in a script.
>
I'm sure some folks can come up with nonsensical uses, but I doubt they can
>
find a good one.
Why, Jon, that sounds like a challenge... ;-)
-- Normal AppleScript comparisons:
--
{"A" < "a", "A" = "a", "A" > "a", "B" < "a"} --> {false, true, false, false}
-- Finder window-lists comparisons:
--
considering case
{"A" < "a", "A" = "a", "A" > "a", "B" < "a"} --> {true, false, false,
false}
end considering
-- Pure ASCII comparisons:
--
set |A| to dataString of GetDataRecord("A" as C string)
set _a_ to dataString of GetDataRecord("a" as C string)
set |B| to dataString of GetDataRecord("B" as C string)
{|A| < _a_, |A| = _a_, |A| > _a_, |B| < _a_} --> {true, false, false, true}
on GetDataRecord(dat)
set dataRecord to {isData:0, dataType:0, dataString:0}
if (length of every data of {dat} is not 1) then
set isData of dataRecord to false
else
set isData of dataRecord to true
try
err of dat
on error err
end try
set oldDelim to text item delimiters
set text item delimiters to "+data "
set err to err's text item 2
set text item delimiters to ";"
set err to err's text item 1
set dataType of dataRecord to err's text 1 thru 4
set dataString of dataRecord to err's text 5 thru -1
end if
return dataRecord
end GetDataRecord
{"A" < "a", "A" = "a", "A" > "a", "B" < "a"} --> {false, true, false, false}
{"A" < "a", "A" = "a", "A" > "a", "B" < "a"} --> {true, false, false, false}
{|A| < _a_, |A| = _a_, |A| > _a_, |B| < _a_} --> {true, false, false, true}
In other words, normal AppleScript string comparisons don't
take case into consideration, so "A" and "a" are the same,
and "b" and "B" both come after "a" and "A".
Considering-case statements do take case into consideration, but
only for the same letter. "A" sorts before "a", but both sort before
"b" and "B".
By converting the strings to an ASCII-hex representation, we can
perform an ASCII sort, where "A" and "B" both sort before "a" and
"b", because they occur earier in the character set.
How did I do? ;-)
Arthur J. Knapp
http://www.stellarvisions.com
mailto:email@hidden
Hey, check out:
http://www.zavatone.com/