1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PDir format question...

Discussion in 'Support' started by mathewsdw, Mar 9, 2012.

  1. mathewsdw

    Joined:
    May 24, 2010
    Messages:
    855
    Likes Received:
    0
    I am trying to do something where I have done similar things many times in the past re. the PDir command. Specifically, I am trying to call a function from within a function, and this time around I can't get it to work and I don't know what I am doing wrong. So as a slightly made-up example that perfectly illustrates the problem I am having:
    Code:
    [Z:\Compression Stuff]Function WW=`%1`
    
    [Z:\Compression Stuff]PDir *.txt /Ou /(WW[@FileSize[*]/@Lines[*]] fpn)
    WW[49926/481] Z:\Compression Stuff\Analyzed Z-Drive Compression Statistics For Comp
    ressed Files.txt
    WW[103111/1002] Z:\Compression Stuff\Analyzed Z-Drive Compression Statistics.txt
    WW[109110/1002] Z:\Compression Stuff\Analyzed Z-Drive Compression StatisticsIII.txt
    WW[52797/480] Z:\Compression Stuff\Compressed Z-Drive Files .txt
    WW[95177/1455] Z:\Compression Stuff\Compression Report Stage 1.txt
    WW[95177/1455] Z:\Compression Stuff\Compression Report Stage 2.txt
    WW[2069/56] Z:\Compression Stuff\ExtractDateTime .btm Subroutine.txt
    WW[180/0] Z:\Compression Stuff\Raw PDir Compression Report.txt
    WW[56311/520] Z:\Compression Stuff\Uncompressable Z-Drive Files.txt
    
    which works as one would expect but does nothing useful.

    So modifying it a bit to come closer to what I am actually trying to accomplish:
    Code:
    [Z:\Compression Stuff]PDir *.txt /Ou /(@WW[%%@FileSize[*]/%%@Lines[*]] fpn)
    TCC: (Sys) The filename, directory name, or volume label syntax is incorrect.
     "%@Lines[*]"
    
    From everything I know/have done/remember, this should work (no percent sign on the outer function, duplicating the percent signs on the inner functions).

    What am I missing/doing wrong?

    - Dan
     
  2. mathewsdw

    Joined:
    May 24, 2010
    Messages:
    855
    Likes Received:
    0
    Important update to the above. It is strictly related to the "@Lines" function; "/(@WW[%%@FileSize[*]/%%@FileSize[*]]" is silly, but works perfectly (doing nothing useful).
     
  3. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,859
    Likes Received:
    83
    It won't work in either case -- you cannot repeat nested '*' substitution in a single function. PDIR will do the first substitution embedded in the @WW argument and pass the remainder as-is.

    (It only *appeared* to work with the "@WW[%%@FileSize[*]/%%@FileSize[*]" syntax because @FILESIZE will accept wildcard arguments and @LINES will not.)
     
  4. mathewsdw

    Joined:
    May 24, 2010
    Messages:
    855
    Likes Received:
    0
    Thank you for the explanation, Rexx. That's why I was able to get it to work when I replaced the @WW function definition by function that @ExecStr'd a .btm file that did a few other related things that I also wanted to do while it was at it. And from experimenting a little bit it seems that a function "AvgLineLength" defined as `%@Eval[%@FileSize[%1]/%@If[%@FileSize[%1] == 0,1,%@Lin
    es[%1]],=1.1]` almost works but because both the "true" and the "false" side of an "@If" are always evaluated and there are, in fact, 0-length files the .btm file with an actual "Iff" statement is the only way I could accomplish that, anyway. I do think that you should make a note that multiple asterisks in the arguments to a single function that is being invoked by PDir is not suppored in the documentation, however, since I really wouldn't call it "expected" behavior (although it's not that unexpected, either!).

    As far as the WW function goes, it really doesn't matter but I no longer remember what its original purpose was. No real surprise there, I think...
     

Share This Page