Re: Script on the fly? - solved
Re: Script on the fly? - solved
- Subject: Re: Script on the fly? - solved
- From: "Serge Belleudy-d'Espinose" <email@hidden>
- Date: Mon, 5 Nov 2001 20:04:10 +0100
At 12:32 -0500 5/11/01, Arthur J Knapp wrote:
>
> - use the result of a 'run script' in any way
>
>
Try this:
>
>
set header to "script returnCompiledScript" & return
>
set tailer to "end script"
>
>
set a_compiled_script to run script (header & theScriptText & tailer)
Arthur, I had already played with this and my conclusion was that it doesn't work, since run only returns the result of the script, which can be no result at all.
-- begin cut
try
set xScript to run script "on xHandler()
-- handler that returns nothing
end xHandler"
on error errMess
log errMess
end try
-- end cut
--> "No result was returned from some part of this expression."
I would be curious to know whether you are suffering from silent coercion, and if so what osax it is :)
However, I'm glad to say that playing hard with this idea made me find the solution, and it's obvious!
-- begin cut
set xVar to 3
set xModName to "AppleMod"
set xScript to "script xObject
property xProp : " & xVar & "
on xHandler()
return xProp
end xHandler
end script
store script xObject in file \"" & (path to scripts folder) & xModName & "\" with replacing"
run script xScript
set xMod to load script file ("" & (path to scripts folder) & xModName)
tell xMod to xHandler()
-- end cut
So yes, run script allows you to assemble, compile and save script on the fly.
Wououh!
Serge
--
\\//\//\// Serge Belleudy-d'Espinose Institut Jacques Monod
// // //
http://www.ijm.jussieu.fr/ Universite Paris VII - Jussieu
//\//\//\\