Announcement

Collapse
No announcement yet.

File extensions?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Jeff Blakeney
    replied
    I haven't been using PBWin 9 for very long and I hadn't come across the PATHNAME$ function but I'm not sure I'll be using it. Of the four forms it can take, all but one can be replaced with a single line of code. The one that takes two lines of code is the one for getting the filename without an extension and I can see little use for that. Besides, the way I do it can all be replaced with a macro or function if desired. And by creating your own macro or function, you can also add the ability to pull out the drive as well as get the number of directories in the path and pull out each individual directory name which you can't do with the PATHNAME$ command.

    Leave a comment:


  • Michael Mattias
    replied
    Code:
    DECLARE FUNCTION PathFindExtension LIB "SHLWAPI.DLL" ALIAS "PathFindExtensionA" _
        (pszPath AS ASCIIZ) AS DWORD

    Leave a comment:


  • John Gleason
    replied
    Paul's suggestion with PB 9/5 is the new way:
    Code:
    filespec = "MyValidFile.Name.txt.dt"
    PATHNAME$(EXTN,  filespec) 'returns ".dt"

    Leave a comment:


  • Jeff Blakeney
    replied
    This has always worked for me:

    Code:
    MID$(Pathname$, INSTR(-1, Pathname$, "."))

    Leave a comment:


  • Paul Dixon
    replied
    With the latest compiler you can use PATHNAME$

    http://www.powerbasic.com/support/help/pbcc/pathname$_function.htm

    Leave a comment:


  • Michael Mattias
    replied
    Look for the dot starting at the end and working backwards?

    Leave a comment:


  • Pat Bullman
    started a topic File extensions?

    File extensions?

    Is there a method for determing if a filespec holds an extension?

    In the old DOS days of 8:3 filenames it was fairly straight forward - look for the "." - not so simple with long names. For example you may find a valid filespec of:

    Code:
    filespec = "MyValidFile.Name.txt.dt"
    In this example I would regard the ".dt" as the file extension.

    If there's no easy or established method, I'll develop my own but I thought this issue must have been "solved" before.


    Pat
Working...
X