Error 93

Things you’d like to miss in the future...
Post Reply
zakhar
Posts: 148
Joined: 08 Sep 2010 21:13

Error 93

Post 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!";}
 }
 
Attachments
f.jpg
f.jpg (75.39 KiB) Viewed 626 times

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

Re: Error 93

Post by admin »

Cannot reproduce. It probably depends on the current path. Does it contain any brackets? ([,])

zakhar
Posts: 148
Joined: 08 Sep 2010 21:13

Re: Error 93

Post 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.

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

Re: Error 93

Post by admin »

Can you give me a full path?

zakhar
Posts: 148
Joined: 08 Sep 2010 21:13

Re: Error 93

Post 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
.

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

Re: Error 93

Post 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.

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

Re: Error 93

Post 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]);

zakhar
Posts: 148
Joined: 08 Sep 2010 21:13

Re: Error 93

Post 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.)

Post Reply