Home AMX User Forum NetLinx Studio

? working with structures

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)")
}
}

Comments

  • viningvining Posts: 4,368
    The ViewStat_Scheduler has some good examples of this. I sent a PM in response to your PM. Once I get your email I'll send you the zip file. Unlike some folks, I include the .axs files of the module so you can see how it's built and maybe even improve on it. You can possibly also learn from it or get ideas for other projects. If you're a seasoned programmer then you'll probably just get a few laugh at my expense but it's a nice module with a very nice gui.
  • It's not apparent what your actual problem is. I think you are saying there is a syntax error on the CALL line. If you could post a compilable version of your code (ie with all declarations included) we could try to nut it out for you.

    Why are you using CALL instead of a define_function?
  • CT-DallasCT-Dallas Posts: 157
    As a newbie, I am learning by editing existing code. The original code did not use variables and hard coded the temp to send to the CALL. As to why it is structured as a call vs a function, I can not speak to that.

    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).
  • TonyAngeloTonyAngelo Posts: 315
    CT-Dallas wrote:
    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)")
    }
    }

    When referencing Data in a structure, you need a decimal between the structure name and the data type.

    nMorningReset.Hour
    nMorningReset.Minute
    CT-Dallas wrote:
    Are there certain things that a function can do that a call can not?

    A function can return a value.
  • TonyAngeloTonyAngelo Posts: 315
    CT-Dallas wrote:
    As a newbie, I am learning by editing existing code.

    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.
  • CT-DallasCT-Dallas Posts: 157
    nMorningResetHour is actually a variable and not part of a structure. The IF statement seems fine and there are no compiler errors on the IF.
  • The problem is that you have defined the type but not the actual variable. You need to instantiate a variable using the struct as its type
    define_variable
    
    strHVACSystem MyHVACSystem[100]
    

    then refer to the variable not the type in the code.
  • CT-Dallas wrote:
    Are there certain things that a function can do that a call can not?

    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:
    DEFINE_CALL 'AddtoHVACQue' (CHAR cCMD[50])
    
    define_function AddtoHVACQueue (char sCommand[50])
    
  • CT-DallasCT-Dallas Posts: 157
    thank you! That makes perfect sense.
Sign In or Register to comment.