Order Sensitive Procedure(s)?

Discussion in 'Pascal Logic Code Examples' started by David H, Dec 13, 2005.

  1. David H

    David H

    Joined:
    Dec 12, 2005
    Messages:
    1
    Likes Received:
    0
    Location:
    Melbourne
    First Post. I don't think this is really the right spot to put this question but I couldn't find anywhere better.
    Procedures in the Logic Engine they seem to be order sensitive.
    Below I have attached code segments. While they're essentially the same thing. One will work and one won't work.
    Is this a known issue? Got a good explanation?
    I would appreciate any input as it was a pain in the behind to work out what was going wrong in the code i was debugging.

    [edit] altered the Group Addresses so they were the same and fixed formatting.
    Code:
    {Procedure Works}
    procedure DemoWorks;
    begin
      once(GetLightingState(1)) then
        SetLightingState(3,ON);
      once(GetLightingState(2)=OFF) then
        SetLightingState(3,OFF);
    end;
    
    {Procedure Fails}
    procedure DemoFails;
    begin
      once(GetLightingState(2)=OFF) then
        SetLightingState(3,OFF);
      once(GetLightingState(1)) then
        SetLightingState(3,ON);
    end;
     
    Last edited by a moderator: Dec 13, 2005
    David H, Dec 13, 2005
    #1
  2. David H

    Richo

    Joined:
    Jul 26, 2004
    Messages:
    1,257
    Likes Received:
    0
    Location:
    Adelaide
    Code:
    {Procedure Works}
    procedure DemoWorks;
    begin
      once(GetLightingState(1)) then
    ...
    
    Tip: Use the CODE tags to preserve formatting. (the hash (#) tool bar button when editing you post)
     
    Richo, Dec 13, 2005
    #2
  3. David H

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    I believe that this problem is related to the use of the once statement within a procedure.

    Once should only ever be used within Module code. I will update the compiler to prevent you from doing this.
     
    Darren, Dec 14, 2005
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.