? working with structures
CT-Dallas
Posts: 157
In a HVAC control include, I am trying to build a string that will be sent to all of the thermostats in the system. One part of the string is to set the temperature for a particular user designated set point nMorningReset
The value for nMorningReset is stored in a structure that contains the pertinant details about all of the stats in the system.
It appears that I am doing something syntax wise that is not allowed and I need help identifying what exactly I am doing wrong. In this example, the line with the CALL statement is where the problem is. If I am off target, please let me know how to retrieve the data and plug it into a statement.
Thank you in advance!
Here is the code that is causing the compiler error:
// Morning Reset
If((TIME_TO_HOUR(Time) >= nMorningResetHour)
and (TIME_TO_MINUTE(Time) >= nMorningResetMinute)
and (TIME_TO_HOUR(Time) <= nAfternoonResetHour)
and (TIME_TO_MINUTE(Time) < nAfternoonResetMinute)){
Send_String 0,"'Doing morning reset.'"
For(xx=1;xx<=NumberOfStats;xx++) {
CALL 'AddtoHVACQue' ("'SN',itoa(xx),' SC=',itoa (strHVACSystem[xx].nMorningSetPoint)")
}
}
The value for nMorningReset is stored in a structure that contains the pertinant details about all of the stats in the system.
It appears that I am doing something syntax wise that is not allowed and I need help identifying what exactly I am doing wrong. In this example, the line with the CALL statement is where the problem is. If I am off target, please let me know how to retrieve the data and plug it into a statement.
Thank you in advance!
Here is the code that is causing the compiler error:
// Morning Reset
If((TIME_TO_HOUR(Time) >= nMorningResetHour)
and (TIME_TO_MINUTE(Time) >= nMorningResetMinute)
and (TIME_TO_HOUR(Time) <= nAfternoonResetHour)
and (TIME_TO_MINUTE(Time) < nAfternoonResetMinute)){
Send_String 0,"'Doing morning reset.'"
For(xx=1;xx<=NumberOfStats;xx++) {
CALL 'AddtoHVACQue' ("'SN',itoa(xx),' SC=',itoa (strHVACSystem[xx].nMorningSetPoint)")
}
}
0
Comments
Why are you using CALL instead of a define_function?
I can change it!
Are there certain things that a function can do that a call can not?
When I spoke to AMX support about this, they had the whole project file and focused on the use of the structure in this instance. Everything is defined, but there seems to be something about referencing the value this way.
You should be able to compile the attached (assuming the syntax issue is resolved).
When referencing Data in a structure, you need a decimal between the structure name and the data type.
nMorningReset.Hour
nMorningReset.Minute
A function can return a value.
That's a good way to learn if the programming you're dissecting is good. Some of the best code that I've learned has come from the very experienced programmers who populate this forum.
then refer to the variable not the type in the code.
define_call is the old way, define_function is the new. functions can return values, and they don't have names which are strings. You can continue to use calls if you like but there's no particular reason to do so. Convert from call to function simply by removing the quotes round the name: