Keyboard Shortcuts
ctrl + shift + ? :
Show all keyboard shortcuts
ctrl + g :
Navigate to a group
ctrl + shift + f :
Find
ctrl + / :
Quick actions
esc to dismiss
Likes
Search
How to edit script, re-exec without restarting?
#scripting
I'm working on a script to facilitate virtual block handling (time before unoccupied, etc) by considering time entered and exited and block length. Since every car being pulled draws power I can estimate how long it will be in a virtual block (assuming same speed).
?
The script is loaded at startup and adds property change listeners.
?
Since I'm learning JMRI I have to make incremental changes and every time I have to restart since the old listener is still active.
?
Maybe I could save my chained listener objects in a memory and check if it's there if I re-execute the script but wanted to check with experts first.
Is there any advice for avoiding a restart? |
stevemac,
?
The document at provided two implementations of () and one of those might be used as your script closes down for the next trial run.
?
If your development is still at the stage of unexpected termination, this idea might not be very useful.
?
Suggestions for all beginning Jython programmers: Keep the Console window open and at least partially visible and put in a lot of print or log statements.
?
Cliff in Baja SoCal |
I don't know the best way to remove old listeners, but I have tested this and it seems to work.
Jython variables that are not within a class are global for the duration of the JMRI session. The first run will create the listener. ?Subsequent runs will remove the old listener and add a new one. Dave Sand ----- Original message ----- From: stevemac <steveo@...> Subject: [jmriusers] How to edit script, re-exec without restarting? #scripting Date: Wednesday, March 19, 2025 11:06 AM I'm working on a script to facilitate virtual block handling (time before unoccupied, etc) by considering time entered and exited and block length. Since every car being pulled draws power I can estimate how long it will be in a virtual block (assuming same speed). ? The script is loaded at startup and adds property change listeners. ? Since I'm learning JMRI I have to make incremental changes and every time I have to restart since the old listener is still active. ? Maybe I could save my chained listener objects in a memory and check if it's there if I re-execute the script but wanted to check with experts first. Is there any advice for avoiding a restart? |
to navigate to use esc to dismiss