Scripting: User-Defined Functions
Re: Scripting: User-Defined Functions
Oh - something I'd call a bug with Includes
After I have included a (.inc-) file, this will be remembered in the current state, even after termination of the "including script".
If, after finding an error, I change the file and restart the original script to include and execute the new .inc version, still the old is executed.
The only way I found in the moment: stop/restart XY. That can't be planned??
(I "prefer" some bugs in my scripts - for debugging I have to restart XY several times to load the changed .inc)
So, if loading of Includes should be optimized: at least when the last script terminates, i.e. when no more script is active, all Includes should be dropped.
(And yes: if I have a script loading a script loading a script..., and several happen to include the same file, it's enough to load it only once.)
Or did I understand something wrong?
After I have included a (.inc-) file, this will be remembered in the current state, even after termination of the "including script".
If, after finding an error, I change the file and restart the original script to include and execute the new .inc version, still the old is executed.
The only way I found in the moment: stop/restart XY. That can't be planned??
(I "prefer" some bugs in my scripts - for debugging I have to restart XY several times to load the changed .inc)
So, if loading of Includes should be optimized: at least when the last script terminates, i.e. when no more script is active, all Includes should be dropped.
(And yes: if I have a script loading a script loading a script..., and several happen to include the same file, it's enough to load it only once.)
Or did I understand something wrong?
Win11 Pro 223H2 Gerrman
-
- Site Admin
- Posts: 60569
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Scripting: User-Defined Functions
Cannot confirm. Everytime the include statement is met the file is freshly read from disk.
FAQ | XY News RSS | XY Twitter
-
- Site Admin
- Posts: 60569
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Scripting: User-Defined Functions
Not possible. You have to find another way to build your script-generator.PeterH wrote:One (rather old) wish (from Load) : for include it would be very fine, if it also could replace itself with the contents of a variable (instead of a file). With this you could build a kind of script-generator. (Again: name it "Macro ability".) If it's not too difficult...
FAQ | XY News RSS | XY Twitter
Re: Scripting: User-Defined Functions
admin wrote:Cannot confirm. Everytime the include statement is met the file is freshly read from disk.
Tested with minimal version: always reproducible, even from Fresh;
2 files, both in xyscript folder
tinc.xys:
Code: Select all
// test refresh of a chged .inc
include "tinc.inc"
"Label"
$r = t(0);
Echo "r = $r";
Code: Select all
function t($a) { return $a + 1; }
- change tinc.inc to add 2 instead of 1
- run tinc.xys again result shows 1 again, should be 2
- if I run it in step mode the stmt in the function still shows + 1, not + 2
- restart XY, run again result is 2, as expected.
So what's wrong here?
Win11 Pro 223H2 Gerrman
Re: Scripting: User-Defined Functions
nothing wrong here on my pc.
edit. also OK in ::fresh and "fresh vanilla" (new <xypath>, new <xydata>) .
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
Re: Scripting: User-Defined Functions
After changing the +1 to +2 my result was the same, like PeterH's until I restarted XY. So, what would account for the different result from Sammay's?
Windows 11, 23H2 Build 22631.3447 at 100% 2560x1440
-
- Site Admin
- Posts: 60569
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Scripting: User-Defined Functions
Aaaahh!! Got it! Yep, . Only comes when you load a script from file! Hence did not see it first.
FAQ | XY News RSS | XY Twitter
Re: Scripting: User-Defined Functions
loading from a file here all the time! ::load 'tinc.xys';
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
- Site Admin
- Posts: 60569
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Scripting: User-Defined Functions
I meant using User | Run Script | Load selected script file.
FAQ | XY News RSS | XY Twitter
Re: Scripting: User-Defined Functions
Oh... "Aaaahh!!" me too!
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
Re: Scripting: User-Defined Functions
Really wouldn't have thought of that
Running from Scripting/Load Selected Script File shows that problem, while ::load tinc; doesn't!
The ::load even "repairs" the situation when the load by Scripting Menu fails
Glad that it wasn't a bad dream
Running from Scripting/Load Selected Script File shows that problem, while ::load tinc; doesn't!
The ::load even "repairs" the situation when the load by Scripting Menu fails
Glad that it wasn't a bad dream
Win11 Pro 223H2 Gerrman
-
- Site Admin
- Posts: 60569
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: Scripting: User-Defined Functions
A bit of explanation: I always optimize for performance, not for maintenance. That's why sometimes several entry points and pathways exist for effectively identical functionality. In this case I forgot to add a line of reset code in one of them. So your updated functions were correctly read and added, but *after* the old functions (that had not been reset). Since the first function wins by the current logic, your updated functions never were used.
FAQ | XY News RSS | XY Twitter
Re: Scripting: User-Defined Functions
Thanks for the info.
Now, knowing that ::load works OK, I can continue to test
Now, knowing that ::load works OK, I can continue to test
Win11 Pro 223H2 Gerrman