Re: Format of strings when using run script -- ok, next step
Re: Format of strings when using run script -- ok, next step
- Subject: Re: Format of strings when using run script -- ok, next step
- From: Paul Berkowitz <email@hidden>
- Date: Tue, 20 May 2003 00:16:20 -0700
What do you mean by " load a text applescript into a database"? How are you
getting the text? If you've saved the script as a text file and then read it
by the read command, you could use text item delimiters (or 'do shell script
"tr"') to replace the line endings by "\\r". If there's any chance that the
script could be longer than 4000 or so lines, you'll need a routine to deal
with the stack overflow:
set textVersion to read alias filePath
try
set theLines to paragraphs of textVersion
on error
set theLines to my LargeTidsList(textVersion, return) -- or (ASCII
character 10) if text has Unix line endings
end try
set oldTids to AppleScript's text item delimiters
set AppleScript's text item delimiters to "\\r"
set textVersion to theLines as string
set AppleScript's text item delimiters to oldTids
textVersion
on LargeTidsList(theText, tid)
local oldTids, newList, a, z, done
set oldTids to AppleScript's text item delimiters
set AppleScript's text item delimiters to {tid}
set {a, z} to {1, 3900} ---- safer (found 3991 was max once)
set newList to {}
set done to false
repeat until done
try
set newList to newList & text items a thru z of theText
set {a, z} to {a + 3900, z + 3900}
on error -- last segment, fewer than 3900
set newList to newList & text items a thru -1 of theText
set done to true
end try
end repeat
set AppleScript's text item delimiters to oldTids
return newList
end LargeTidsList
--
Paul Berkowitz
>
From: Jaime Magiera <email@hidden>
>
Date: Tue, 20 May 2003 02:56:28 -0400
>
To: Paul Berkowitz <email@hidden>
>
Cc: Applescript-Users <email@hidden>
>
Subject: Re: Format of strings when using run script -- ok, next step
>
>
Ok, I get that part. Now I have to figure out how to save an
>
Applescript as plain text including \n, \r, etc.
>
>
What I'm trying to do is load a text applescript into a database, then
>
retrieve the text into an applescript application (via SOAP) which then
>
compiles and saves the transmitted text as separate scripts. Since the
>
line endings are necessary, I'll need to include the line endings in
>
the database string. Bummer.
>
>
Jaime
>
>
On Tuesday, May 20, 2003, at 02:40 AM, Paul Berkowitz wrote:
>
>
> On 5/19/03 11:03 PM, "Jaime Magiera" <email@hidden> wrote:
>
>
>
> set scriptObj to run script "script" & return & "set helloString to
>
> \"Hello
>
> world\"" & return & "display dialog helloString" & return & "end
>
> script"
>
>
>
> --or (all one line)
>
>
>
> set scriptObj to run script "script\rset helloString to \"Hello
>
> world\"\rdisplay dialog helloString\rend script"
_______________________________________________
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.