Welcome to the forum   
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Share
Options
View
Go to last post in this topic Go to first unread post in this topic
Offline dodi  
#1 Posted : 22 February 2024 18:37:15(UTC)
dodi

Belgium   
Joined: 03/07/2012(UTC)
Posts: 3
Hi,

Now my train landscape is finished, I am programming some scenario's using advanced events of the CS3. Nothing really exotic. Some things work very well, but I have
an issue with an IF statement that I want to repeat in a loop.

The goal is to make a train pass the station on one pass, and the next time pass on a track outside the station.

I have created two events for the train, one to set the turnouts so the train goes to the station and stops there. A second one to set the turnouts so the train does not go to the station but the parallel track.

I have next created an IF macro. The train is starting stationary. I test on a contact rail. If the train is on the parallel track, the sequence to send it to the station is called, otherwise the sequence to send the train to the parallel track is called.

I want this to repeat indefinitely. So I created an event which contains a loop. In the loop I call the event with the IF clause.

This (with my background as programmer, a long time ago), should do the trick. However, it does not :(

It seems that as soon as the IF decision is made, and the right event is called, the IF test immediately repeats itself, not stopping for the called event to finish first.

Is there a way to force the IF to wait to test again until the called event is finished (e.g. taking the train to the station and stopping there)?

Or am I completely misunderstanding the Marklin logic? And if my method is wrong, what could be a good method with Marklin events?

Thank you very much for any time spend to answer this beginners question.

Dodi
thanks 1 user liked this useful post by dodi
Offline dodi  
#2 Posted : 23 February 2024 07:56:41(UTC)
dodi

Belgium   
Joined: 03/07/2012(UTC)
Posts: 3
Answering my own question...

Apparently the processes (events) placed in the THEN and ELSE clause are spawned detached. Meaning the IF clause is evaluated immediately again in the loop... Not what a traditional programmer would expect, but probably it is strange Marklin logic...
But, there is something one can do to prevent it: if you click on the event in the THEN (or ELSE) container, you can add delay, but there is also a nearly invisible tick box (light grey on a bit less light grey). Actually the box looks greyed out, but it isn't.
If you tick that box, the process gets fully executed before the IF is evaluated again in the loop. I really did not see that tick last night. I use VNC viewer remote, maybe it would be clearer on the CS3 itself, dunno, didn't check yet.
Anyway, it now works as expected.

Dodi
thanks 1 user liked this useful post by dodi
Offline marklinist5999  
#3 Posted : 23 February 2024 13:50:43(UTC)
marklinist5999

United States   
Joined: 10/02/2021(UTC)
Posts: 3,140
Location: Michigan, Troy
Oh, maybe that's the problem I have with getting the delay executions to work right.
Offline rhfil  
#4 Posted : 23 February 2024 19:34:49(UTC)
rhfil

United States   
Joined: 05/09/2014(UTC)
Posts: 427
Location: NEW HAMPSHIRE, Somersworth
If you bring up the Event as though editing it and set things in motion like normal you can actually watch the Event go through the various windows. Good way to see problems.
thanks 2 users liked this useful post by rhfil
Offline dodi  
#5 Posted : 23 February 2024 22:05:58(UTC)
dodi

Belgium   
Joined: 03/07/2012(UTC)
Posts: 3
Originally Posted by: rhfil Go to Quoted Post
If you bring up the Event as though editing it and set things in motion like normal you can actually watch the Event go through the various windows. Good way to see problems.



Yes, indeed. That's how I finally understood the IF fell through rapidly. The execution red line jumped back and forth quickly over the IF statement.

Dodi
thanks 1 user liked this useful post by dodi
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

| Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.438 seconds.