PDA

View Full Version : Order Sensitive Procedure(s)?


David H
13 Dec 05, 01:17 PM
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.
{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;

Richo
13 Dec 05, 03:51 PM
{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)

Darren
14 Dec 05, 03:06 PM
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.