Page 1 of 1
scripting wish for future
Posted: 30 Jul 2008 15:43
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.
Re: scripting wish for future
Posted: 31 Jul 2008 17:45
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.
Posted: 31 Jul 2008 19:01
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...
Posted: 31 Jul 2008 19:22
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...
Posted: 01 Aug 2008 07:37
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/

Posted: 01 Aug 2008 13:54
by jacky
Yeah, of course if you don't want to wait there's always that

Posted: 01 Aug 2008 20:23
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?
Posted: 03 Aug 2008 22:10
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>";
Posted: 04 Aug 2008 00:53
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.