scripting wish for future

Discuss and share scripts and script files...
Post Reply
graham
Posts: 457
Joined: 24 Aug 2007 22:08
Location: Isle of Man

scripting wish for future

Post by graham »

you mentioned before that scripting might have ability to branch or jump within a script so, added to this, I would like for sel command to have a parameter that branches if the selection was false.

Code: Select all

sel [position/pattern], [count], [label]
so if a sel command fails then one can jump to a label within the script and thereby miss out some of the script commands.

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

Re: scripting wish for future

Post by admin »

graham wrote:you mentioned before that scripting might have ability to branch or jump within a script so, added to this, I would like for sel command to have a parameter that branches if the selection was false.

Code: Select all

sel [position/pattern], [count], [label]
so if a sel command fails then one can jump to a label within the script and thereby miss out some of the script commands.
Yes, goto/labels will be part of S2.

PeterH
Posts: 2785
Joined: 21 Nov 2005 20:39
Location: Germany

Post by PeterH »

...but I think, instead of providing something like error-labels on commands, it would be better if commands set a returncode. You can test it and branch where you want.
And, for example, if a cmd sets different RCs for (e.g.) AllDone, SomeDone, NothingDone, ParmError, FileNotFound, ..., you could select what to react on. Else you had to specify 10 error-labels for one command...

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

PeterH wrote:...but I think, instead of providing something like error-labels on commands, it would be better if commands set a returncode. You can test it and branch where you want.
And, for example, if a cmd sets different RCs for (e.g.) AllDone, SomeDone, NothingDone, ParmError, FileNotFound, ..., you could select what to react on. Else you had to specify 10 error-labels for one command...
Well, it's already been said that Don had functions in mind, so so commands could be turned into functions easily, and with conditions it will all be up to us/the script...
Proud XYplorer Fanatic

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

Post by admin »

jacky wrote:
PeterH wrote:...but I think, instead of providing something like error-labels on commands, it would be better if commands set a returncode. You can test it and branch where you want.
And, for example, if a cmd sets different RCs for (e.g.) AllDone, SomeDone, NothingDone, ParmError, FileNotFound, ..., you could select what to react on. Else you had to specify 10 error-labels for one command...
Well, it's already been said that Don had functions in mind, so so commands could be turned into functions easily, and with conditions it will all be up to us/the script...
Of course, there's also this possibility:
http://88.191.26.34/computers_are_fun/2 ... g-further/

:wink:

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

admin wrote:Of course, there's also this possibility:
http://88.191.26.34/computers_are_fun/2 ... g-further/

:wink:
Yeah, of course if you don't want to wait there's always that ;)
Proud XYplorer Fanatic

graham
Posts: 457
Joined: 24 Aug 2007 22:08
Location: Isle of Man

Post by graham »

Bloody Hell! Very clever, but too clever for me - Regexp illiterate! Full marks for ingenuity though

All I want is a simple addition to scripting either a return condition top act on or a pre-determined action IN scripting and a test condition with a goto label.

Roll on scripting 2 but when?

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

graham wrote:Bloody Hell! Very clever, but too clever for me - Regexp illiterate!
Not sure what you need to do exactly, but adapting a little the example given there, you can do this :

Code: Select all

"Example"
 // script begins here...
 // select next text file on List
 sel "[*.txt]";
 // now we check if it worked or not
 regexreplace $next, <curname>, "^$", "_noItem";
 regexreplace $next, $next, "^((?!_noItem).)*$", "_Item";
 sub $next;

"_noItem"
 // script continues here when sel "failed" (no file selected)
 msg "Selection failed !";

"_Item"
 // script continues here when a file was/is selected
 msg "Selection success : <curname>";
Proud XYplorer Fanatic

graham
Posts: 457
Joined: 24 Aug 2007 22:08
Location: Isle of Man

Post by graham »

Thank you Jacky for your code,

I now have incorporated the regexp you supplied, modified to fit and it all works as I intended.

I don't have the need in my file management to get to understand regexp in detail but it is clearly very powerful. I do think that XY scripting, however, can offer many uses, even for me, and with scripting 2 it will be even more useful (whatever scripting 2 is!).

Imo, the future success of XY is with its own built in scripting ability together with ease of use. Don has a wondefful ability to present new features which can readily be understood and used, especially for casual users. In the short time I have been in this forum XY has changed significantly.

In truth, I am just impatient for scripting 2 but every day brings some new gem and that is the great thing about XY.

Post Reply