Page 1 of 1

Error 93

Posted: 22 Nov 2021 05:28
by zakhar
Hello, dear XYplorer Community!

This simple script causes an error 93:

Code: Select all

"Up"
 global $sign;
 $sign = "-";
 folders();
 
 function folders(){
     $folder_ud = "";
     global $sign;
     $current_folder = <curpath>;
     $parent_folder = getpathcomponent($current_folder,"path");
     $qs1 = quicksearch("/dn","$parent_folder");
     $current_folder_index = gettokenindex($current_folder,$qs1,<crlf>);
     if($sign == "-"){$folder_ud = $current_folder_index - 1;}
     $folder_ud = gettoken($qs1,$folder_ud,<crlf>);
     if($folder_ud != ""){goto "$folder_ud";}
     else {echo "No more folders exists!";}
 }
 

Re: Error 93

Posted: 22 Nov 2021 09:52
by admin
Cannot reproduce. It probably depends on the current path. Does it contain any brackets? ([,])

Re: Error 93

Posted: 22 Nov 2021 15:09
by zakhar
admin wrote: 22 Nov 2021 09:52 Does it contain any brackets? ([,])
Yes, the last folders sometimes contain the sequences like ..."=[" ... "]="... .
The error occurs directly on such folder names.

Re: Error 93

Posted: 22 Nov 2021 16:15
by admin
Can you give me a full path?

Re: Error 93

Posted: 22 Nov 2021 17:33
by zakhar
Yes.
The above mentioned script allows moving upwards between folders.
Adding modules

Code: Select all

"Down"
 global $sign;
 $sign = "+";
 folders();
and in the function

Code: Select all

if($sign == "+"){$folder_ud = $current_folder_index + 1;}
gives a possibility to move downwards inside folders.

The following is a simple random reconstruction of folder area.
C:\Personal\Wallet\Accounts\2021\023-38716871
C:\Personal\Wallet\Accounts\2021\024-38716871-=[restricted-a]=
C:\Personal\Wallet\Accounts\2021\025-38716871-e.-20.11.21
C:\Personal\Wallet\Accounts\2021\026-38716871
C:\Personal\Wallet\Accounts\2021\027-38716871

Go into the folder
C:\Personal\Wallet\Accounts\2021\023-38716871
and go down (using the above mentioned script) - you will not be able to pass the folder
C:\Personal\Wallet\Accounts\2021\024-38716871-=[restricted-a]=
.
Go into the folder
C:\Personal\Wallet\Accounts\2021\024-38716871-=[restricted-a]=
and try to go downwards or upwards and you will receive error immediately - .

Go into the folder
C:\Personal\Wallet\Accounts\2021\025-38716871-e.-20.11.21
and go upwards - you will not be able to pass the folder
C:\Personal\Wallet\Accounts\2021\024-38716871-=[restricted-a]=
.

Now change "=[restricted-a]=" to "=[restricted]=" and go up - the behavior changes:
the folder
C:\Personal\Wallet\Accounts\2021\024-38716871-=[restricted-a]=
will be changed directly to
C:\Personal\Wallet\Accounts\2021\027-38716871 - (to the last folder)
.
If you go down, then you will change to
C:\Personal\Wallet\Accounts\2021\023-38716871
.

Re: Error 93

Posted: 23 Nov 2021 10:18
by admin
if you call gettokenindex like this the switches default to "iw" where "w" means the string is a wildcard pattern:

Code: Select all

$current_folder_index = gettokenindex($current_folder,$qs1,<crlf>);
But your strings are not meant to be wildcard patterns and they happen to be invalid patterns, hence the error.

The fix is to explicitly pass the switches parameter without "w", for example like this:

Code: Select all

$current_folder_index = gettokenindex($current_folder,$qs1,<crlf>,"");
BTW, I now find it stupid that switches defaults to "iw". :blackstorm: But it will break old user code if I change it.

Re: Error 93

Posted: 23 Nov 2021 10:47
by admin
admin wrote: 23 Nov 2021 10:18 BTW, I now find it stupid that switches defaults to "iw". :blackstorm: But it will break old user code if I change it.
In fact, if I think about it, I'd say it's a bug. Are there any objections to a fix?

Code: Select all

OLD: gettokenindex(token, tokenlist, [separator=|], [switches="iw"]);
NEW: gettokenindex(token, tokenlist, [separator=|], [switches]);

Re: Error 93

Posted: 23 Nov 2021 14:40
by zakhar
Thank you for this (adding "" into the gettokenindex code) quick help! My script works now! :kidding:

(I would not (if I am being asked about this) qualify this as a bug,
because the solution (using of an available option) does not require programming.
I have no objections against intended changes. It is important to know, that something can be changed in the future.)