Applescript "Variable hdg is not defined"

Discussion in 'Mac Programming' started by Dreamspinner, Feb 12, 2013.

  1. Dreamspinner macrumors member

    Dec 17, 2012
    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
  2. Partron22 macrumors 68020


    Apr 13, 2011
    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'.
  3. numero macrumors regular

    Jul 23, 2002
    TxRprt v : Writes the parameter into the Sent RST field
    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"
  4. Dreamspinner thread starter macrumors member

    Dec 17, 2012
    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.


    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:

Share This Page