Alternative for self("file") if include is used

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
jupe
Posts: 3478
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Alternative for self("file") if include is used

Post by jupe »

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?

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

Post by admin »

Just to be sure, you want self("...") to return the name of the included file?

jupe
Posts: 3478
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Alternative for self("file") if include is used

Post by jupe »

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

Post by admin »

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....

jupe
Posts: 3478
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Alternative for self("file") if include is used

Post by jupe »

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

Post by admin »

Well, I think it should be doable (ontological and deontic)...

jupe
Posts: 3478
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Alternative for self("file") if include is used

Post by jupe »

That went over my head, but if you are happy to try, :D

jupe
Posts: 3478
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Alternative for self("file") if include is used

Post by jupe »

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

old.png
new.png

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?

Post by Filehero »

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.
includes.png
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:
Remaining debug code?
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%

Re: 18.70.0107: script includes broken?

Post by Filehero »


admin
Site Admin
Posts: 66719
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: 18.70.0107: script includes broken?

Post by admin »

See reply in the other thread...

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

Post by admin »

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). :eh: 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... :maf:

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

Post by admin »

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. :(

jupe
Posts: 3478
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Alternative for self("file") if include is used

Post by jupe »

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.

Post Reply