Page 1 of 2
How to Check Both Panes for Existing Files?
Posted: 09 Nov 2010 21:18
by SkyFrontier
Can someone tell me how can I check if a file (<curbase>) is present on both panes and:
-if YES, proceed execution of script;
-if NO, stop script.
Thanks!
Re: How to Check Both Panes for Existing Files?
Posted: 09 Nov 2010 22:12
by serendipity
SkyFrontier wrote:Can someone tell me how can I check if a file (<curbase>) is present on both panes and:
-if YES, proceed execution of script;
-if NO, stop script.
Thanks!
HINT:
From help:
Code: Select all
exists()
Checks whether a file or directory exists.
Syntax
exists(item)
item: Full path (local or UNC) to a file system item.
return: 0 = does not exist
1 = exists (file)
2 = exists (folder; drive; share; server)
Examples
echo exists("C:\autoexec.bat"); //1
echo exists("C:"); //2
echo exists("C:\"); //2
echo exists("C:\Windows"); //2
echo exists("C:\Windows\"); //2
echo exists("C:\*.bat"); //0 - wildcards are NOT recognized
Combine this with get "Item", [pane] and use IF.
Re: How to Check Both Panes for Existing Files?
Posted: 09 Nov 2010 22:27
by SkyFrontier
IF only I knew it...
Thanks anyway, Serendipity!
-bug on forum engine: when trying to bold IF, it put the /b at the end of the whole sentence...

Re: How to Check Both Panes for Existing Files?
Posted: 12 Nov 2010 02:54
by SkyFrontier
@Serendipity:
I don't understand.
Here I posted a working version of an
if/elseif/else-based script (is it bugged, perhaps...? Can't see nothing special).
But I'm yet to find a way to get this working on a much more simple stuff.
Here are some excerpts of code (enough to try and get results - not a single one working as intended, "
a==a" >
msg 1, "
a==b" >
msg 2.
Code: Select all
$b = "<curname>";
focus("pi");
focus;
selfilter "$b";
// $check = exists("$b");
if (Exists("$b")==0) { echo "hi!"; };
// elseif ($check = 0) { echo "hi!"; }
else (Exists("$b")==1) { echo "Sorry - try again"; };
-------------
$b = "<curname>";
focus("pi");
focus;
$x = selfilter "$b";
// $y = exists("$x");
if ("$x"=="$b") {
echo "hi!"
}
else {
end ("$x"!="$b"), "Sorry - try again!";
}
--------------
$b = "<curname>";
focus("pi");
focus;
$x = selfilter "$b";
// $y = exists("$x");
if ("$x"=="$b") {
echo "hi!"
}
else {
end ("$x"!="$b"), "Sorry - try again!";
}
// else {
// end ($x =0), "Sorry - try again!";
// }
--------------
$b = "<curname>";
focus("pi");
focus;
$x = selfilter "$b";
// $y = exists("$x");
if (Exists("$x")==0) { echo "hi!"; };
// elseif ($check = 0) { echo "hi!"; }
else (Exists("$x")==1) { echo "Sorry - try again!"; };
Worst part is - all of this makes sense to me...

Re: How to Check Both Panes for Existing Files?
Posted: 12 Nov 2010 08:19
by admin
SkyFrontier wrote:Can someone tell me how can I check if a file (<curbase>) is present on both panes and: ...
I think you want listpane(), not exists() for this job...
Re: How to Check Both Panes for Existing Files?
Posted: 12 Nov 2010 11:20
by SkyFrontier
admin wrote:SkyFrontier wrote:Can someone tell me how can I check if a file (<curbase>) is present on both panes and: ...
I think you want listpane(), not exists() for this job...
...there we go again... >sigh<
Thanks for the tip, Don! Hope that way I finally understand
if/else/elseif... or perhaps is just the use of the improper command that was preventing the script to work.
Re: How to Check Both Panes for Existing Files?
Posted: 12 Nov 2010 13:07
by SkyFrontier
...am I doing something absurdly stupid enough for this to
work or is it really working after all?!
Code: Select all
end (<xyver> < "9.70.0009"), "Sorry - this script requires XYplorer version 9.70.0009 or higher.<crlf>Click 'Ok' to exit.";
$b = "<curname>";
focus("pi");
focus;
$c = listpane(, "$b", 1 + 8);
if (Exists("$c")==1) { echo "hi!"; };
else (Exists("$c")==0) { echo "Sorry - try again"; };
-is there a way to force it to work with <curbase> and NOT <curname>? Maybe fooling the system using the flag
2: NoFiles (= return only folders)? Is that safe?
>thank you!!!
EDIT: Reference:
Code: Select all
v9.70.0009 - 2010-11-12 12:30
* SCs listfolder and listpane enhanced. Added flag to force the
pattern to be an exact match, i.e. to suppress auto-adding of
wildcards when no wildcards are contained in the pattern (aka
"loose match").
flags: (binary field)
0: return folders and files with full paths [default]
1: NoFolders (= return only files)
2: NoFiles (= return only folders)
4: NoPaths (= return the filenames without paths)
8: NoAutoWildcards (= allow exact matches)
Example:
//list all folders that are named "code" in active pane
::inputselect("Test", listpane(, "code", 2 + 8));
EDIT 2: Added compatibility check code.
Re: How to Check Both Panes for Existing Files?
Posted: 12 Nov 2010 14:33
by admin
Please define "is present on both panes" and "exists". I think you are mixing categories.
Re: How to Check Both Panes for Existing Files?
Posted: 12 Nov 2010 14:51
by SkyFrontier
A certain script (working on it - it performs perfectly, but it
NEEDS this as an error handling method) requires to check if <
curbase> is present on the opposite pane so it can continue. <
curname> was used to deal with the existence of a same named file on both panes (solved with the
list* implementation, but this script must also work if both panes has a same <
curbase> named files.
Sorry, I really can't tell the conceptual difference among "present on both panes" and "exists" - except that "exists" has a crucial role to check whether a file is present on the other pane or not.
Code: Select all
Pane 1:
text.diz
Pane 2:
text.diz = script must apply to this file!
text.txt = to this file, too - even if "text.diz" is not present!
text for test.diz = ...and ignore this - if no "text.[b]ext[/b]" is found, stop script.
Thanks!
---
Reference:
Code: Select all
v7.90.0264 - 2009-05-13 13:04
+ Scripting got a new function.
Name: exists
Action: Checks whether a file or directory exists.
Syntax: exists(item)
item: full path (local or UNC) to a file system item.
return: 0 = does not exist
1 = exists (file)
2 = exists (folder; drive; share; server)
Examples:
::echo exists("C:\*.bat"); //0 - wildcards are NOT recognized
::echo exists("C:\autoexec.bat"); //1
::echo exists("C:"); //2
::echo exists("C:\"); //2
::echo exists("C:\Windows"); //2
::echo exists("C:\Windows\"); //2
Remarks:
The API function used to determine the existence and nature of
the item is inherently tolerant with trailing spaces, and it
resolves relative syntax (\..\.. etc) before doing the check.
This was not my choice but there's no way to turn it off.
Some of those special cases:
::echo exists("C:\autoexec.bat "); //1
::echo exists("C:\autoexec.bat\.."); //2 (!)
::echo exists("XYplorer.exe"); //1 (!)
::echo exists("appdata"); //2 (!) - if folder "appdata" is below
the current path (= xypath)
Re: How to Check Both Panes for Existing Files?
Posted: 12 Nov 2010 14:56
by admin
Note that "present on a pane" and "exists" are different things. I cannot help you until you make up your mind about what you want.

Re: How to Check Both Panes for Existing Files?
Posted: 12 Nov 2010 14:59
by SkyFrontier
admin wrote:Note that "present on a pane" and "exists" are different things. I cannot help you until you make up your mind about what you want.

...so I assume my description of the *real* problem wasn't of any help, right?
Re: How to Check Both Panes for Existing Files?
Posted: 12 Nov 2010 15:03
by admin
SkyFrontier wrote:admin wrote:Note that "present on a pane" and "exists" are different things. I cannot help you until you make up your mind about what you want.

...so I assume my description of the *real* problem wasn't of any help, right?
Well, no. I have no time to follow this.
This is all can give oyu now:
present on a pane -> listpane()
exsts in file system -> exists()
Re: How to Check Both Panes for Existing Files?
Posted: 12 Nov 2010 15:09
by SkyFrontier
Thank you, Don.
Posted the script
here in case anyone is interested in the actual usage I have in mind for this.
Re: How to Check Both Panes for Existing Files?
Posted: 13 Nov 2010 15:21
by SkyFrontier
Can someone please help me getting this to work?
Problem is with
elseif syntax at the
exists part.
Scenario: launch script with pane 2 active. Pane 1 must have something like: unins001.txt, unins000.diz; pane 2 must have: unins000.txt.
Expected result:
echo "hi! IT WORKS!";
Code: Select all
end (<xyver> < "9.70.0009"), "Sorry - this script requires XYplorer version 9.70.0009 or higher.<crlf>Click 'Ok' to exit.";
$b = "<curname>";
focus("pi");
focus;
$c = listpane(, "$b", 1 + 8);
if (Exists("$c")==1) { echo "hi!"; };
elseif ($t= substr ($c, 0,-4); $c2 = listpane(, "$t", 1 + 8); (Exists("$c2")==1)) { echo "hi! IT WORKS!"; }
else (Exists("$c")==0) { echo "Sorry - try again"; };
Thanks!
Re: How to Check Both Panes for Existing Files?
Posted: 13 Nov 2010 16:29
by PeterH
I don't understand this in several ways...
First: If/ElseIf/Else is one statement: so put no ; in between. (E.g. at end of the If-line.)
Second: ElseIf must, like If, specify what to compare, and then what to execute conditionally.
And third: Else can't have anything to compare - specifies only what to execute if neither If nor any ElseIf executed.
But as I said: I don't understand what you want to achieve, so can't be more specific.