Page 1 of 1

Option to auto-replace illegal chars on input dialogs

Posted: 20 May 2021 20:03
by 1024mb
There have been times where I've pasted some text that has illegal characters and I don't notice them or simply forget about them but upon clicking OK the script fails because I use that input as a filename and Windows doesn't accept certain chars.

Could you add an option so XYplorer auto replaces on paste the illegal characters or just don't accept them showing an error?

Re: Option to auto-replace illegal chars on input dialogs

Posted: 23 May 2021 18:36
by Delphine
What's an "illegal" character ?

Re: Option to auto-replace illegal chars on input dialogs

Posted: 23 May 2021 18:41
by Horst
And how should XY know what purpose your input has in advance ?
If you make such errors often you can add a routine to your scripts to make a check according to some rules.

Re: Option to auto-replace illegal chars on input dialogs

Posted: 23 May 2021 18:44
by 1024mb
Delphine wrote: 23 May 2021 18:36 What's an "illegal" character ?
In Windows are: ":", """ (quote), "?", "*", "\", "/", "<", ">" and "|" . Also you can't name "con", "com#" or "nul" any file or folder.
Horst wrote: 23 May 2021 18:41 And how should XY know what purpose your input has in advance ?
If you make such errors often you can add a routine to your scripts to make a check according to some rules.
I was thinking by implementing a name input dialog command or adding a param so we can set a dialog to be like that.

Re: Option to auto-replace illegal chars on input dialogs

Posted: 23 May 2021 19:48
by highend
You could just do it with a:

Code: Select all

    $input = '"a<>b|*c?d\e/f'; // You'd be using an input() here... 
    $input = regexreplace($input, "(^(con|com#|nul)$|[""?*\\/<>|])", "_");

Re: Option to auto-replace illegal chars on input dialogs

Posted: 23 May 2021 22:50
by 1024mb
highend wrote: 23 May 2021 19:48 You could just do it with a:

Code: Select all

    $input = '"a<>b|*c?d\e/f'; // You'd be using an input() here... 
    $input = regexreplace($input, "(^(con|com#|nul)$|[""?*\\/<>|])", "_");
I will try that, thank you!