|
||
The PathClass is a handy utility that takes a filename and path (or just filename) and returns any portion of it.
The PathClass is defined as:
PS_PathClass CLASS
GetFilePath PROCEDURE( STRING PS_FilePath ), STRING
GetDriveLetter PROCEDURE( STRING PS_FilePath ), STRING
GetFullFileName PROCEDURE( STRING PS_FilePath ), STRING
GetFileName PROCEDURE( STRING PS_FilePath ), STRING
GetExtension PROCEDURE( STRING PS_FilePath ), STRING
GetMyDocuments PROCEDURE(), STRING
GetMyPictures PROCEDURE(), STRING
GetLocationByCLSID PROCEDURE( LONG CSLID_ID ), STRING
GetFileInfo PROCEDURE( STRING PS_FileInfo, STRING PS_FilePath), LONG
END !Class
!-----------------------------------------------------------------------------------------------------
!Equates for PS_PathClass
!-----------------------------------------------------------------------------------------------------
CSIDL_MyDocuments EQUATE(5H) !My Documents
CSIDL_MyPictures EQUATE(27H) !My Pictures
CSIDL_SendTo EQUATE(9H) !<user name>\SendTo
CSIDL_Recent EQUATE(8H) !<user name>\Recent
CSIDL_DesktopRecycle EQUATE(0AH) !Desktop\Recycle Bin
CSIDL_StartMenuPrograms EQUATE(2H) !Start Menu\Programs
CSIDL_StartMenuStartup EQUATE(7H) !Start Menu\Programs\Startup
CSIDL_Windows EQUATE(24H) !Windows Directory
CSIDL_System EQUATE(25H) !System Directory
CSIDL_ProgramFiles EQUATE(26H) !Program Files Directory
CSIDL_InternetCache EQUATE(28H) !Internet Cache Directory
SHGFP_Type_Current EQUATE(0) !The folders current path
SHGFP_Type_Default EQUATE(1) !The folders default path
!-----------------------------------------------------------------------------------------------------
! Data for PS_PathClass
!-----------------------------------------------------------------------------------------------------
PS_Path CSTRING(FILE:MAXFILENAME)
PS_Drive CSTRING(FILE:MAXFILENAME)
PS_Dir CSTRING(FILE:MAXFILENAME)
PS_Name CSTRING(FILE:MAXFILENAME)
PS_Ext CSTRING(FILE:MAXFILENAME)
!-----------------------------------------------------------------------------------------------------
! Local instance of ProSeries Path Class ( PS_PathClass )
!-----------------------------------------------------------------------------------------------------
PSPath PS_PathClass
Using the class is easy. The ProSeries templates declare an instance of the class for you as PSPath.
You call the method as a function and pass the filename or full path to it. The data you wanted is returned (unless it is not available).
Examples:
Getting the PATH
DATA
Result STRING(255)
CODE
Result = PSPath.GetFilePath( 'C:\Program Files\PathClass\Pathtest.txt' )
This example returns: C:\Program Files\PathClass\
Getting the DRIVE LETTER
DATA
Result STRING(255)
CODE
Result = PSPath.GetDriveLetter( 'C:\Program Files\PathClass\Pathtest.txt' )
This example returns: C:
Getting the FULL FILE NAME
DATA
Result STRING(255)
CODE
Result = PSPath.GetFullFileName( 'C:\Program Files\PathClass\Pathtest.txt' )
This example returns: Pathtest.txt
Getting the FILE NAME
DATA
Result STRING(255)
CODE
Result = PSPath.GetFileName( 'C:\Program Files\PathClass\Pathtest.txt' )
This example returns: Pathtest
Getting the EXTENSION
DATA
Result STRING(255)
CODE
Result = PSPath.GetExtension( 'C:\Program Files\PathClass\Pathtest.txt' )
This example returns: .txt