PDA

View Full Version : Applescript "Variable hdg is not defined"




Dreamspinner
Feb 12, 2013, 12:40 PM
This is my first Applescript, and has been working for 2 days when run from thr Applescript editor. Today, I started the Script Menu and put my script into the folder.

When I ran it from there, nothing happened. When I ran it from the editor, I got the error "Variable hdg is not defined" on the line with the <---.


on enabledGUIScripting(true)
tell application "System Events"
activate -- brings System Events authentication dialog to front
set UI elements enabled to true
return UI elements enabled
end tell
end enabledGUIScripting

tell application "RUMlog"
set hdg to TxRprt
set beam to hdg as string <---- error here
repeat while length of beam as string < 3
set beam to "0" & beam
--display dialog "Now beam = " & beam buttons {"OK"}
end repeat
activate application "RotorDCU"
tell application "System Events"
tell process "RotorDCU"
set value of text field 1 of window "RotorDCU" to beam
end tell
end tell
end tell



Partron22
Feb 12, 2013, 04:25 PM
TxRprt is probably coming back undefined from the app, which leaves hdg undefined when you try to convert it to a string->error.

Try adding the line 'set hdg to ""' before 'set hdg to TxRprt'.

numero
Feb 12, 2013, 04:26 PM
TxRprt v : Writes the parameter into the Sent RST field
TxRprt
TxRprt text

TxRprt doesn't return anything. It expects a parameter. I don't know what is appropriate since I'm not into HAM, but it would be something like
TxRpt "hello"

Dreamspinner
Feb 12, 2013, 06:33 PM
TxRprt is probably coming back undefined from the app, which leaves hdg undefined when you try to convert it to a string->error.

Try adding the line 'set hdg to ""' before 'set hdg to TxRprt'.

AHA! Your idea about TxRprt being un-defined was spot on! Thanks!
I had two copies of RUMlog, 1 exposing TxRprt, 1 not. Oddly, looking at the dictionary of both versions with Script Editot, they seem identical.

----------

TxRprt v : Writes the parameter into the Sent RST field
TxRprt
TxRprt text

TxRprt doesn't return anything. It expects a parameter. I don't know what is appropriate since I'm not into HAM, but it would be something like
TxRpt "hello"

Thanks for the response. TxRprt does return a value, it does not expect a value. That is, if I call the correct version of the program.....:confused: