• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Script on the fly? - solved
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
//\//\//\\


References: 
 >Re: Script on the fly? (From: Arthur J Knapp <email@hidden>)

  • Prev by Date: Creating new catalog in Cumulus 5.0
  • Next by Date: Multiple params in list elements
  • Previous by thread: Re: Script on the fly?
  • Next by thread: Re: Script on the fly?
  • Index(es):
    • Date
    • Thread