+ Reply to Thread
Results 1 to 13 of 13

Thread: Delta GCL+

  1. #1
    Join Date
    Feb 2005
    Posts
    1,724
    Post Likes

    Delta GCL+

    In GCL+, how many IF statements can be nested within each other?
    I have a program with 3 or more levels of nested Ifs and the trace does not behave as I expect it.

  2. #2
    Join Date
    Jan 2006
    Location
    Seattle, Wa
    Posts
    116
    Post Likes
    You can use as many "IF" statements as you would like. The more "IF" statements makes it hard to trace what is affecting your logic. 3 is not that many at all. Without seeing your program it would be hard to diagnois your tracing issue.

  3. #3
    Join Date
    Feb 2005
    Posts
    1,724
    Post Likes
    Thread Starter
    Thanks, just to be clear I am talking about nested Ifs, and not just regular Ifs.
    It is on a DSC controller, and the top If statement is false, but the Trace is still going through the 3rd nested if and so on.
    Here is a picture of it.
    Line 49 is False, but the trace is still hitting Lines 53,60,69,76, makes no sense to me. I have hit the apply button a few times to be sure that it is the latest trace I am looking at.
    Attached Images Attached Images

  4. #4
    Join Date
    Jan 2003
    Location
    USA
    Posts
    9,437
    Post Likes
    I don't know jack about Delta...but line programming is nothing new to me.

    I assume the green dot is the trace mechanism? If that is the case...why is it passing by line 51? Without that IF statement, the trace path would be logical. Perhaps start looking there.
    Propagating the formula. http://www.noagendashow.com/

  5. #5
    Join Date
    Jan 2003
    Location
    USA
    Posts
    9,437
    Post Likes
    "Else" where it should be "Else If" or "ElseIf" on line 66 hosing it up?
    Propagating the formula. http://www.noagendashow.com/

  6. #6
    Join Date
    Feb 2005
    Posts
    1,724
    Post Likes
    Thread Starter
    The green dot is the trace, yes. That is what I am saying, it should hit 49, it is false then it should jump to 83 but it does not as I expect it. It seems to hit every 2nd nested if statement, which makes no sense to me and that is why I asked the original question.

    May be like you say, GCL+ may require ElseIf to work right but I do not see that as a specific rule in the Docs.

  7. #7
    Join Date
    Jan 2003
    Location
    USA
    Posts
    9,437
    Post Likes
    The only other thing I see is the If statements where you enclosed your conditional statement with () are the only ones that worked.

    Maybe line 51 should be "If (WSHP_LEAD = 2) Then" ?
    Propagating the formula. http://www.noagendashow.com/

  8. #8
    Join Date
    Feb 2005
    Posts
    1,724
    Post Likes
    Thread Starter
    I will give that a shot but doubtful. It seems to me that the trace is hitting every 2nd nested if no matter what the top layer condition evaluates to.

  9. #9
    Join Date
    Sep 2007
    Location
    Under the sea
    Posts
    285
    Post Likes
    I think the trace dot is related to the "OnFor" timers. To make the code easier to read and understand you should use only one "Onfor" or "Offfor" on a single line only. Create local variables for status or states.

    IE.
    Var HeatMode

    if (whsp_Heat required) onfor 3:M then
    heatmode = on
    else
    Heatmode = off
    end if

    if (Heatmode = on) then

    if Leadwhsp = 2 then
    start 2
    stop 1
    else
    start 1
    stop 2
    end if

    else
    stop1, 2
    end if

    Onfor and offfor statements are tricky. use them only if needed.
    In case of malfunction-Reconnect brain BEFORE starting mouth.

  10. #10
    Join Date
    Feb 2005
    Posts
    1,724
    Post Likes
    Thread Starter
    I think that is it, thanks.
    I will modify.

  11. #11
    Join Date
    Mar 2007
    Posts
    304
    Post Likes
    don't know Delta but those green dots don't make sense at all... if it's tracing line 53 then how come it's not tracing line 55, 56, 58, 62, 63 .....

    If this was JC-basic then I would suspect line 51... i've seen unpredictable results in JC-Basic when you mix integer and real numbers in a statement

    Maybe your point WSHP_LEAD is a real and freaks out when it sees 2, which is an integer
    a JC-Basic solution would be to write.... if WSHP_LEAD = 2.0

    wonder if this would solve your problem.... keep us posted

  12. #12
    Join Date
    Feb 2005
    Posts
    1,724
    Post Likes
    Thread Starter
    Thanks, but the problem was the "Onfor" or "Offfor" conditions like AutoPilot said, it traces through eventhough it is in nested ifs, so I modified the code and it is all good

  13. #13
    Join Date
    Sep 2007
    Location
    Under the sea
    Posts
    285
    Post Likes
    Onfor and Offfor Statements set internal timers in the program. The trace dots are just indicating that those lines with specified conditions are setting/resetting the timers.
    In case of malfunction-Reconnect brain BEFORE starting mouth.

+ Reply to Thread

Quick Reply Quick Reply

Register Now

Please enter the name by which you would like to log-in and be known on this site.

Please enter a password for your user account. Note that passwords are case-sensitive.

Please enter a valid email address for yourself.

Log-in

Posting Permissions

  • You may post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts
  •