Home AMX User Forum AMXForums Archive Threads Tips and Tricks

Subroutine calls not allowed in expressions

Hi,

I have an issue with one function passing value to a variable.
I get an error that says, "Subroutine calls not allowed in expressions"
Below is my program code:

DEFINE_VARIABLE
INTEGER nFamSittingRoomTempFlash //variable for ac in gf family sitting
FLOAT ActualTemp
FLOAT SetTemp

DEFINE_FUNCTION KNXGet(DEV dvKNX, INTEGER nAmxNr)
{
SEND_COMMAND dvKNX,"'GET=', ITOA(nAmxNr)"
}


DEFINE_PROGRAM
WAIT 55 'TEMPFLASH'
{
ActualTemp = KNXGet (dvNxbKnx, 81) //error is here
SetTemp = KNXGet (dvNxbKnx, 84) //error is here


nFamSittingRoomTempFlash = !nFamSittingRoomTempFlash

IF(nFamSittingRoomTempFlash = 0)
{

SEND_COMMAND aTP,"'^SHO-2,0'"
SEND_COMMAND aTP,"'^SHO-22,0'"
SEND_COMMAND aTP,"'^SHO-1,1'"
SEND_COMMAND aTP,"'^SHO-21,1'"

}
IF(nFamSittingRoomTempFlash = 1)
{

SEND_COMMAND aTP,"'^SHO-1,0'"
SEND_COMMAND aTP,"'^SHO-21,0'"
SEND_COMMAND aTP,"'^SHO-2,1'"
SEND_COMMAND aTP,"'^SHO-22,1'"

}

}

Can someone help me with the solution?

Thank you all!

Comments

  • mighemighe Posts: 39
    DEFINE_FUNCTION KNXGet(DEV dvKNX, INTEGER nAmxNr)
    {
        SEND_COMMAND dvKNX,"'GET=', ITOA(nAmxNr)"
    }
    

    does not return anything: it lacks of return type in signature and a return statement.
  • PhreaKPhreaK Posts: 966
    What mighe said ^^^

    Also, I/O in NetLinx is asynchronous, so simply returning that send_command from your GetKNX(..) function will not give you the behaviour that you are looking for.

    To capture the response from a send_command you will need to use a data_event with a command handler.
    ...
    
    send_command vdvFooBar, "'my command'"
    
    ...
    
    
    define_event
    
    data_event[vdvFooBar]
    {
    	command:
    	{
    		// parse your response here (it will be in data.text)
    	}
    }
    
  • MarkCoMarkCo Posts: 18
    Thanks for the response guys. :)
    You have helped a lot
Sign In or Register to comment.