Please note that you can subscribe to the individual forums. A subscription for news only covers the news.
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.
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.
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.
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.
Thanks Subbie53 and Sven for your feedback. I think I understand both your observations about ‘notif’: it knocks out the entire string:
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. 🙂
PS. I wish I was 20 years old.
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:
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.
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.