Alternative for self("file") if include is used
-
jupe
- Posts: 3478
- Joined: 20 Oct 2017 21:14
- Location: Win10 22H2 120dpi
Alternative for self("file") if include is used
Scripting related:
Does anyone know an alternative method of self("file") in the case of if I have a main script that uses include() to add to it then the included scripts return the main script when using self("file") I assume because it joins them all together before parsing or something similar, is there a way around this?
I was going to add the filename in a comments section at the top of the file before I dynamically create the child script, but then I still can't reference the file I am in to read it when I run it anyway, or can I?
And if I use a perm variable within an Initialize, each child item would be trying to set it simultaneously, so my thinking currently is having to use an ini file with menu index and filename, but that is not preferred, or alternatively not using include and writing main and child items in 1 file but that complicates things further, does anyone have any suggestions for me?
Does anyone know an alternative method of self("file") in the case of if I have a main script that uses include() to add to it then the included scripts return the main script when using self("file") I assume because it joins them all together before parsing or something similar, is there a way around this?
I was going to add the filename in a comments section at the top of the file before I dynamically create the child script, but then I still can't reference the file I am in to read it when I run it anyway, or can I?
And if I use a perm variable within an Initialize, each child item would be trying to set it simultaneously, so my thinking currently is having to use an ini file with menu index and filename, but that is not preferred, or alternatively not using include and writing main and child items in 1 file but that complicates things further, does anyone have any suggestions for me?
-
admin
- Site Admin
- Posts: 66719
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Alternative for self("file") if include is used
Just to be sure, you want self("...") to return the name of the included file?
FAQ | XY News RSS | XY X
-
jupe
- Posts: 3478
- Joined: 20 Oct 2017 21:14
- Location: Win10 22H2 120dpi
Re: Alternative for self("file") if include is used
Say Main.xys has an include child.xys, child2.xys etc, then from within child.xys I want to be able to reference the filename of Child.sys, which normally I would do with self(), but because it is called via an include from Main.xys that is what is returned, instead of Child.xys which would be, if it was called directly instead of via an include().
-
admin
- Site Admin
- Posts: 66719
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Alternative for self("file") if include is used
OK, makes sense. But I currently don't see an easy way for me to add that. As you assumed, the includes are really done right into the memory, and the source file is totally forgotten afterwards. I'll see what I can do....
FAQ | XY News RSS | XY X
-
jupe
- Posts: 3478
- Joined: 20 Oct 2017 21:14
- Location: Win10 22H2 120dpi
Re: Alternative for self("file") if include is used
Oh, I was just wondering if it could be done and I wasn't aware how, I didn't expect you to add it.
-
admin
- Site Admin
- Posts: 66719
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Alternative for self("file") if include is used
Well, I think it should be doable (ontological and deontic)...
FAQ | XY News RSS | XY X
-
jupe
- Posts: 3478
- Joined: 20 Oct 2017 21:14
- Location: Win10 22H2 120dpi
Re: Alternative for self("file") if include is used
That went over my head, but if you are happy to try, 
-
jupe
- Posts: 3478
- Joined: 20 Oct 2017 21:14
- Location: Win10 22H2 120dpi
Re: Alternative for self("file") if include is used
Wow just notice new beta release notes, thanks soooooo much for adding this, I have a slight problem though.
Both screenshots exact same script running in new beta and old .0103
Thanks again for adding this feature, I hope its not a hassle.
Both screenshots exact same script running in new beta and old .0103
Thanks again for adding this feature, I hope its not a hassle.
To see the attached files, you need to log into the forum.
-
Filehero
- Posts: 2734
- Joined: 27 Feb 2012 18:50
- Location: Windows 11@100%
18.70.0107: script includes broken?
Hi Don,
after updating to 18.70.0107 all my scripts with includes don't execute but simply display the header section of in memory assemblies. I suspect the cause is associated with
Remaining debug code?
after updating to 18.70.0107 all my scripts with includes don't execute but simply display the header section of in memory assemblies. I suspect the cause is associated with
Code: Select all
v18.70.0107 - 2018-02-27 17:24
+ SC self enhanced: Added switch to return the full path of the
included script file (if any) containing this command.
Syntax: self(info)
info:
inc = Full path of the included script file (if any) containing this
command.
Example:
echo self("inc"); //this line should be in included script file
Remarks:To see the attached files, you need to log into the forum.
-
Filehero
- Posts: 2734
- Joined: 27 Feb 2012 18:50
- Location: Windows 11@100%
-
admin
- Site Admin
- Posts: 66719
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
-
admin
- Site Admin
- Posts: 66719
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Alternative for self("file") if include is used
Hmmmm, tricky! ATM this looks like the end of that little feature. I don't see how to handle included multi-scripts (aka scripts that comes up as menus).
I can prevent them from appearing in the menu (as in your screenshot), but I cannot make them work as they should. I need to find a totally different approach... 
FAQ | XY News RSS | XY X
-
admin
- Site Admin
- Posts: 66719
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Alternative for self("file") if include is used
Sorry, jupe, but it looks like I have to remove it again. It was the wrong approach and I don't see another one at the moment. 
FAQ | XY News RSS | XY X
-
jupe
- Posts: 3478
- Joined: 20 Oct 2017 21:14
- Location: Win10 22H2 120dpi
Re: Alternative for self("file") if include is used
Ok, sorry, I hope it didn't waste too much of your time, thanks for trying though, I'll have to come up with another solution.
edit: I merged the topics, just to keep all the info together, and the regression is fixed anyway.
edit: I merged the topics, just to keep all the info together, and the regression is fixed anyway.
XYplorer Beta Club