Page 1 of 1

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

Posted: 26 Feb 2018 11:48
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?

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

Posted: 26 Feb 2018 12:01
by admin
Just to be sure, you want self("...") to return the name of the included file?

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

Posted: 26 Feb 2018 12:05
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().

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

Posted: 26 Feb 2018 12:10
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....

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

Posted: 26 Feb 2018 12:14
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.

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

Posted: 26 Feb 2018 12:55
by admin
Well, I think it should be doable (ontological and deontic)...

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

Posted: 26 Feb 2018 13:26
by jupe
That went over my head, but if you are happy to try, :D

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

Posted: 27 Feb 2018 18:25
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.

18.70.0107: script includes broken?

Posted: 27 Feb 2018 20:37
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?

Re: 18.70.0107: script includes broken?

Posted: 27 Feb 2018 20:39
by Filehero

Re: 18.70.0107: script includes broken?

Posted: 27 Feb 2018 20:57
by admin
See reply in the other thread...

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

Posted: 27 Feb 2018 21:00
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:

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

Posted: 27 Feb 2018 21:09
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. :(

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

Posted: 28 Feb 2018 05:17
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.