• 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
Evaporating properties
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Evaporating properties


  • Subject: Evaporating properties
  • From: "Marc K. Myers" <email@hidden>
  • Date: Tue, 06 Feb 2001 17:34:24 -0500
  • Organization: [very little]

I wrote the following script to test how an applet could create another
applet and fill it with a script object:

global thePass, newFile

on run
set thePass to 0
end run

on idle
set thePass to thePass + 1
if thePass = 1 then
set theCnt to 16
set newScript to makeScript(theCnt as text)
set myFile to (path to me)
tell application "Finder"
set newFile to (duplicate myFile) as alias
set name of newFile to "New App"
end tell
store script newScript in newFile with replacing
return 2
else if thePass = 2 then
ignoring application responses
tell application (newFile as text) to run
end ignoring
return 2
else
tell me to quit
return
end if
end idle

on makeScript(theText)
script test
property occCnt : theText
on idle
activate
display dialog "It happened " & occCnt & " times."
set occCnt to ((occCnt as integer) + 1) as text
return 4
end idle
end script
end makeScript

There's something peculiar about the property "occCnt" in the created
script. When the created script runs initially it works fine but ends
immediately with a Type 1 error if you try to run it again. I found that
if I opened it in Script Editor and changed the definition of the
property to:

property occCnt:"6"

it would work as expected. Trying to figure out where the trouble was
creeping in, I went back to the creating script and changed the line
there to match. Much to my surprise, when I tried to run the created
script a second time it blew off with a Type 1 error! Going into Script
Editor, keying over the "6", and saving the script again put everything
back as it should be.

It seems to have something to do with the idle handler in the created
script, because if I change the creating script so there's no run
handler in the created script it can be run repeatedly:

on makeScript(theText)
script test
property occCnt : theText
activate
display dialog "It happened " & occCnt & " times."
set occCnt to ((occCnt as integer) + 1) as text
tell me to quit
end script
end makeScript

Does anyone have any idea what's happening here?

Marc [2/6/01 5:28:27 PM]


  • Prev by Date: scripting web sharing control panel
  • Next by Date: Re: Attachability
  • Previous by thread: Re: scripting web sharing control panel
  • Next by thread: Direct character replacement in a string
  • Index(es):
    • Date
    • Thread