Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Drive Path Name Extent (Word97/SR2)

    (Template attached)

    I'm still searching for a definitive description of how to parse a filename in this day and age (Win98/SE since you ask).

    For a standalone system, a "chunk" of data, commonly called a file, is identified uniquely by a string of keyboard characters which (string) can be broken down into elements known as "DRIVE, PATH, NAME and EXTENT".

    My strBreakFileString has just broken with a file that has two periods in its description.

    So I've been thinking to be a tad more specific about what constitutes each part.


    Drive Separator

    Usually a colon character ":"


    Path Separator

    Usually a backslash "" character, but can be a double-backslash "" as found in a Word97 Hyperlink field.


    Extent Separator

    Usually a period ".".


    Drive Element

    If no drive separator string is found, then the DRIVE element is empty.
    The Drive Element is the data extending from left hand end of the string to the drive separator in the string.
    More than one drive separator invalidates the string.


    Path Element

    If no path separator string is found, then the DRIVE element is empty.

    The Path Element is the data to the right of the drive element, if any, extending to the rightmost path separator,


    Extent Element

    The Extent Element is the data extending from the first extent separator following the rightmost path separator.


    Name Element

    The name Element is the data between the path element, (if any, else the drive element, if any, else the leftmost end of the string) and the extent element, (if any, else the rightmost end of the string).

    The name can not be an empty string.



    Method:

    I no longer travel from left to right along the string, but instead look for the Drive, Path and Extent in that order; anything left over must be the Name portion.

    I have elected to treat only the LAST period following the Path Element as the extent delimiter, because Windows Explorer uses this method to determine file-types for association. I could use all text following the FIRST period following the Path Element as an option.
    Attached Files Attached Files

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Drive Path Name Extent (Word97/SR2)

    How about

    Extent = right$(fullname,3) ?
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Drive Path Name Extent (Word97/SR2)

    Chris,

    What is your link supposed to point to? It leads to a Lounge Search with a long page of posts rather than to a specific post with the code in it. Is that what you intended?
    Charlotte

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Drive Path Name Extent (Word97/SR2)

    If you upgrade to Office 2000 you can use InStrRev() to search from the end of the file name to the first (last) period. There is a library function to do this supplied with the VBA Developer's Handbook by Getz and Gilbert for the VBA5 crowd.

    Unless you are sure you will not have to deal with UNC strings, you probably want to allow for the possibility of ServerShareFolderSubfolderFile.ext syntax as well.

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Drive Path Name Extent (Word97/SR2)

    I use .html so... maybe:

    Right(fullname, 5 - InStr(1, Right(fullname, 5), "."))

  6. #6
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Drive Path Name Extent (Word97/SR2)

    Since posting I've had time to reflect. Here are some other considerations which I foreshadowed in the full text (in the template) but have not yet incorprated into the code.

    The text/code is draft, because I value feedback from the VBA forum on my ideas.

    We don't get sunshine this wekeend, I'll have it all wrapped up come Monday (grin!)



    2002/06/14 CG DPNE cope with knowing that a string describes a directory (and hence has no name or extent items)
    2002/06/14 CG DPNE incorporate a set of valid characters outside of the three separators.
    2002/06/14 CG DPNE option to use all text following the FIRST period following the Path Element as the extent item
    2002/06/14 CG DPNE provide meaningful cover functions for common utility requirements.
    2002/06/14 CG DPNE use separator strings > 1 character in length.
    2002/06/14 CG DPNE use the

  7. #7
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Drive Path Name Extent (Word97/SR2)

    > Extent = right$(fullname,3)

    Because the extent isn't necessarily the rightmost THREE characters, as in "homepage.html".

    (Also because I want to give the developer the option of including all text to the right of the FIRST period after the rightmost path separator, as well as the option of including only text to the right of the LAST period after the rightmost path separator.

  8. #8
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Drive Path Name Extent (Word97/SR2)

    > It leads to a Lounge Search

    That's right.

    In part it's an aide-memoire for those who remember "That I saw something else about that", but can't remember where it is.

    Sometimes I think I'm the only Lounger who sees any value in SEARCH.


    SEARCH is a superb tool for laying up a store of references to posts that are yet to come.

    A year from now someone else may post something referenced by a SEARCH in today's post, and a year from now, someone reading what I've posted today will discover what will not yet be written for a year to come.

    Powerful stuff!

  9. #9
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Drive Path Name Extent (Word97/SR2)

    > If you upgrade to Office 2000

    Does this mean I have to drag the WinXP/OfficeXP drive out of the closet? I've not fired it up for months.


    InStrRev as in "InStr REVerse", I take it.

    That would save me a little bit of looping, but not much, and it won't be useful for the developer option of using (see my response to Kevin) all text to the right of the first period after the rightmost path separator.



    > you are sure you will not have to deal with UNC strings

    Not at all. I just don't have any within a hundred and twenty feet of me; hence my not-so-veiled reference to phase 2 - this basic test should (be made to) work on any other machine.

    I have stolen your path example as test data; hope you don't mind ...

  10. #10
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Drive Path Name Extent (Word97/SR2)

    In the meanwhile, it's a tad vague, don't you think? Sort of like saying, "I wrote this wonderful sentence in my novel and its somewhere in one of the 350 chapters. Just look around until you find it!" <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    Charlotte

  11. #11
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Impossible to parse!

    Here's something of interest (to me, at least, as a logical challenge).

    Given the input string below, it ought to be impossible (!) to parse a folder or a file name from the string.

    There is no path separator, so one cannot say explicitly "this is a path" or even "there is a hint of a path here".

    I can envisage a FILE "tempautoexec.bat" in any folder on drive C.

    I can envisage a FOLDER "tempautoexec.bat"in any folder on drive C.

    If I am running on the host system, I could issue a test to see whether it is a folder or not ((GetAttr(strIn) And vbDirectory) = vbDirectory), but given the string and asked to parse it, I think that there is no way to distinguish between a folder and a file.

    darn!


    Maybe that's why there are so few documents issuing definitive statements about parsing filename strings?


    <pre> ' No path separator - so it could be a folder OR a file!
    strIn = "c:tempautoexec.bat"
    </pre>


  12. #12
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Drive Path Name Extent (Word97/SR2)

    Au contraire.

    > Just look around until you find it!

    By choosing search phrases I'm pointing the reader to areas that could well be of interest to them (noone has to click on a search item)


    Charlotte, imagine that you're not an expert at VBA, like we all used to be, and that you've just read my post with the <font color=blue>GetAttr</font color=blue> word. You're curious about GetAttr, so you want to see what else has been said about it. If you get 200 hits, that tells you that GetAttr is a popular thingo, maybe you should explore it more. If you get as few as five hits, you can quickly get a feel of what it does.


    > I wrote this wonderful sentence in my novel

    Not for me to judge how wonderful are my posts and response. That's for the reader to decide.

    And every reader has different needs.


    I have maintained for far too long that under-utilization of the SEARCH tag greatly diminshes the value of the Lounge. Obtaining immediate answers to immediate problems is fine (and of great value), but every posting adds to the repository of data, and it will be SEARCHing this data that yields the greatest value for future users. We should be preparing our posts so that future users can obtain answers to questions without having to re-post questions that have alreday been answered.

    Think of our users yet to arrive on the scene, and put out a welcome mat.

  13. #13
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Drive Path Name Extent (Word97/SR2)

    Note also

  14. #14
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Drive Path Name Extent (Word97/SR2)

    Chris,

    I use search and I recommend it, but I think it only polite to indicate in a message that the link is to a *list* of posts rather than to a thread or a single post. I was mildly curious, enough to click the link. I certainly wasn't curious enough to wade through all the search results to try and figure out what you were talking about.

    That isn't a welcome mat and it doesn't teach the loungers how to use search, it just throws them in the deep end unexpectedly.
    Charlotte

  15. #15
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Drive Path Name Extent (Word97/SR2)

    > indicate in a message that the link is to a *list* of posts

    You may want to re-read Nice to have - search tags colour.

    30 people read it.

    No-one commented on it.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •