Re: Define script object with variable
Re: Define script object with variable
- Subject: Re: Define script object with variable
- From: has <email@hidden>
- Date: Wed, 14 Aug 2002 23:03:32 +0100
Laine Lee wrote:
>
I've been working with a script to save automatically generated scripts to
>
the scripts folder. I've been creating a file, writing the script text to
>
the file, then using osacompile to turn it into a compiled script. It would
>
seem easier to me to put my automatically generated script into a script
>
object and use the store script command. Is there any way to define a script
>
object with a variable?
If you're mashing your automatically generated script together as a string
and compiling that, you could use something like:
on run
set theName to "Bob"
set scriptString to "set str to \"hello " & theName & \"
display dialog str"
set obj to run script "script
" & scriptString & "
end script"
store script obj in filePath
end run
Depending on circumstances, you may not have to indulge in such crudity
(messing with strings to create customised scripts is ugly, and a pain to
write and test). If the only thing changing is the data (and the stored
script doesn't need to be editable), you could cut straight to the chase:
on run
set theName to "Bob"
script obj
property str : "hello " & theName
display dialog str
end script
store script obj in filePath
end run
HTH
has
--
(My email address has changed from <email@hidden> to
<email@hidden>. Please update your address books accordingly.)
_______________________________________________
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.