WAD PDIR @IF bug, @WORD bug

Jul 21, 2012
32
0
Hi,

20 years user of 4DOS / NDOS / 4NT etc.
(Using version TCC 14.00.29 x64 on Windows 7)

A small bug:
The following:​
pdir /(@if[1,%%@filesize[*],%%@filesize[*]] fn)​
prints:​
%@if[1,8994580,8994580] Windows​
instead of:​
8994580 Windows​

Another bug, not sure what the extent of it, appears when using @word. It only works on file names with no spaces in them. The following:
pdir /(@word["\",0,*] fpn)​
prints:​
"C:\Program Files" C:\Program Files​
C: C:\Windows​
instead of:​
C: C:\Program Files​
C: C:\Windows​
Cheers,
Gilad
 

rconn

Administrator
Staff member
May 14, 2008
12,340
149
A small bug:
The following:​
pdir /(@if[1,%%@filesize[*],%%@filesize[*]] fn)​
prints:​
%@if[1,8994580,8994580] Windows​
instead of:​
8994580 Windows​

Not a bug -- you've invented a new feature (and then reported that it doesn't work! :)).

The "@function[*]" syntax in PDIR only accepts a single argument, and you're passing it two. I might be able to support your specific instance (@IF[...]) in a future build.
 

rconn

Administrator
Staff member
May 14, 2008
12,340
149
Another bug, not sure what the extent of it, appears when using @word. It only works on file names with no spaces in them. The following:
pdir /(@word["\",0,*] fpn)​
prints:​
"C:\Program Files" C:\Program Files​
C: C:\Windows​
instead of:​
C: C:\Program Files​
C: C:\Windows​

WAD -- what this is being expanded to is this:

pdir /(@word["\",0,"C:\Program Files")

The filenames returned for the * argument are double quoted if they contain whitespace. This was requested (well, demanded) by users who didn't want to have to explicitly enter the quotes. So your @WORD function sees a single (double quoted) argument, and returns the whole thing.

You're probably trying to push PDIR a little too far -- these examples would be better handled with a DO loop.
 
May 20, 2008
3,515
4
Elkridge, MD, USA
Code:
pdir /(@if[1,%%@filesize[*],%%@filesize[*]] fn)

The first parameter of @IF should be a conditional expression as defined in HELP -> Conditional Expressions, not a number, which is a numeric expression. This is not C/C++! In the IF command the result of some of the @IS... functions is parsed in the manner of a C/C++, but not elsewhere.

Another bug, not sure what the extent of it, appears when using @word. It only works on file names with no spaces in them. The following:
pdir /(@word["\",0,*] fpn)​
prints:​
"C:\Program Files" C:\Program Files​
C: C:\Windows​
instead of:​
C: C:\Program Files​
C: C:\Windows​
WAD. As discussed at length many versions before the current one. the * symbol representing the full name of the current directory entry is quoted when it contains special characters, such as spaces, but not otherwise. When the last parameter of @WORD is a quoted string, the whole string is parsed as its word 0 regardless of the chosen word separator. If you want the drive letter followed colon :)), use
Code:
pdir/(@left[2,%%@path[*]] fpn)
 
Jul 21, 2012
32
0
The "@function[*]" syntax in PDIR only accepts a single argument, and you're passing it two.
Mmm - wasn't aware of that - probably worth a clarification in the help text...

No need to create a special build for me :). I did circumvent the issue with a Do loop, but still use the @output of a PDIR as it is quicker than doing @filesize for every file...

Still would be handy to have the full capabilities of @functions within a PDIR. In addition, I have some feature requests for it, but I'll open a new thread for that.
 
Jul 21, 2012
32
0
By the way, intended or not, the @IF condition does produce C/C++ results for 0 and 1. Try: echo %@if[0,2,3]
 
Jul 21, 2012
32
0
Just digested the bit about @WORD with double quotes :eek:. This makes it meaningless. Wouldn't make more sense to strip the double quotes and return the requested word?
 
May 20, 2008
3,515
4
Elkridge, MD, USA
Just digested the bit about @WORD with double quotes :eek:. This makes it meaningless. Wouldn't make more sense to strip the double quotes and return the requested word?
Not really meaningless. Most environment variables contain unquoted strings, functions and internal variables likewise, so @WORD will operate on them flawlessly. It is only in the * symbolic representation of the current directory entry in PDIR where the value is automatically quoted the issue can come up; one can use the @UNQUOTES function to remove the quotation marks, or use functions intended to analyze file specifications instead of generic string analyzers.
 
May 31, 2008
382
2
one can use the @UNQUOTES function to remove the quotation marks
Indeed adding @unquotes works as intended, but Rex pointed out that nested @fun[] syntax in PDIR is an invented feature so YMMV
Code:
E:\>pdir /(@word["\",0,%%@unquotes[*]] fpn) c:\
C: C:\PerfLogs
C: C:\Program Files
 
Similar threads
Thread starter Title Forum Replies Date
R Colored directory listing bug with pdir. Support 1
Phileosophos PDIR to list filenames without extensions? Support 2
vefatica PDIR and streams Support 1
vefatica PDIR with fixed-width unqualified filename? Support 2
W pdir returns diff results between tcc and tcmd - one is an error msg Support 5
thedave pdir /s Support 2
Emilio III pdir /f switch Support 1
D pdir ignores pm Support 2
WadeHatler pdir broken in 19.1 for directories with spaces Support 1
M WAD PDir not working correctly... Support 5
vefatica WAD Nested variable expansion in PDIR's @function[*]? Support 13
mfarah More on pdir's options: /(fq) Support 5
mfarah How to? Getting pdir to display relative paths. Support 2
S PDIR and @LABEL questions Support 4
M How to? PDir on multiple wildcard patterns... Support 2
A pdir function usage Support 3
T How to? dir/pdir - 2nd level down only Support 7
JohnQSmith PDIR and descriptions Support 21
S WAD PDIR: files with percent sign % in name cause not listing other files in directory Support 9
S WAD PDIR ignores exclusion ranges Support 1
M PDir format question... Support 3
M How to? "PDir" not working the way the I _thought _ the documentation said it does… Support 8
S WAD /Sn mishandled in DIR and PDIR, possibly elsewhere Support 15
S Fixed GPF in PDIR Support 3
S PDIR issue Support 1
M PDir causing Take Command/TCC to crash... Support 6
M A "PDir" issue... Support 16
M A simple question related to the "dir" (and "pdir") commands... Support 5
J pdir /b1 issue Support 20
M Missing PDir option... Support 5
J Maybe Not So Hard Pdir Question Support 1
S PDIR fails in 12.10.55 Support 3
J V12 PDIR failure Support 1
S PDIR command causes GPF Support 5
D pdir inconsistency Support 4
S PDIR has trouble processing filenames with embedded percent sign Support 3
P PDIR woes Support 0
gschizas pdir crashes horribly in one specific folder Support 5
S PDIR question Support 2
S pdir /(fq) not working Support 5
nickles Bias in PDIR Support 5
F pdir problem Support 3
D can PDIR list full filepaths of docs in a nested folder? Support 13
Dick Johnson v28 Cosmetic Bug Support 0
Jay Sage WAD Possible Bug With OPTION Command With @FILE Support 5
R strange bug? Support 7
Jay Sage Bug With Flow Control and/or Command Grouping Support 2
M Server 2019 Bug with @execstr? Support 14
R bug _ypixels in BDEBUGGER Support 6
E Fixed Bug with DIR /Z displaying descriptions Support 8

Similar threads