getting a script within a script

so in my script you manually (in the script) set the variables for how long you want to delay and how many times to repeat. So like I want my script so you can choose a script file and stick it’s contents within the other script…confusing i know…but here is my code

set user_time to "120"  as string
set x to "5" as string
repeat x times
	--chosen script contents here--
	delay user_time
end repeat

thats the idea anyway…

Sounds like you want to just run the chosen script a certain number of times with a given delay?

You could do it like this…

set user_time to "120" as string
set x to "5" as string

set scriptFile to choose file with prompt "Please select the script to run"

repeat x times
	tell application "Finder" to open scriptFile
	delay user_time
end repeat

hi hendo,

you can also use ‘run script’, like this:


set user_time to "120" as string
set x to "5" as string

set scriptFile to choose file with prompt "Please select the script to run"

repeat x times
	run script scriptFile
	delay user_time
end repeat

Good point, that is a better option.

Dave

thanks! just what i was trying to do

Or you can use a “script object” construction like this:


set delayTime of myDelay to 120
set delayRuns of myDelay to 5
tell myDelay to run_me()

script myDelay
	property delayTime : 0
	property delayRuns : 0
	on run_me()
		display dialog "delayTime is " & delayTime & ". Runs = " & delayRuns
	end run_me
end script

HTH,

Vince

You can also send parameters with the ‘run script’ command.

gl,