parsing a response line from sysfiletree - REXX

This is a discussion on parsing a response line from sysfiletree - REXX ; CyberSimian wrote: > /* following works correctly */ > parse var string date time size attrs 0 (attrs) +7 filename --except for keeping extra stuff in ATTRS; you want a dot before the 0. Actually, though, are there file systems ...

+ Reply to Thread
Page 3 of 4 FirstFirst 1 2 3 4 LastLast
Results 21 to 30 of 35

parsing a response line from sysfiletree

  1. Default Re: parsing a response line from sysfiletree

    CyberSimian wrote:
    > /* following works correctly */
    > parse var string date time size attrs 0 (attrs) +7 filename


    --except for keeping extra stuff in ATTRS; you want a dot before the 0.

    Actually, though, are there file systems that can have a blank at the
    start of a *fully-qualified* file name? That's what sysreftree returns.

    ¬R

  2. Default Re: parsing a response line from sysfiletree

    Glenn Knickerbocker wrote:
    > Actually, though, are there file systems that can have a blank at the
    > start of a *fully-qualified* file name? That's what sysreftree returns.


    Windows XP Professional:

    C:\temp\blanks>dir
    Volume in drive C is C: Drive
    Volume Serial Number is 8017-F8A8

    Directory of C:\temp\blanks

    09/07/2008 08:34 <DIR> .
    09/07/2008 08:34 <DIR> ..
    09/07/2008 08:33 0 a file
    09/07/2008 08:34 0 noblanks.file
    2 File(s) 0 bytes
    2 Dir(s) 39,151,828,992 bytes free

    As I said earlier, having leading blanks in a filename is simply begging
    for problems. I'd be the last person to fail such a request. :-)

    --
    Steve Swift
    http://www.swiftys.org.uk/swifty.html
    http://www.ringers.org.uk

  3. Default Re: parsing a response line from sysfiletree

    Glenn Knickerbocker wrote
    >> parse var string date time size attrs 0 (attrs) +7 filename

    >
    > --except for keeping extra stuff in ATTRS; you want a dot before the 0.


    The correct solution to this problem is to change SysFileTree to return only
    one blank between the attributes and the filename; then a simple parse
    provides the right answer, with leading blanks in the name preserved:

    parse var string date time size attrs filename

    However, compatibility considerations suggest that SysFileTree would not be
    changed in that way (although it could be done via a new option that the
    invoker specified). For the same reason, SysFileTree will not return MORE or
    LESS attributes than it does at the moment (again unless controlled by a new
    option), so the use of the explicit "7" in the parse is safe.

    Can you explain the purpose of putting a dot before the "0"? I cannot see
    that it is needed (but I am always happy to learn something new).

    -- from CyberSimian in the UK



  4. Default Re: parsing a response line from sysfiletree

    On Wed, 09 Jul 2008 08:36:40 +0100, Steve Swift wrote:
    >Glenn Knickerbocker wrote:
    >> Actually, though, are there file systems that can have a blank at the
    >> start of a *fully-qualified* file name? That's what sysreftree returns.

    >
    >C:\temp\blanks>dir
    >09/07/2008 08:33 0 a file
    >09/07/2008 08:34 0 noblanks.file


    Fine, but there's no leading blank in the *fully-qualified* file name
    "C:\temp\blanks\ a file".

    ¬R Around here, the fun is always filled with blanks.
    http://users.bestweb.net/~notr/arkville.html --Theresa Willis

  5. Default Re: parsing a response line from sysfiletree

    On Wed, 9 Jul 2008 10:19:05 +0100, CyberSimian wrote:
    >Can you explain the purpose of putting a dot before the "0"?


    Examine the contents of ATTRS and you'll see. Without the dot, you're
    setting ATTRS to everything that follows one blank after the third word.

    ¬R Plus meditandum, minus misculandum.
    (Marty Shapiro, deftly translated by Sean Fitzpatrick)

  6. Default Re: parsing a response line from sysfiletree

    In <VLSdnfMqTbEQH-nVnZ2dnUVZ8q7inZ2d@bt.com>, on 07/09/2008
    at 10:19 AM, "CyberSimian" <CyberSimian3@BeeTeeInternet.com> said:

    >The correct solution to this problem is to change SysFileTree to return
    >only one blank between the attributes and the filename; then a simple
    >parse provides the right answer, with leading blanks in the name
    >preserved:


    >parse var string date time size attrs filename


    No; you still need to remove an extraneous leading blank.

    --
    Shmuel (Seymour J.) Metz, SysProg and JOAT <http://patriot.net/~shmuel>

    Unsolicited bulk E-mail subject to legal action. I reserve the
    right to publicly post or ridicule any abusive E-mail. Reply to
    domain Patriot dot net user shmuel+news to contact me. Do not
    reply to spamtrap@library.lspace.org


  7. Default Re: parsing a response line from sysfiletree

    Glenn Knickerbocker wrote:
    > Examine the contents of ATTRS and you'll see. Without the dot, you're
    > setting ATTRS to everything that follows one blank after the third word.


    I have now done that, and I see what you mean! Thanks for pointing out this
    error.

    -- from CyberSimian in the UK



  8. Default Re: parsing a response line from sysfiletree

    CyberSimian wrote:

    > /* following works correctly */
    > parse var string date time size attrs 0 (attrs) +7 filename


    Unfortunately this seems "hard coded" to the platform on which the SysFileTree output was generated. For ooRexx on Linux, I needed:

    parse var string date time size attrs . 0 (attrs) +13 filename

    to get the filename correctly.

    It was necessary to add a . after the attrs word to keep that entry clean.

    It would be nice to automate the correct +? finding in some way.

    --
    Michael Lueck
    Lueck Data Systems
    http://www.lueckdatasystems.com/

  9. Default Re: parsing a response line from sysfiletree

    Michael Lueck wrote:
    > Unfortunately this seems "hard coded" to the platform on which the
    > SysFileTree output was generated. For ooRexx on Linux, I needed:
    >
    > parse var string date time size attrs . 0 (attrs) +13 filename


    How about the solution shown below. To work correctly, it requires that the
    attributes (Windows or Linux) are always followed by TWO blanks, and the
    parsing trigger is a string with two blanks (if you are viewing this post
    using a proportionally-spaced font, the trigger might look like a single
    blank, but it really is two).

    -- from CyberSimian in the UK

    -------------------------------------------------------
    /* parstest.rex */

    /* "file" has 5 blanks at the start */
    file=' abc.xyz'
    string='2008-07-02 12:10:00 1000 ADHRS '||file

    say 'SysFileTree data in Windows format using +7 as parsing trigger'
    parse var string date time size attrs . 0 (attrs) +7 filename
    say 'date: "'date'"'
    say 'time: "'time'"'
    say 'size: "'size'"'
    say 'attrs: "'attrs'"'
    say 'file: "'filename'"'

    say 'SysFileTree data in Windows format using " " as parsing trigger'
    parse var string date time size attrs . 0 (attrs) ' ' filename
    say 'date: "'date'"'
    say 'time: "'time'"'
    say 'size: "'size'"'
    say 'attrs: "'attrs'"'
    say 'file: "'filename'"'

    say 'SysFileTree data in Linux format using " " as parsing trigger'
    string='2008-07-02 12:10:00 1000 drwxrwxrwx '||file
    parse var string date time size attrs . 0 (attrs) ' ' filename
    say 'date: "'date'"'
    say 'time: "'time'"'
    say 'size: "'size'"'
    say 'attrs: "'attrs'"'
    say 'file: "'filename'"'
    ----------------------------------------------------------------



  10. Default Re: parsing a response line from sysfiletree

    CyberSimian wrote:
    > How about the solution shown below.
    > say 'SysFileTree data in Linux format using " " as parsing trigger'
    > parse var string date time size attrs . 0 (attrs) ' ' filename


    That works on Linux for me, so I assume it will also work on Windows.

    Thanks! :-)

    --
    Michael Lueck
    Lueck Data Systems
    http://www.lueckdatasystems.com/

+ Reply to Thread
Page 3 of 4 FirstFirst 1 2 3 4 LastLast