Help with a Back Button

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Help with a Back Button

Post by SkyFrontier »

So I finally managed to produce a submenu... :roll:

Code: Select all

"_Initialize"
   unset $mn;
   perm $mn;
 step;
	$mn =<<<FOO
"1 - Icon Group 1"
   $a = <<<hdc
"autorefresh|:autorefresh" copytext ":autorefresh";
"back|:back" copytext ":back";
hdc;
 load ("$a", , s);
-
"2 - Icon Group 2"
   $b = <<<hdc
"go|:go" copytext ":go";
"goprev|:goprev" copytext ":goprev";
hdc;
 load ("$b", , s);
-
"3 - Icon Group 3"
   $c = <<<hdc
"zoomin|:zoomin" copytext ":zoomin";
"zoomout|:zoomout" copytext ":zoomout";
-
"back"
 step; load "$mn",* , 's'; unset $mn;
// self(script); text "$mn"; 
hdc;
 load ("$c", , s);
FOO;

 load "$mn",* , 's';

"_Terminate"
 unset "$mn";
Permanent var "$mn" is there but when I press the "back" item (currently present only on script 3), the LOAD command tries to run an empty variable, displaying as if it were load "",* , 's'; instead.
Why?
If I don't use sc perm, it correctly tries to run a "$mn" variable but without any usable value set.

____
thanks for the tip on load() on another thread, Don!
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

PeterH
Posts: 2826
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Help with a Back Button

Post by PeterH »

The first heredoc <<<FOO sets the variable $mn.

In this moment all variables inside the heredoc are resolved. This is especially true for the "$mn" near the end of this heredoc. And as $mn is empty in this moment it will disappear. (Replaced by an empty string.)

You have step instructions inside - so just use them: step until
$mn = <<<FOO ...
is executed, then click "Variables", and then doubleclick $mn :arrow: you will see what this very first heredoc has built.

This doesn't happen for $a etc, as these are local variables: if undefined they are replaced by their name, while $mn is defined (as perm) but empty and so is resolved by an empty string.

I hope this explanation is understandable?

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Help with a Back Button

Post by SkyFrontier »

Thanks, PeterH, I understood it. I tried to solve the $nm disappearance using the "Initialize" trick, as you can see, but as said, didn't completely got it yet (see http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=10275).

But: is there a solution for this?

Because I tried a series of approaches: load-based, sub-based, load+sub-based and other variations and none seems to be able to solve the problem, ie, load a menu of scripts each having a BACK entry to get back to the main menu containing each submenu. The only thing (besides using "load, , f") that worked was to run the script from the GUI - "Run Script..." and set "Load Script Again" as the BACK action. Which is cheating.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

totmad1
Posts: 131
Joined: 24 Jun 2013 12:37

Re: Help with a Back Button

Post by totmad1 »

I don't know if i have missed a point but doesn't the following code produce what
you are trying to achieve.

Code: Select all

"1 - Icon Group 1 :  dd ME"  Load("*","_ dd MD;-;_ dd A;_ dd B;") ;
"autorefresh|:autorefresh : _ dd A" copytext ":autorefresh";
"back|:back : _ dd B" copytext ":back";
-
"2 - Icon Group 2 :  ee ME"  Load("*","_ ee MD;-;_ ee A;_ ee B;") ;
"go|:go : _ ee A" copytext ":go";
"goprev|:goprev : _ ee B" copytext ":goprev";
-
"3 - Icon Group 3 :  ff ME"  Load("*","_ ff MD;-;_ ff A;_ ff B;_ ff C;_ ff D;") ;
"zoomin|:zoomin : _ ff A" copytext ":zoomin";
"zoomout|:zoomout : _ ff B" copytext ":zoomout";
"- : _ ff C"
"<- back |: ff |1 : _ ff MD"   Load("*");
     // step; load "$mn",* , 's'; unset $mn;
totmad1 (totally mad one)

klownboy
Posts: 4407
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: Help with a Back Button

Post by klownboy »

Hi SkyFrontier,
Submenus along with heredoc, others have been dabbling on this but not to this extent. Very nice script...with much potential use. After playing with your script for 2 hours this morning when I should be doing some work around the house, I finally came up with these modifications that seem to be working just fine. See what you think. It's probably not the way you wanted to resolve it, but it does work just fine.

Code: Select all

"_Initialize"
  perm $script = self(file);
   unset $mn;
   perm $mn =<<<FOO
"1 - Icon Group 1|:conf"
   $a = <<<hdc
"autorefresh|:autorefresh" copytext ":autorefresh";
"fore|:fore" copytext ":back";
-
"back|:back"
   load "$script";
hdc;
 load ("$a", , s);
-
"2 - Icon Group 2|:cofi"
   $b = <<<hdc
"go|:go" copytext ":go";
"goprev|:goprev" copytext ":goprev";
-
"back|:back"
   load "$script";
hdc;
 load ("$b", , s);
-
"3 - Icon Group 3|:cfi"
   $c = <<<hdc
"zoomin|:zoomin" copytext ":zoomin";
"zoomout|:zoomout" copytext ":zoomout";
-
"back to Main menu|:back"
   load "$script";
hdc;
 load ("$c", , s);
FOO;

 load "$mn",* , 's';
 end(1==1);
 
"_Terminate"
 unset $mn, $script;
Thanks for the nice script,
Ken

Edit: I noticed that if I clicked out of the menu when it first displayed, I received an error. I had to fix the end statements.
Last edited by klownboy on 15 Oct 2013 15:51, edited 2 times in total.

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Help with a Back Button

Post by SkyFrontier »

Hello, Ken!
Thanks for your time playing with it. Worked on it (ie, the many many many concepts until I came up with a half-solution) always feeling I was near something. For instance, if sc self could refer to the whole script, not the 'local' version of it (ie, the last called "sub" script), problem solved.

Your version seems to have the answer, too. But I'm just getting a

Code: Select all

Command 'load' called with empty 'resource' argument.
load

_Initialize
error message when pushing BACK. Since perm $script = self(file);, that's a potential problem as I'm trying to play with file-less menus. Setting self() to deal with script breaks the main menu completely.

-am I doing something wrong with your version? Is there a special setting you forgot to mention?
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Help with a Back Button

Post by SkyFrontier »

HEY!!!
Wait a minute!
totmad1 produced something I almost missed.
Yes, test run said it's true, I can have a working back to main menu item!
Will play with it a bit more and be back with a definitive answer after studying the code.
Thanks a bunch, totmad1 and Ken (form whom I'd like to have an answer too, as I need to fully understand why his code doesn't worked here)!

edit: no, it's not what I want as each Icon Group must have a Back item.
=\
edit 2: it seems that with some work I got a positive answer from script. Yes, I have to study it more...

Code: Select all

"1 - Icon Group 1 :  dd ME"  Load("*","_ dd MD;-;_ dd A;_ dd B;") ;
"autorefresh|:autorefresh : _ dd A" copytext ":autorefresh";
"back|:back : _ dd B" copytext ":back";
"- : _ ff C"
"<- back |: ff |1 : _ dd MD"   Load("*");
-
"2 - Icon Group 2 :  ee ME"  Load("*","_ ee MD;-;_ ee A;_ ee B;") ;
"go|:go : _ ee A" copytext ":go";
"goprev|:goprev : _ ee B" copytext ":goprev";
"- : _ ff C"
"<- back |: ff |1 : _ ee MD"   Load("*");
-
"3 - Icon Group 3 :  ff ME"  Load("*","_ ff MD;-;_ ff A;_ ff B;_ ff C;_ ff D;") ;
"zoomin|:zoomin : _ ff A" copytext ":zoomin";
"zoomout|:zoomout : _ ff B" copytext ":zoomout";
"- : _ ff C"
"<- back |: ff |1 : _ ff MD"   Load("*");
     // step; load "$mn",* , 's'; unset $mn;
quick test seems to prove it works as expected.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

totmad1
Posts: 131
Joined: 24 Jun 2013 12:37

Re: Help with a Back Button

Post by totmad1 »

A little help may be needed .
I placed

Code: Select all

"- : _ ff C"
in the script as was only way to get a seperater.
You do have to change the "ff" part to suit each group i.e group 1 has "dd".
HTH
totmad1 (totally mad one)

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Help with a Back Button

Post by SkyFrontier »

Biggest problem with totmad1's approach: each and every menu item *have* to have its own label/index.
The sandbox I'm playing with is, as you can see, a 103 icon codes for XY scripting.

Ideal usage is a dynamic menu producer which, as far as I can conceive, won't work because XY scripting is (currently, I hope?) unable to set variables in a dynamic manner (lack of this broke some solutions I needed to write in the past).
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

klownboy
Posts: 4407
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.7171 at 100% 2560x1440

Re: Help with a Back Button

Post by klownboy »

Odd, that it's not working for you. I again copied what I put in the code box above, made a new script file and assigned it to a CTB and I also ran it from "load script file" and the address bar and all methods ran without errors when hitting the "back" function. Unless there's some tweak I'm using that you are not. The only one I can think of is "ScriptRecursionWarningOff=1" but you're not getting that error and the other is saving permanent variables "on" of course. Yes, totmad's version works fine for me as well, but of course it's using a different methods, strickly load not heredoc.

By the way are you using the latest version of XY? At one time I know you were hanging on to an older version. I ask only because the "perm $script = self(file);" line could be an issue being all on one line if you are using an older version...you might have to use: "perm $script; $script = self(file);" instead. I took your steps out so turn stepping on to see if the variable is assigned as it should.
Last edited by klownboy on 14 Oct 2013 19:05, edited 2 times in total.

totmad1
Posts: 131
Joined: 24 Jun 2013 12:37

Re: Help with a Back Button

Post by totmad1 »

Have you had a look at my MenuProducer http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=10077
totmad1 (totally mad one)

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Help with a Back Button

Post by SkyFrontier »

totmad1 wrote:Have you had a look at my MenuProducer http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=10077
There *must* be an easier way to do this, totmad1.

I'm trying to stay on a road where the user just need to pick a basic template (or a simple concept) and copy+paste whatever he wants in terms of preexistent scripts. That's why I preferred heredoc over script indexes (load-based approach), for instance.

Concerning the MenuProducer: well, the name itself makes my eyes shine but it seems I will have to read the entire thread plus instructions on zip file. Seeing ".xys" among the first lines make me nervous... lol

Please consider joining the quest for the menu grail... :wink:
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Help with a Back Button

Post by SkyFrontier »

Hello, Ken.
Yes, I see the script works when using it in the form of a file. But as I said in a previous post,
The only thing (besides using "load, , f") that worked...
I try to keep my installations as sharp as possible so I can port them to anywhere I need without any hassles. That means the number of associated files required to run my custom XYplorer installments either. I have to deal with literally tens of scripts each day and that means I have to search for them using external or Windows built-in search tools. As they tend to share similar names for general operations used in specific contexts, ie, versioning hell, I have to keep strict control over them. The less files I have, the faster I work.

As you saw, the potential is huge - particularly as I'm considering this as a way to consolidate several scripts under project-specific main menus. See...?
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

totmad1
Posts: 131
Joined: 24 Jun 2013 12:37

Re: Help with a Back Button

Post by totmad1 »

Hi SkyFrontier
read your last two posts,which got me thinking.
I produced this
http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=10286
and while writing the code came across a problem of "parsing" code which
I didn't want "parsing" and found only way was using a "text" file.
If you take the logic further .... An ini file could be set up to produce
scripts/lets to be called as and when required.
Just a thought.
totmad1 (totally mad one)

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Help with a Back Button

Post by SkyFrontier »

http://www.xyplorer.com/xyfc/viewtopic.php?f=3&t=5715
Something like File-Based Favorites, you mean, but for scripts?

I already work like that with a cool multi-entries script, which also auto-adds selected files and folders, auto-captioning and properly coding and icon-setting according to the type of selected item. In that project I went stuck in the same basic problem: go back to the main menu (although now I see how to solve it).

The key here is to have a functional back-and-forth multi-menu, no files dependent solution. Or have I misunderstood your post...?
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

Post Reply