Forum

Please note that you can subscribe to the individual forums. A subscription for news only covers the news.

Notifications
Clear all

Multiple conditions  

   RSS

0

Hello

Another question from the remedial hut, should anyone have the time and inclination... This one on conditionals.

I’m not sure how to phrase this question in the simplest way, so I’ll start at the end.

[Procedure-Choices]

Case=First

               When=Cross

                              Message=Punish!

              

               When=Sweet

                              Input=Tea?

Case=End                   

 

I want to insert a condition to ensure that once the event (‘punish’ or ‘tea’) has triggered, it doesn’t do so again. Further, I’d like the other one to trigger if the flag (‘cross’ or ‘sweet’) is active. So, if both Cross and Sweet are active, then Sub is punished on the first circuit and offered tea on the second.

I’ve tried various things involving ‘notif’ and ‘whennot’, but I can’t seem to fathom it. I’m beginning to think that conditionals with ‘when’ are not the path to glory here. I’m also completely frazzled with the problem – can’t see the wood for the brick wall.

Any guidance appreciated.

7 Answers
0

Some more detail. As I’ve described things so far, an obvious solution is to remove the flag once it’s served:

      When=Cross

                   Message=Punish!

                   RemoveFlag=Cross

But I don’t want to remove it at this stage. In the script, the flag triggers a pertinent comment or question, but it also serves a subsequent objective.

I’ve also realised that a series of conditions separated by commas is possible. So I could set a second flag, something like ‘CrossPending’, and then remove that:  

      When=Cross,CrossPending

                    Message=Punish!

                    RemoveFlag=CrossPending

Seems a bit clunky, but it works.

If you’ve got some insight, I welcome it, but all in all I regret the question!

0

I'm not sure exactly what your asking, but I have been working with the case stuff for a little bit. I've noticed I had problems when it came to adding conditionals to the statement part of the case. I had one where the when would trigger first, but because there was a notif in the statement it would just void the entire string of commands instead of moving to the next when. The way I fixed my own case was to create two separate cases. In order for the first one to not trigger multiple times I put a flag in the statement to prevent it and then used a timer at midnight to reset the flags. Not sure if any of that helps.. but yeah. 

0

I realise that complex test are tricky. In this case, I think that two flags may be the best solution. Sometimes it's easier to break it up in procedures, using if and notif. 

Note that if and notif prevents all of the procedure (or other objects) from being called. No matter where in the procedure it is placed. This may not be the most logical way of doing it, but the program is more than 20 years old, and started with a quite primitive syntax. 

There are several ways to ensure that a flag is removed. One is to use a timer once a day, as @Subbie53 has done. It could also be a NewDay event. Another way is to use a duration in the flag, to have it removed after some specified time. And of course you can use a procedure or report that you know is called when there is no longer a need for the flag. 

Sven

 

 

0

Thanks Subbie53 and Sven for your feedback. I think I understand both your observations about ‘notif’: it knocks out the entire string:

When=YES

               notif=X

               Blah blah

When=YES

               if=X

               Blah Blah

So if YES and X, nothing happens: the script doesn’t get past the first ‘when’, which is blocked by the existence of ‘X’. My solution so far has been to use a series of ‘when’ conditions: When=YES,X; I can then remove the ‘X’ condition in the statement to stop this ‘when’ triggering again. I have a number of flags set up on entry which are then removed at appropriate moments. I fear that if mine were a building, there’d be an awful lot of materials used for limited living space, and God knows I wouldn’t trust it to stand up in a breeze. It is fun, though. 🙂

0

PS. I wish I was 20 years old.

0

I advise you not to mix if/notif with case. If you use if/notif, and there can be very good reasons to do so, place them in the beginning of the procedure, so it if obvious that they cover the whole procedure. 

In the above example, you will never even get to the when. Either the if or the notif will prevent it all from being used. 

However, you can have a case in a case. Like this:

Case=First

   When=Cross

      Case=First

         WhenNot=PunishDone

            Message=Punish!

         When=None

            Input=Tea?

      Case=End

   When=Sweet

       Input=Tea?

Case=End         

 

I don't think it is the best solution to your problem. I just wanted to mention it. 

You can easily build a building that is in danger of collapsing if you change anything. The art is to keep it as simple as possible, though make it do what is necessary.

Sven

0

Case-within-case is a minor revolution over here. I won't try to explain, but it certainly offers a more efficient solution to the one I had. Well worth mentioning. Thanks.