hmclay Posted November 10 Posted November 10 I would like to have the function of "subroutine call & return" in 3D-Modellbahn Studios as implemented in other languages.
BahnLand Posted November 10 Posted November 10 Hallo / hello @hmclay, definiere im Modellbahn-Studio ein Benutzer-definiertes Ereignis und rufe dieses in einem anderen Ereignis mit der Aktion "Benutzer-definiertes Ereignis auslösen" auf. Define a user-defined event in the Train Studio and call it up in another event with the "User-defined event" action. Beachte aber bitte, dass das Verhalten einer Subroutinen mit Rückkehr zum Aufrufer nach Beendigung der Subroutine nur dann funktioniert, wenn die Subroutine (das Benutzer-definierte Ereignis) keine Aktion "Ausführung verzögern" enthält. Betrachte hierzu das beigefügte Anlagen-Beispiel: Please note, however, that the behavior of a subroutine with return to the caller after completion of the subroutine only works if the subroutine (the user-defined event) does not contain a "Defer execution" action. Please refer to the attached example: Subroutine Demo.mbp Schalte bitte das Ereignisprotokoll ein, um den Ablauf beim Drücken des obigen Buttons verfolgen zu können: Please activate the event trace to be able to follow the process when pressing the above button: Wird der Button aktiviert, ergibt sich der im obigen Bild links dargestellte Ablauf: Das Hauptereignis ruft das Benutzer-definierte Ereignis "Subroutine 1" auf, das wiederum ein weiteres Ereignis "Subroutine 2" aufruft. Nach Beendigung des jeweiligen Benutzer-definierten Ereignisses kehrt der Ablauf in das aufrufende Ereignis zurück und wird dort fortgesetzt. If the button is activated, the sequence shown in the above image on the left results: The main event calls the user-defined event "Subroutine 1", which in turn calls another event "Subroutine 2". Once the respective user-defined event has been completed, the sequence returns to the calling event and is continued there. Wir der Button deaktiviert, durchläuft das Benutzer-definierte Ereignis "Subroutine 1" eine Zeitverzögerung (siehe den Ablauf rechts). Diese bewirkt, dass das Ereignis "Subroutine 1" an dieser Stelle beendet und nach Ablauf der Wartezeit in einem neuen Prozess fortgesetzt wird. Die Beendigung der "Subroutine 1" bewirkt eine sofortige Rückkehr zum aufrufenden Hauptereignis, dessen Ablauf somit ohne Abwarten der Zeitverzögerung fortgesetzt und beendet wird (siehe die Uhrzeit [12:24:38]). Subroutine 1 wird dagegen erst nach Ablauf der Wartezeit 5 Sekunden später ([12:24:43]) fortgesetzt, wo das aufrufende Hauptereignis längst beendet ist. If the button is deactivated, the user-defined event "Subroutine 1" runs through a time delay (see the process on the right). This has the effect that the "Subroutine 1" event ends at this point and is continued in a new process after the delay time has elapsed. The termination of "Subroutine 1" causes an immediate return to the calling main event, whose process is thus continued and terminated without waiting for the time delay (see the time [12:24:38]). Subroutine 1, on the other hand, is only continued after the delay time has expired 5 seconds later ([12:24:43]), when the calling main event has long since ended. Die Nachbildung einer synchronen Subroutine mithilfe des Benutzer-definierte Ereignisses funktioniert also nur, wenn in der Subroutine keine Zeitverzögerung eíngebaut ist. The simulation of a synchronous subroutine using the user-defined event therefore only works if no time delay is built into the subroutine. Viele Grüße / many greetings BahnLand
EASY Posted November 10 Posted November 10 (edited) Hello, ... I deleted the text because I misinterpreted something... ... ich habe den Text gelöscht, da ich etwas falsch interpretiert habe... Gruß / greetings EASY Edited November 10 by EASY
Goetz Posted November 10 Posted November 10 Hallo @EASY, as implemented in other languages heißt frei übersetzt: "So, wie ich es aus anderen Sprachen kenne." Er will schon bei Lua bleiben.
EASY Posted November 10 Posted November 10 Hallo, @Goetz, ... das habe ich dann auch gemerkt und habe den Text gelöscht... Du warst nur schneller. Gruß EASY
hmclay Posted November 12 Author Posted November 12 I would like to have subroutine call/return in 3D Train Studio . Guessing it may be quite an involved undertaking. But sure would be a welcomed addition. Put a request in the supplied forum here ...
Neo Posted November 12 Posted November 12 3D Train Studio already supports subroutines. What are you trying to achive and what have you already tried? Kind regards, Neo
EASY Posted November 12 Posted November 12 What is the difference between the example from BahnLand and what you want? EASY
hmclay Posted November 19 Author Posted November 19 If I understand @BahnLand example, it was written in Lua script language. What I was trying to infer was that subroutine call and return be included in Train Studio language . I have tried using script condition within an event, then go and perform a task and come back to the event, however the calling event goes to the next line of code without waiting for the script to complete. Therefor, I would need to put a defer action line in to wait for the script to do it's task(s). Am I explaining adequately, or do I not understand how to use Train Studio Language correctly. I am not proficient in Lua, so I only use it sparingly and mostly from published routines or very small math and crane operations. Therefore would like to have the function in Train Studio Language.
Phrontistes Posted November 19 Posted November 19 vor 4 Stunden schrieb hmclay: however the calling event goes to the next line of code without waiting for the script to complete This is an expected behavior of an event-driven, object-oriented language.
BahnLand Posted November 19 Posted November 19 Hallo / hello @hmclay, vor 6 Stunden schrieb hmclay: If I understand @BahnLand example, it was written in Lua script language. Nein! / No! In der Ereignisdefinition des obigen Demo-Beispiels existiert keine einzige selbst geschriebene Lua-Zeile. Der komplette Ablauf wurde ausschließlich mit der grafischen Ereignisverwaltung realisiert. In the event definition of the demo example above, there is not a single self-written Lua line. The entire process was realized exclusively with the graphical event management. Die Trace-Ereignisse dienen ausschließlich der Ereignisprotokollierung. Sie besitzen keinen Inhalt. The trace events are used exclusively for event logging. They have no content. Es genügt, das Benutzer-definierte Ereignis "Trace 1" (mit 1 Parameter) oder "Trace 2" (mit 2 Parametern) aufzurufen, um im aktivierten Ereignisprotokoll einen entsprechenden Trace-Eintrag zu erzeugen. It is sufficient to call up the user-defined event "Trace 1" (with 1 parameter) or "Trace 2" (with 2 parameters) to generate a corresponding trace entry in the activated event trace. Sinn und Zweck des obigen Beitrags war, nur mithilfe solcher Trace-Einträge den Ablauf aufgerufener "Unterprozedur"-Abläufe mit und ohne Zeitverzögerung - mit Mitteln der grafischen Ereignisverwaltung - zu visualisieren. The purpose of the above article was to visualize the flow of called "sub-procedure" sequences with and without defer execution - using graphical event management - only with the help of such trace entries. Viele Grüße / many greetings BahnLand
hmclay Posted November 19 Author Posted November 19 I Posted: however the calling event goes to the next line of code without waiting for the script to complete. Therefor, I would need to put a defer action line in to wait for the script to do it's task(s). Phrontistes Responded: 11 hours ago, Phrontistes said: This is an expected behavior of an event-driven, object-oriented language. OK .... I understand - it's a limitation of object-oriented language. I will continue my work arounds as others have done now that I know it's not possible. If I need to wait for a called user defined event to finish, I can handle that. I now know that I'm not mis-interpreting the use of user-defined or script-condition. Thanks to Phrontistes and BahnLand and NEO and all, for consideration and clarification.
EASY Posted November 19 Posted November 19 Hi, vor 16 Stunden schrieb hmclay: have tried using script condition within an event, then go and perform a task and come back to the event, however the calling event goes to the next line of code without waiting for the script to complete. Therefor, I would need to put a defer action line in to wait for the script to do it's task(s). You can export your 3D Train Studio project as an .mbp file and then publish it here as an attachment. That way we can see what you have done. Du kannst dein 3D Train Studio Projekt als .mbp Datei exportieren und dann hier als Anhang veröffentlichen. So können wir nachsehen, was du gemacht hast. greetings EASY
Phrontistes Posted November 19 Posted November 19 vor 2 Stunden schrieb hmclay: I now know that I'm not mis-interpreting the use of user-defined or script-condition. Really? There is (unfortunately) no user-defined script-condition. There is a user-defined event on the one hand and a script-condition on the other These are two completely different things. Kind regards Phrontistes
hmclay Posted November 21 Author Posted November 21 (edited) That's why I stated User Defined OR Script Condition. The word or was sort of hidden because I emphasized the two commands. Sorry ! I did realize there was a difference ! Enjoying V9 ..... one problem I had is the program bombed out on me twice tonight while laying track and using slopes. Displayed a succession of error messages quickly, then jumped completely out of the program. Lost my work twice. Darn Bug's will show their face on new versions ! Edited November 21 by hmclay changed "or messages" to "of messages"
Phrontistes Posted November 21 Posted November 21 I wasn't sure if you meant "or" in the sense of respectively.
Phrontistes Posted November 21 Posted November 21 vor 2 Stunden schrieb hmclay: Displayed a succession or error messages quickly, Did you send the error message to the developer? You should always do that.
hmclay Posted November 21 Author Posted November 21 (edited) 10 hours ago, Phrontistes said: Did you send the error message to the developer? You should always do that. No Sir, didn't get a chance. Multi messages appeared in successive overlays very quickly then the whole screen went blank before I could even read them. Unless there is a file that records them, I haven't a clue what the code is. Edited November 21 by hmclay Added response
Phrontistes Posted November 21 Posted November 21 (edited) vor 3 Stunden schrieb hmclay: Multi messages appeared in successive overlays very quickly This was a known bug in V 7 or V 8 when driving into a portal with the cockpit camera turned on. Which version are you using? Look here: vor 3 Stunden schrieb hmclay: Unless there is a file that records them No, there is no such file Yes, see Neo's answer below Edited November 21 by Phrontistes
Neo Posted November 21 Posted November 21 vor 3 Stunden schrieb hmclay: Unless there is a file that records them Yes there is an error file which is stored in "C:\Users\<User>\AppData\Local\3D-Modellbahn Studio V9". But this file is deleted once you restart the app, so it is only useful directly after the crash.
hmclay Posted November 22 Author Posted November 22 Good to know about the file. If it happens again. Ill send. I'm using V9 ... Good upgrade ... some nice features !
hmclay Posted November 23 Author Posted November 23 (edited) @Neo and @Phrontistes Attaching error file from error I have been experiencing. Happens when editing track and it seems to happen during slope adjustment. I changed the extension from .log to .pdf so I could sent here. I was able to open it in notepad. Error.pdf Edited November 23 by hmclay wording
Phrontistes Posted November 23 Posted November 23 (edited) Do you use V 9.0.1.8? Sorry, the question is superfluous, you can see that in the log file. The .pdf is damaged. I overlooked that you only changed the extension but did not convert the .log to a .pdf. Edited November 23 by Phrontistes
Goetz Posted November 23 Posted November 23 vor 5 Stunden schrieb hmclay: I changed the extension from .log to .pdf so I could sent here. Better send it to Neo's email address and without the name change! Use "Kontakt" at the bottom of this page to find his email. kind regards Goetz
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now