|
Previous Top Next |
The File Select Class is ues to select folders or files, i.e. prime and prompt using FileDialog. It can use variables or entry controls as default values.
ITFileSelectClass Class(ITShellClass),TYPE,Module('ITFileSelectClass.clw'),Link('ITFileSelectClass',_ITUtilLinkMode_),DLL(_ITUtilDllMode_)
FileMasks &ITFileMaskQueue ! Enumerated list of filetypes
FileMask CString(2048),Private ! File mask passed
FileName CString(FILE:MaxFileName),Private
FileFlags Long,Private
wCaption CString(256),Private
DefaultPath CString(2049)
ForceDefaultPath Byte
UseShortFileNames Byte !! Applies to file/folder names returned by SelectDir and SelectFile
AddFileMask Procedure(String pName, String pMask, Byte pFree=False) ! Adds a single mask
BuildFileMask Procedure(),String
GetCaption Procedure(),String
GetFileMasks Procedure(),String
GetFileName Procedure(),String
Init Procedure(String pCaption, String pFileMasks, Long pFlags, String pDefaultPath)
ParseFileMask Procedure(String pFileMask, Byte pFree=True) ! Parses file mask
SelectDir Procedure(*? pDirName),Long,Proc
SelectDir Procedure(Long pFEQ),Long,Proc
SelectFolder Procedure(*? pDirName),Long,Proc ! Calls SelectDir
SelectFolder Procedure(Long pFEQ),Long,Proc ! Calls SelectDir
SelectFile Procedure(*CString pFileName, Byte pMulti=False, Byte pSave=False, Byte pSuggestFileName=False),BYTE,PROC
SelectFile Procedure(*String pFileName, Byte pMulti=False, Byte pSave=False, Byte pSuggestFileName=False),BYTE,PROC
SelectFile Procedure(Long pFEQ, Byte pMulti=False, Byte pSave=False, Byte pSuggestFileName=False),BYTE,PROC
SetCaption Procedure(String pCaption)
SetDefaultDir Procedure(String pDefaultPath)
SetDefaultFolder Procedure(String pDefaultPath)
SetDefaultPath Procedure(String pDefaultPath, Byte pDefaultProgramPath=1)
SetFileMask Procedure(String pFileMasks) ! Calls ParseFileMask
SetFileName Procedure(String pFileName)
SetForceDefaultpath Procedure(Byte pForce=True)
SetUseLongNames Procedure !!Sets UseShortFileNames to False
SetUseShortNames Procedure !!Sets UseShortFileNames to True
Construct Procedure
Destruct Procedure
End
Example - Select a file:
FS ITFileSelectClass
Code
FS.AddFileMask('INI File','*.ini',True)
FS.AddFileMask('All Files','*.*.')
FS.SetDefaultPath(INIMgr.Fetch('UpdateGetFromINI','FS:INIFilename'))
FS.SetForceDefaultPath()
FS.SetCaption('Select INI File') !! Set FileDialog caption
FS.SelectFile(?Loc:IniFileName) !! Use control on window
!!Or
FS.SelectFile(Loc:IniFileName) !! Use variable
INIMgr.Update('UpdateGetFromINI','FS:INIFilename',FS.GetFilePart(Loc:IniFileName,FNS_FullPath))
Example - Select a folder:
FS ITFileSelectClass
Code
FS.SetDefaultPath(INIMgr.Fetch('UpdateGetFromINI','FS:INIFilename'))
FS.SetUseShortNames !! Force use of short filenames, use SetUseLongNames for long file names
FS.SelectDir(?Loc:IniFileName) !! Use the FEQ from an entry field. SelectFolder is alternate method name
!! Or:
FS.SelectDir(Loc:IniFileName) !! Use a variable
INIMgr.Update('UpdateGetFromINI','FS:INIFilename',FS.GetFilePart(Loc:IniFileName,FNS_FullPath))
Example - Build file mask string to use with FileDialog:
FS ITFileSelectClass
F CString(1025)
Code
FS.AddFileMask('INI File','*.ini',True) !! Start a new FileMask string
FS.AddFileMask('Text File','*.txt.')
FS.AddFileMask('CSV File','*.csv.')
FS.AddFileMask('All Files','*.*.')
!! FS.BuildFileMask() will now return the following string:
!! 'INI File|*.ini|Text File|*.txt|CSV File|*.csv|All Files|*.*'
If FileDialog('Select file',F,FS.BuildFileMask(),FILE:KeepDir+FILE:LongName)
End
Code example from Build Automator - Selecting DLLs:
FS FileSelectClass
Code
FS.AddFileMask('DLL files (*.dll)','*.dll',True)
If Loc:DLL
FS.SetDefaultPath(Loc:DLL)
Else
FS.SetDefaultPath(INIMgr.Fetch('UpdateCallDLL','FS:DLLPath'))
End
FS.SelectFile(?Loc:DLL,False, False)
INIMgr.Update('UpdateCallDLL','FS:DLLPath',FS.GetFilePart(Loc:DLL,FNS_FullPath))
Code example from Build Automator - Selecting MS-Build command line processor:
FS FileSelectClass
Code
If Not Loc:MSBuildCommandLine
FS.SetDefaultFolder(ITS.GetSpecialFolder(IT_CSIDL_WINDOWS) & '\Microsoft.NET\Framework')
End
FS.AddFileMask('MSBuild', 'MSBuild.exe', True) ! Adds a single mask
FS.SelectFile(?Loc:MSBuildCommandLine)
Code example from Build Automator - Selecting and processing multiple file selections:
ITU ITUtilityClass
FS ITFileSelectClass
ITC ITClarionClass
ITS ITStringClass
Code
FS.AddFileMask('Clarion Application (*.app;*.prj)','*.app;*.prj',True)
FS.SetDefaultPath(INIMgr.Fetch('UpdateClarionCompileFile','FS:Clarion Application'))
R = FS.SelectFile(Fn,True)
If R
R = ITU.MultiFileSelect(Clip(Fn))
If R
Sort(Loc:Applications,Loc:Applications.Loc:AppFile)
LineN = Records(Loc:Applications)
Loop I = R To 1 By -1
Get(ITU.MSQ,I)
Loc:Applications.Loc:AppFile = ITU.MultiFileSelPath & ITU.MSQ.MSFileN
Get(Loc:Applications,Loc:Applications.Loc:AppFile)
If ErrorCode()
LineN += 1
Clear(Loc:Applications)
Loc:Applications.Loc:LineNr = LineN
Loc:Applications.Loc:AppFile = ITU.MultiFileSelPath & ITU.MSQ.MSFileN
TargetFile = ITC.GetFilePart(Loc:Applications.Loc:AppFile,FNS_FullPath) & '\' & ITC.GetTargetName(Loc:Applications.Loc:AppFile)
If TargetFile
Loc:Applications.Loc:DestFile = TargetFile
Else
Loc:Applications.Loc:DestFile = ''
End
Add(Loc:Applications,Loc:Applications.Loc:AppFile) !! Add to maintain filename sorting
End
End
Sort(Loc:Applications,Loc:Applications.Loc:LineNr)
INIMgr.update('UpdateClarionCompileFile','FS:Clarion Application',ITU.MultiFileSelPath)
End
End