Re: Script on the fly? - solved
Re: Script on the fly? - solved
- Subject: Re: Script on the fly? - solved
- From: Arthur J Knapp <email@hidden>
- Date: Mon, 05 Nov 2001 19:07:56 -0500
>
Date: Mon, 5 Nov 2001 20:04:10 +0100
>
From: "Serge Belleudy-d'Espinose" <email@hidden>
>
Subject: Re: Script on the fly? - solved
>
At 12:32 -0500 5/11/01, Arthur J Knapp wrote:
>
> 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.
>
try
>
set xScript to run script "on xHandler()
>
-- handler that returns nothing
>
end xHandler"
Well, it's clear that you really didn't understand my example, but
that's OK, since it wasn't working "as is" anyway. ;-)
Some corrections:
set header to "script returnCompiledScript" & return
set tailer to "end script" & return & "return returnCompiledScript"
set yourSourceCode to "
on xHandler()
-- handler that returns nothing
end xHandler"
set a_compiled_script to run script (header & yourSourceCode & tailer)
>
I would be curious to know whether you are suffering from silent coercion, and
>
if so what osax it is :)
The only osax I have in use is Jon's commands.
>
However, I'm glad to say that playing hard with this idea made me find the
>
solution, and it's obvious!
>
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"
As I showed, you just need to add a "return" statement to the end of
the string:
set xVar to 3
set xModName to "AppleMod"
set xScript to "
script xObject
property xProp : " & xVar & "
on xHandler()
return xProp
end xHandler
end script
return xObject"
set xMod to run script xScript
Arthur J. Knapp
http://www.stellarvisions.com
mailto:email@hidden
Hey, check out:
http://www.zavatone.com/