Questions about loading scripts and relative paths.

I have a script that runs thru iChat and allows me to remotely control my networked computers. One of the “commands” is a weather command that uses a python script to scrap yahoo weather and returns the results. Since I’m calling a handler in the weather script to return the weather results is there a way to have a non relative path?

This is my weather “command”.

on AAIR(dynamicCommand)
	--set weather_loc to findLoc()
	set weather_loc to POSIX path of ((path to home folder as text) & "")
		if dynamicCommand is "weather" then
			set theResponse to "NULL area code."
			set theWeather to do shell script ("python " & weather_loc & " " & dynamicCommand)
			set theResponse to theWeather
		end if
	on error error_message
		set theResponse to "Weather Control - error retrieving weather. " & error_message
	end try
	--set theResponse to weather_loc
	return theResponse
end AAIR

When I compile this script weather_loc get’s stuck to my systems information. Is there a way around this?

The only time a path gets “stuck” is if you defined the variable as a property. Properties are remembered when you compile the script. So if you defined it like the following then it will get stuck to the path on the computer where the script was compiled.

property weather_loc : POSIX path of ((path to home folder as text) & "")

The way around that is to use “set” to define it then it gets evaluated each time the script is run.

And of course your other option, if the above doesn’t help, is to pass in the path. So you would want something like the following for the handler name:

on AAIR(dynamicCommand, weather_loc)