Can't get this script to return a value from another machine.

Hello!

I�m trying to get this script to return a value from another machine. The following works just fine from within Script Editor:

global remoteMachine, batteryVoltage
set remoteMachine to "eppc://sense.local"

using terms from application "Finder"
	try
		tell application "Finder" of machine remoteMachine
			set batteryVoltage to (get LabJack pin AI8)
			
		end tell
	end try
end using terms from

display dialog batteryVoltage

Yet when I try and adapt it to work in Xcode:

global batteryVoltage
set remoteMachine to "eppc://sense.local"

on clicked theObject
	
	if (name of theObject is "updateVoltage") then
		using terms from application "Finder"
			try
				tell application "Finder" of machine remoteMachine
					
					set batteryVoltage to (get LabJack pin AI8)
					
				end tell
			end try
		end using terms from
		
	end if
	set contents of text field "batteryVoltageField" of window "mainWindow" to batteryVoltage as number
end clicked

…I get an error stating the �The variable batteryVoltage is not defined. (-2753)�

What am I doing wrong?
Thanks!!

Really, that works from Script Editor? What is “get LabJack pin AI8”? Why did you change “global remoteMachine, batteryVoltage” to “global batteryVoltage”?

Jon

Hello!

Yes, that script works just fine from ScriptEditor. “Get LabJack pin AI8” is basically telling one of these (http://labjack.com/labjack_u12.html) to get a value from one of the pins (measuring points). In my case, I’m measuring the voltage of a battery. The value that is returned is simply a number.

As far as the global variables, I am honestly just trying different combinations. Even if both they both are "global remoteMachine, batteryVoltage” I still get the same result.

I’m sorry for not clarifying this from the beginning.

Thanks for your help!

A little more information; this is the Event Log from the code executed in ScriptEditor:


tell application "Finder" of machine "eppc://sense.local"
	get LabJack pin AI8
		13.0859375
end tell
tell current application
	display dialog 13.0859375
		{button returned:"OK"}
end tell