DOS File Lookup - just the file name, not the path AND file name 
Author Message
 DOS File Lookup - just the file name, not the path AND file name

I am hoping there is some simple change I can make, but I don't know where
to start.  I am using the DOS File Lookup button on a window to select a
file for an image.  It works but is storing the whole path to the file in
addition to the filename and I need to save just the filename without the
directory.  So instead of the entry field (picfilename) showing C:\My
documents\myfile.jpg how can I change things so that after the DOS lookup
only myfile.jpg is saved to the picfilename field.?

Probably something simple, but I am missing it.

Any help would be greatly appreciated.

Dennis



Mon, 10 Oct 2005 00:28:08 GMT  
 DOS File Lookup - just the file name, not the path AND file name
I use the API call Fn_Split. do a search in the comp.lang.clarion newsgroup
and you will find the code to use this function.

Jeff Hojka
Marathon Software Co.

Quote:
> I am hoping there is some simple change I can make, but I don't know where
> to start.  I am using the DOS File Lookup button on a window to select a
> file for an image.  It works but is storing the whole path to the file in
> addition to the filename and I need to save just the filename without the
> directory.  So instead of the entry field (picfilename) showing C:\My
> documents\myfile.jpg how can I change things so that after the DOS lookup
> only myfile.jpg is saved to the picfilename field.?

> Probably something simple, but I am missing it.

> Any help would be greatly appreciated.

> Dennis



Mon, 10 Oct 2005 00:38:28 GMT  
 DOS File Lookup - just the file name, not the path AND file name
Hi Dennis, if you don't want to use the API functions, you can always
'slice' the returned filename + path. I think working backwards until you
get to a '\' should do the trick.

HTH



Mon, 10 Oct 2005 01:37:03 GMT  
 DOS File Lookup - just the file name, not the path AND file name
Hi guys,

Thanks for the tips, but I haven't found the API Fn_Split and not sure how
to "slice" the filename and path. (BTW I am using C6 EA3 if it matters).  I
have found a line (that seems protected and I can't edit it) that says
KeepDir = 0 and I was wondering if I could change that to a 1 maybe that
would not include the directory, just the file name.  ??
not sure where I found this but it doest seem to be protected not like an
embed I could edit.



Quote:
> Hi Dennis, if you don't want to use the API functions, you can always
> 'slice' the returned filename + path. I think working backwards until you
> get to a '\' should do the trick.

> HTH



Mon, 10 Oct 2005 02:34:57 GMT  
 DOS File Lookup - just the file name, not the path AND file name
Use www.google.com and do a search in the newsgroups.  Put the following in
your search field.
  "comp.lang.clarion fn_split"

I get two results.

Try this link
http://groups.google.com/groups


Quote:
> Hi guys,

> Thanks for the tips, but I haven't found the API Fn_Split and not sure how
> to "slice" the filename and path. (BTW I am using C6 EA3 if it matters).
I
> have found a line (that seems protected and I can't edit it) that says
> KeepDir = 0 and I was wondering if I could change that to a 1 maybe that
> would not include the directory, just the file name.  ??
> not sure where I found this but it doest seem to be protected not like an
> embed I could edit.



> > Hi Dennis, if you don't want to use the API functions, you can always
> > 'slice' the returned filename + path. I think working backwards until
you
> > get to a '\' should do the trick.

> > HTH



Mon, 10 Oct 2005 03:17:26 GMT  
 DOS File Lookup - just the file name, not the path AND file name
Thanks to all who responded!  I got it working thanks to a code snippet
emailed to me.

I appreciate all who offered there help!!!

Dennis


Quote:
> Use www.google.com and do a search in the newsgroups.  Put the following
in
> your search field.
>   "comp.lang.clarion fn_split"

> I get two results.

> Try this link
> http://groups.google.com/groups



> > Hi guys,

> > Thanks for the tips, but I haven't found the API Fn_Split and not sure
how
> > to "slice" the filename and path. (BTW I am using C6 EA3 if it matters).
> I
> > have found a line (that seems protected and I can't edit it) that says
> > KeepDir = 0 and I was wondering if I could change that to a 1 maybe that
> > would not include the directory, just the file name.  ??
> > not sure where I found this but it doest seem to be protected not like
an
> > embed I could edit.



> > > Hi Dennis, if you don't want to use the API functions, you can always
> > > 'slice' the returned filename + path. I think working backwards until
> you
> > > get to a '\' should do the trick.

> > > HTH



Mon, 10 Oct 2005 03:20:54 GMT  
 DOS File Lookup - just the file name, not the path AND file name
Hi Dennis;

Here's how I did it the last time:

   YY = LEN(CLIP(Attachpath))
    LOOP XX = YY TO 1 BY -1
        IF Attachpath[XX] = '\'
            BREAK.
    END

    XX +=1
    CLEAR(AttachFileName)
    AttachFileName = Attachpath[XX : YY]

HTH

Greg


Quote:
> Hi guys,

> Thanks for the tips, but I haven't found the API Fn_Split and not sure how
> to "slice" the filename and path. (BTW I am using C6 EA3 if it matters).
I
> have found a line (that seems protected and I can't edit it) that says
> KeepDir = 0 and I was wondering if I could change that to a 1 maybe that
> would not include the directory, just the file name.  ??
> not sure where I found this but it doest seem to be protected not like an
> embed I could edit.



> > Hi Dennis, if you don't want to use the API functions, you can always
> > 'slice' the returned filename + path. I think working backwards until
you
> > get to a '\' should do the trick.

> > HTH



Mon, 10 Oct 2005 03:23:49 GMT  
 DOS File Lookup - just the file name, not the path AND file name
Dennis -

As yet another suggestion, you could look at my redirection stuff:

http://www.clarionmag.com/cmag/v2/v2n12redir.html

In there, is a FileDialog() method that has a switch for "Return
Relative Path". I use this all of the time. Especially handy on
networked apps that have differing drive letters for the application.

So, if you have an image file in "m:\yourapp\images\yourfile.jpg",
then it will return "images\yourfile.jpg".

Or, if you have a redirection entry for *.jpg=%ROOT%\images, then it
will just return the yourfile.jpg.

On Wed, 23 Apr 2003 14:34:57 -0400, "Dennis Baggott"

Quote:

>Hi guys,

>Thanks for the tips, but I haven't found the API Fn_Split and not sure how
>to "slice" the filename and path. (BTW I am using C6 EA3 if it matters).  I
>have found a line (that seems protected and I can't edit it) that says
>KeepDir = 0 and I was wondering if I could change that to a 1 maybe that
>would not include the directory, just the file name.  ??
>not sure where I found this but it doest seem to be protected not like an
>embed I could edit.



>> Hi Dennis, if you don't want to use the API functions, you can always
>> 'slice' the returned filename + path. I think working backwards until you
>> get to a '\' should do the trick.

>> HTH

Jeff Slarve  
http://www.jssoftware.com


Mon, 10 Oct 2005 03:31:56 GMT  
 DOS File Lookup - just the file name, not the path AND file name
If you have HandyTools, it's in there already.

Rocky


Quote:
> Hi guys,

> Thanks for the tips, but I haven't found the API Fn_Split and not sure how
> to "slice" the filename and path. (BTW I am using C6 EA3 if it matters).
I
> have found a line (that seems protected and I can't edit it) that says
> KeepDir = 0 and I was wondering if I could change that to a 1 maybe that
> would not include the directory, just the file name.  ??
> not sure where I found this but it doest seem to be protected not like an
> embed I could edit.



> > Hi Dennis, if you don't want to use the API functions, you can always
> > 'slice' the returned filename + path. I think working backwards until
you
> > get to a '\' should do the trick.

> > HTH



Mon, 10 Oct 2005 04:01:12 GMT  
 DOS File Lookup - just the file name, not the path AND file name
Hi Dennis,

On Wed, 23 Apr 2003 12:28:08 -0400, "Dennis Baggott"

Quote:

>I am hoping there is some simple change I can make, but I don't know where
>to start.  I am using the DOS File Lookup button on a window to select a
>file for an image.  It works but is storing the whole path to the file in
>addition to the filename and I need to save just the filename without the
>directory.  So instead of the entry field (picfilename) showing C:\My
>documents\myfile.jpg how can I change things so that after the DOS lookup
>only myfile.jpg is saved to the picfilename field.?

>Probably something simple, but I am missing it.

With Clarion there is a file called CLIB.CLW.  Include this file in
the "Inside the Global Map":

Include('clib.clw')

This gives you access to all the functions that are documented in
chapter 13 in the programmers guide (PDF)

Here is parts of code in my api library class:

Inc file...
FnS:Path       Cstring(256)
FnS:Drive      Cstring(256)
FnS:Dir        Cstring(256)
FnS:File       Cstring(256)
FnS:Ext        Cstring(256)
...

! FnSplit functions
FnSplit              Procedure(String pPath)         ! Populates FnS
properties
GetFileName          Procedure(String pPath),String  ! Returns
filename only
GetExtension         Procedure(String pPath),String  ! Returns
extension only
GetFullFileName      Procedure(String pPath),String  ! Returns
filename and extension
GetDrive             Procedure(String pPath),String  ! Returns drive
only
GetPathOnly          Procedure(String pPath),String  ! Returns path
only (no drive)
GetPath              Procedure(String pPath),String  ! Returns path
(with drive)
GetPathIfDrive       Procedure(String pPath),String  ! Returns path if
drive is part of path
GetFullNoExt         Procedure(String pPath),String  ! Returns drive,
path and filename (no extension)
GetRelativePath      Procedure(String pPath, String pFileName, <Byte
pFilenameOnly>),String
GetFileDate          Procedure(String pFile),Long
GetFileTime          Procedure(String pFile),Long
FileDateTimeSame     Procedure(String pFile, Long pDate, Long
pTime),Byte

Clw file...

   Map
     Include('clib.clw')
   End

...

Implemented code:

!==============================================================================
ApiClass.FnSplit                 Procedure(String pPath)
!------------------------------------------------------------------------------
Code
 FnS:Path = Clip(pPath)
 X# = FnSplit(FnS:Path,Self.FnSDrive,Self.FnSDir,Self.FnSFile,Self.FnSExt)

!==============================================================================
ApiClass.GetFileName             Procedure(String pPath)!,String
!------------------------------------------------------------------------------
Code
 FnS:Path = Clip(pPath)
 X# = FnSplit(FnS:Path,FnS:Drive,FnS:Dir,FnS:File,FnS:Ext)
 Return(Clip(FnS:File))

!==============================================================================
ApiClass.GetExtension            Procedure(String pPath)!,String
!------------------------------------------------------------------------------
 Code
 FnS:Path = Clip(pPath)
 X# = FnSplit(FnS:Path,FnS:Drive,FnS:Dir,FnS:File,FnS:Ext)
 Return(Clip(FnS:Ext))

!==============================================================================
ApiClass.GetFullFileName         Procedure(String pPath)!,String
!------------------------------------------------------------------------------
 Code
 FnS:Path = Clip(pPath)
 X# = FnSplit(FnS:Path,FnS:Drive,FnS:Dir,FnS:File,FnS:Ext)
 Return(Clip(FnS:File) & Clip(FnS:Ext))

!==============================================================================
ApiClass.GetDrive                Procedure(String pPath)!,String
!------------------------------------------------------------------------------
 Code
 FnS:Path = Clip(pPath)
 X# = FnSplit(FnS:Path,FnS:Drive,FnS:Dir,FnS:File,FnS:Ext)
 Return(Clip(FnS:Drive))

!==============================================================================
ApiClass.GetPathOnly             Procedure(String pPath)!,String
!------------------------------------------------------------------------------
 Code
 FnS:Path = Clip(pPath)
 X# = FnSplit(FnS:Path,FnS:Drive,FnS:Dir,FnS:File,FnS:Ext)
 Return(Clip(FnS:Dir))

!==============================================================================
ApiClass.GetPath                 Procedure(String pPath)!,String
!------------------------------------------------------------------------------
 Code
 FnS:Path = Clip(pPath)
 X# = FnSplit(FnS:Path,FnS:Drive,FnS:Dir,FnS:File,FnS:Ext)
 Return(Clip(FnS:Drive) & Clip(FnS:Dir))

!==============================================================================
ApiClass.GetPathIfDrive           Procedure(String pPath)!,String
!------------------------------------------------------------------------------
p  CString(256)
 Code
 FnS:Path = Clip(pPath)
 X# = FnSplit(FnS:Path,FnS:Drive,FnS:Dir,FnS:File,FnS:Ext)
 If FnS:Drive
   p = Clip(FnS:Drive) & Clip(FnS:Dir)
 Else
   p = ''
 End
 Return(p)

!==============================================================================
ApiClass.GetFullNoExt         Procedure(String pPath) !,String
!------------------------------------------------------------------------------
 Code
 FnS:Path = Clip(pPath)
 X# = FnSplit(FnS:Path,FnS:Drive,FnS:Dir,FnS:File,FnS:Ext)
 Return(Clip(FnS:Drive) & Clip(FnS:Dir) & Clip(FnS:File))

!==============================================================================
ApiClass.GetRelativePath      Procedure(String pPath, String
pFileName, <Byte pFilenameOnly>) !,String
!------------------------------------------------------------------------------
p  CString(256)
 Code
 If Omitted(4)
   pFilenameOnly = True
 End
 FnS:Path = pFileName
 X# = FnSplit(FnS:Path,FnS:Drive,FnS:Dir,FnS:File,FnS:Ext)
 If pFilenameOnly
   p = FnS:File & FnS:Ext
 Else
   If Instring(Upper(LongPath(p)),Upper(LongPath(FnS:Path)),1,1)
     p = FnS:File & FnS:Ext
   End
 End
 Return(p)

!==============================================================================
ApiClass.GetFileDate          Procedure(String pFile)!,Long
!------------------------------------------------------------------------------
FQ  Queue(FILE:Queue),Pre(FQ)
    End
D   Long
 Code
 If pFile
   Directory(FQ,Clip(pFile),ff_:normal)
   If Records(FQ)=1
     D = FQ.Date
   End
 End
 Free(FQ)
 Return(D)

!==============================================================================
ApiClass.GetFileTime          Procedure(String pFile)!,Long
!------------------------------------------------------------------------------
FQ  Queue(FILE:Queue),Pre(FQ)
    End
T   Long
 Code
 If pFile
   Directory(FQ,Clip(pFile),ff_:normal)
   If Records(FQ)=1
     T = FQ.Time
   End
 End
 Free(FQ)
 Return(T)

!==============================================================================
ApiClass.FileDateTimeSame     Procedure(String pFile, Long pDate, Long
pTime)!,Byte
!------------------------------------------------------------------------------
FQ  Queue(FILE:Queue),Pre(FQ)
    End
D   Long
T   Long
R   Byte
 Code
 R = True
 If pFile
   Directory(FQ,Clip(pFile),ff_:normal)
   If Records(FQ)=1
     D = Self.GetFileDate(pFile)
     T = Self.GetFileTime(pFile)
     If pDate  <> D Or pTime <> T
       R = False
     End
   End
 End
 Return(R)

Hope this helps:)

Best regards,

Arnr Baldvinsson
Icetips Software        
San Antonio, Texas, USA
www.icetips.com

Subscribe to information from Icetips.com:
http://www.icetips.com/getnotificationinfo.htm



Mon, 10 Oct 2005 04:25:39 GMT  
 DOS File Lookup - just the file name, not the path AND file name
Arnor -

That's sorta like what I use

GetElementFromPath  Procedure(String pPath,Byte pElement=12)

 Itemize,PRE(Part)
DriveName Equate(1)
Directory Equate(2)
FileName  Equate(4)
Extension Equate(8)
         end

ReturnVal CString(File:MaxFilePath)
LOC:Path CString(File:MaxFilePath)
ElementGroup  Group,PRE()
LOC:Drv  CString(File:MaxFilePath)
LOC:Dir  Cstring(File:MaxFilePath)
LOC:Name Cstring(File:MaxFilePath)
LOC:Ext  Cstring(File:MaxFilePath)
              end

  Code

  Clear(ReturnVal)
  LOC:Path = Clip(pPath)
  FNSplit(LOC:Path,LOC:Drv,LOC:Dir,LOC:Name,LOC:Ext)
  If BAND(pElement,Part:DriveName)
    ReturnVal = ReturnVal & LOC:Drv
  end
  If BAND(pElement,Part:Directory)
    ReturnVal = ReturnVal & LOC:Dir
  end
  If BAND(pElement,Part:FileName)
    ReturnVal = ReturnVal & LOC:Name
  end
  If BAND(pElement,Part:Extension)
    ReturnVal = ReturnVal & LOC:Ext
  end
  Return ReturnVal


Quote:

>!==============================================================================
>ApiClass.FnSplit                 Procedure(String pPath)
>!------------------------------------------------------------------------------
>Code
> FnS:Path = Clip(pPath)
> X# = FnSplit(FnS:Path,Self.FnSDrive,Self.FnSDir,Self.FnSFile,Self.FnSExt)

Jeff Slarve  
http://www.jssoftware.com


Mon, 10 Oct 2005 04:35:16 GMT  
 DOS File Lookup - just the file name, not the path AND file name
Hi Jeff,



Quote:
>That's sorta like what I use

>GetElementFromPath  Procedure(String pPath,Byte pElement=12)

Your's is simpler - you're better at bit counting than I am<g>

Best regards,

Arnr Baldvinsson
Icetips Software        
San Antonio, Texas, USA
www.icetips.com

Subscribe to information from Icetips.com:
http://www.icetips.com/getnotificationinfo.htm



Mon, 10 Oct 2005 06:49:35 GMT  
 
 [ 14 post ] 

 Relevant Pages 

1. Making file path control only select directory paths not file names

2. Alias TPS with different path/file name than original file

3. Max length of VI file paths and file names

4. error 37 File not open using a variable file name

5. How can I know the .EXE file name, file date, file size

6. COMMAND() and long file name path - BUG?

7. C4 ABC - System crashes when giving Full Path Name for a file

8. CW2.003 Report Writer - Using variable for file path/name

9. Grabbing Saved File Name And Path

10. FileDialog - default path - changing file name

11. FORTRAN INQUIRE for a path/file name

12. (VA 4.02b) using long file names for Envy file attachments

 

 
Powered by phpBB® Forum Software