Validating scripting command

Features wanted...
ugus
Posts: 211
Joined: 02 Jun 2006 16:42

Validating scripting command

Post by ugus »

Could you add a special kind of <#Command> used only for scripting
that easily eliminates this kind of disaster...

by validating a folder.
- Go to the Temporary Internet Files folder
- Select All
- Delete (Skip Locked)
!!! However, here comes a serious WARNING!!! Scripting is an
advanced hardcore feature, and the above example is a good one to
show you why. If the Temp folder cannot be shown (e.g., because
you opted to not show hidden items), then the script will happily
go on with the next commands (select all and delete) IN THE FOLDER
YOU END UP IN *instead* of the Temp folder!
Example

::#559::<#CommandValidateFolderCommand>#250::#171

Description:

Execute the next parts of the command (#250::#171)only
if the ::#559 [Go to the Temporary Internet Files folder] was successful
(eg the Temporary Internet Files folder was displayed/validated)

The command should look for the previous command and only allow execution of the next
scripting command if the previous command was a "folder command" or a "Go to UDC" command.

There are maybe need for more types of "validate" commands but this could be a start?

I realize that this maybe is complicated...

j_c_hallgren
XY Blog Master
Posts: 5826
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Post by j_c_hallgren »

Maybe this could be handled by a plain true/false or good/bad result code from each command that could be tested, if desired, by a new command which would, if prior result was false, stop the script execution at that point with a pop-up (as one gets with script errors on HTML pages in IE) and ask user go/quit? Something like #TEST or similar...

If one wanted to ignore any/all errors, you'd just not have any #TEST...however, if you wanted to test each/every one, maybe if that was the very first command, then it'd be a shortcut to that functionality.
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

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

Re: Validating scripting command

Post by jacky »

ugus wrote:::#559::<#CommandValidateFolderCommand>#250::#171
Sounds a bit complicated/too much to me; but I think there should be some kind of, even minimal, error support. As in, if a command failed (eg. path/file not found, etc), then the user should probably be informed & asked whether or not to continue.

And for hardcore, fearless users, much like there's a "step" there could be a "nowarning" or something like that, to have the script go all the way regardless of any errors that may occur...
Proud XYplorer Fanatic

ugus
Posts: 211
Joined: 02 Jun 2006 16:42

Post by ugus »

j_c_hallgren wrote:Maybe this could be handled by a plain true/false or good/bad result code from each command that could be tested, if desired, by a new command which would, if prior result was false, stop the script execution at that point with a pop-up (as one gets with script errors on HTML pages in IE) and ask user go/quit? Something like #TEST or similar...
Yes, this sounds like a reasonable idea. It should be easy to use but still powerful. Let see what Don has for ideas for this 8)

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

Post by admin »

ugus wrote:
j_c_hallgren wrote:Maybe this could be handled by a plain true/false or good/bad result code from each command that could be tested, if desired, by a new command which would, if prior result was false, stop the script execution at that point with a pop-up (as one gets with script errors on HTML pages in IE) and ask user go/quit? Something like #TEST or similar...
Yes, this sounds like a reasonable idea. It should be easy to use but still powerful. Let see what Don has for ideas for this 8)
Scripting is not for cowards! :P

While your (meaning all folks in this thread) ideas seem logic, they are not suitable in the real world of programming. While some functions have a clear good/bad result, most others have not (countless error codes exist, errors are raised and handled, many are meaningless/irrelevant for the user, other have more meaning up to a LOT of meaning... :wink: ). If a function failed or not is dependent on what the user intended to do, and that's a pragmatic notion far beyond the realm of thinking machines...

IOW: maybe you better do your radical deletion jobs manually, or at least stepwise... :wink: (note that I provided a way to turn stepping off and on very quickly! So you can step only in the dangerous parts of a script.

Other idea: I could add a "stop" (or "step") flag right into the script commands, like:
::#1234::#2345 stop::#3456

This would stop before function #2345 is executed, and prompt the user whether to go on or abort.

j_c_hallgren
XY Blog Master
Posts: 5826
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Post by j_c_hallgren »

Ok... :oops: I kinda figured we were making it too simple...hey, it was worth a shot! So...instead of STOP, I'd suggest PAUSE or DELAY instead, as stop to me implies more of an ending where pause is just that...and maybe the Pause could have an optional parm with nbr of seconds max to wait before it goes ahead by itself? My CoreFTP does this, so I have chance to change/cancel each file transfer or let it go on without keyboard/mouse interaction.
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

ugus
Posts: 211
Joined: 02 Jun 2006 16:42

Post by ugus »

admin wrote: Other idea: I could add a "stop" (or "step") flag right into the script commands, like:
::#1234::#2345 stop::#3456

This would stop before function #2345 is executed, and prompt the user whether to go on or abort.
That would be a nice idea. Then you have a possibility to add some "safety" checks if your feel unsafe :wink: :P

Some more "system functions" could be added as well like the Sleep function The Qwerty mentioned in another thread, in order to make the script more responsive.

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

Post by admin »

ugus wrote:
admin wrote: Other idea: I could add a "stop" (or "step") flag right into the script commands, like:
::#1234::#2345 stop::#3456

This would stop before function #2345 is executed, and prompt the user whether to go on or abort.
That would be a nice idea. Then you have a possibility to add some "safety" checks if your feel unsafe :wink: :P

Some more "system functions" could be added as well like the Sleep function The Qwerty mentioned in another thread, in order to make the script more responsive.
But I will only add this when I'm 100% sure about the general scripting syntax. I mean real scripting, not calling by numbers... currently I'm about 90% sure...

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

Post by jacky »

admin wrote:While your (meaning all folks in this thread) ideas seem logic, they are not suitable in the real world of programming. While some functions have a clear good/bad result, most others have not (countless error codes exist, errors are raised and handled, many are meaningless/irrelevant for the user, other have more meaning up to a LOT of meaning... :wink: ). If a function failed or not is dependent on what the user intended to do, and that's a pragmatic notion far beyond the realm of thinking machines...
I'm not sure that's entirely true. I mean, for a Go To command, if the path doesn't exists, that's a failure to me, it couldn't be any other way.
If the application to use for an Open (With) isn't found, it's pretty much the same.
Which is probably why, by the way, those do already have XY to show an error message. So, while in scripting, turning the "Ok" button to a "Ok/Cancel" combo might not sound like such a "bad idea" I would say.

Now talking about a Rename command that didn't actually rename any items, that maybe normal yes. But not renaming a file cause the actual system call to rename the file failed, that's an error. Always. (I would think.)
admin wrote:Other idea: I could add a "stop" (or "step") flag right into the script commands, like:
::#1234::#2345 stop::#3456

This would stop before function #2345 is executed, and prompt the user whether to go on or abort.
Sounds quite weird to me. I would have assume it would stopped after the command #2345, given how we read first #2345, and then "stop"... :roll:
Proud XYplorer Fanatic

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

Post by admin »

jacky wrote:
admin wrote:Other idea: I could add a "stop" (or "step") flag right into the script commands, like:
::#1234::#2345 stop::#3456

This would stop before function #2345 is executed, and prompt the user whether to go on or abort.
Sounds quite weird to me. I would have assume it would stopped after the command #2345, given how we read first #2345, and then "stop"... :roll:
It's only weird for those who don't know the rules of XY scripting syntax. Which are all but me! :P

Patience...

I'm currently experiencing a kind of overflow situation here... plus I caught a cold and am coughing all the time into my keyboard... so my magical powers are slightly dimished... patience...

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Post by serendipity »

admin wrote:... plus I caught a cold and am coughing all the time into my keyboard... so my magical powers are slightly dimished... patience...
Gesundheit!

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

Post by admin »

serendipity wrote:
admin wrote:... plus I caught a cold and am coughing all the time into my keyboard... so my magical powers are slightly dimished... patience...
Gesundheit!
Danke!

ugus
Posts: 211
Joined: 02 Jun 2006 16:42

Post by ugus »

admin wrote:But I will only add this when I'm 100% sure about the general scripting syntax. I mean real scripting, not calling by numbers... currently I'm about 90% sure...
I realize that implementing full-fledged scripting is a really complex task and it will take some time to complete.

It is however already now as in it's current state, a real brilliant start! - so take some rest and recover your batteries... :)

j_c_hallgren
XY Blog Master
Posts: 5826
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Post by j_c_hallgren »

ugus wrote:I realize that implementing full-fledged scripting is a really complex task and it will take some time to complete.

It is however already now as in it's current state, a real brilliant start! - so take some rest and recover your batteries... :)
I fully agree with these sentiments! And I think that by our interaction here, as we've done today, helps make the result even that much better, if I do say so myself...Don is brilliant, but sometimes even geniuses need a push in another direction that they had'nt considered.
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

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

Post by admin »

jacky wrote:
admin wrote:Other idea: I could add a "stop" (or "step") flag right into the script commands, like:
::#1234::#2345 stop::#3456

This would stop before function #2345 is executed, and prompt the user whether to go on or abort.
Sounds quite weird to me. I would have assume it would stopped after the command #2345, given how we read first #2345, and then "stop"... :roll:
Found a better way:

Code: Select all

    + Scripting: Now you can force stepping (prompting) per command. 
      Simply prefix a ? to the command. For example, the following 
      script will goto Desktop (and remove any Visual Filters), and then 
      prompt you before executing the sortby command:
        ::goto Desktop|::?sortby m, d
      Works as well with ID-based scripts:
        ::?#1016::?#101
Upload soon...

Post Reply