Re: coerce record to string - does this work in other System languages?
Re: coerce record to string - does this work in other System languages?
- Subject: Re: coerce record to string - does this work in other System languages?
- From: "Stockly, Ed" <email@hidden>
- Date: Thu, 25 Mar 2010 13:34:46 -0700
- Thread-topic: coerce record to string - does this work in other System languages?
Maybe, but on the other hand, if the same script could be running with any
language, at any time, it would require a test for language and if the
language has changed since last time it was run, then run the calculations
again. This version may be simpler. But if the handler is called multiple
times and the same script doesn't run different languages with each run,
then that could be worth it.
On 3/25/10 1:24 PM, "Mark J. Reed" wrote:
> Although it would perhaps be more useful to calculate startCut and
> endCut once and persist those values, rather than doing that work anew
> (and then overwriting endCut with a value tied to the specific current
> record) each time.
>
> On Thu, Mar 25, 2010 at 4:15 PM, Stockly, Ed <email@hidden> wrote:
>>
>> Yours didn't work for me, but this modification does:
>>
>> HTH,
>>
>> ES
>>
>> on to_String(the_record)
>> try
>> {a:0} as string
>> on error cutoff
>> set oldDelims to AppleScript's text item delimiters
>> set AppleScript's text item delimiters to {"{a:0}"}
>> set startCut to length of first text item of cutoff
>> set endCut to length of last text item of cutoff
>> set AppleScript's text item delimiters to oldDelims
>> end try
>> try
>> the_record as string
>> on error the_record
>> set endCut to (the (length of the_record) - endCut)
>> set the_record to text startCut thru endCut of the_record
>> end try
>> return the_record -- as string
>> end to_String
>>
>>
>> On 3/25/10 12:48 PM, "Skeeve" wrote:
>>
>>> Hi!
>>>
>>> I wrote this little handler to coerce a record into a string. It works
>>> with "German" as System language. Does it work with other languages too?
>>> Who can test?
>>>
>>> display dialog to_String(info for POSIX file "/tmp")
>>>
>>> on to_String(the_record)
>>> try
>>> {a:0} as string
>>> on error cutoff
>>> set cutoff to 4 - (length of cutoff)
>>> end try
>>> try
>>> the_record as string
>>> on error the_record
>>> set the_record to text 1 thru cutoff of the_record
>>> end try
>>> return the_record -- as string
>>> end to_String
>>>
>>> _______________________________________________
>>> Do not post admin requests to the list. They will be ignored.
>>> AppleScript-Users mailing list (email@hidden)
>>> Help/Unsubscribe/Update your Subscription:
>>> s.
>>> com
>>> Archives: http://lists.apple.com/archives/applescript-users
>>>
>>> This email sent to email@hidden
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> AppleScript-Users mailing list (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>>
m
>> Archives: http://lists.apple.com/archives/applescript-users
>>
>> This email sent to email@hidden
>>
>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden