📄 cfiles.prg
字号:
*} Library: CFILES.PRG
*} Class: CFileRepository
*} Method: GetFileList()
*-------------------------------------------------------
*) Description: Returns the list of files in the
*) file list table in the format indicated by the
*) cMessagingType property.
*------------------- Usage Section ---------------------
*$ Scope:
*$ Parameters: rxFileList - An empty string passed by
*$ reference. Will be populated
*$ with the file list.
*$ Usage:
*$ Returns: Logical
*$ Notes:
*-------------------------------------------------------
*! Copyright:
*! Flash Creative Management, Inc., 1999
*! Author: Michael G. Emmons
*! Architect: Michael G. Emmons
*-------------------------------------------------------
PROCEDURE GetFileList(rxFileList)
LOCAL llRetVal
DO CASE
CASE THIS.cMessagingType = "Array"
llRetVal = THIS.GetFileListInArrayFormat(@rxFileList)
CASE THIS.cMessagingType = "XML"
llRetVal = THIS.GetFileListInXMLFormat(@rxFileList)
CASE THIS.cMessagingType = "ADO"
llRetVal = THIS.GetFileListInADOFormat(@rxFileList)
OTHERWISE
*-- Something just ain't right.
llRetVal = .F.
ENDCASE
RETURN llRetVal
ENDPROC
*///////////////////////////////////////////////////////
*---------------- Location Section ---------------------
*} Library: CFILES.PRG
*} Class: CFileRepository
*} Method: GetFileListInArrayFormat()
*-------------------------------------------------------
*) Description: Returns the list of files in the
*) file list table in the form of an array.
*------------------- Usage Section ---------------------
*$ Scope:
*$ Parameters: rxFileList - An empty string passed by
*$ reference. Will be populated
*$ with the file list.
*$ Usage:
*$ Returns: Numeric
*$ Notes:
*-------------------------------------------------------
*! Copyright:
*! Flash Creative Management, Inc., 1999
*! Author: Michael G. Emmons
*! Architect: Michael G. Emmons
*-------------------------------------------------------
PROTECTED PROCEDURE GetFileListInArrayFormat(rxFileList)
LOCAL lnRetVal, lnSelected, lnCount
lnRetVal = THIS.GetFileCount()
IF lnRetVal > 0
DIMENSION rxFileList[lnRetVal, 2]
lnCount = 0
lnSelected = SELECT(0)
SELECT (THIS.cFileTable)
SCAN FOR NOT DELETED()
lnCount = lnCount + 1
rxFileList[lnCount, 1] = Filename
rxFileList[lnCount, 2] = FilenameEx
ENDSCAN
ENDIF
RETURN lnRetVal
ENDPROC
*///////////////////////////////////////////////////////
*---------------- Location Section ---------------------
*} Library: CFILES.PRG
*} Class: CFileRepository
*} Method: GetFileListInXMLFormat()
*-------------------------------------------------------
*) Description: Returns the list of files in the file
*) list table in the form of XML.
*------------------- Usage Section ---------------------
*$ Scope:
*$ Parameters: rxFileList - An empty string passed by
*$ reference. Will be populated
*$ with the file list.
*$ Usage:
*$ Returns: Logical
*$ Notes:
*-------------------------------------------------------
*! Copyright:
*! Flash Creative Management, Inc., 1999
*! Author: Michael G. Emmons
*! Architect: Michael G. Emmons
*-------------------------------------------------------
PROTECTED PROCEDURE GetFileListInXMLFormat(rxFileList)
LOCAL llRetVal
RETURN llRetVal
ENDPROC
*///////////////////////////////////////////////////////
*---------------- Location Section ---------------------
*} Library: CFILES.PRG
*} Class: CFileRepository
*} Method: GetFileListInADOFormat()
*-------------------------------------------------------
*) Description: Returns the list of files in the file
*) list table in the form of ADO.
*------------------- Usage Section ---------------------
*$ Scope:
*$ Parameters: rxFileList - An empty string passed by
*$ reference. Will be populated
*$ with the file list.
*$ Usage:
*$ Returns: Logical
*$ Notes:
*-------------------------------------------------------
*! Copyright:
*! Flash Creative Management, Inc., 1999
*! Author: Michael G. Emmons
*! Architect: Michael G. Emmons
*-------------------------------------------------------
PROTECTED PROCEDURE GetFileListInADOFormat(rxFileList)
LOCAL llRetVal
RETURN llRetVal
ENDPROC
*///////////////////////////////////////////////////////
*---------------- Location Section ---------------------
*} Library: CFILES.PRG
*} Class: CFileRepository
*} Method: GetFileCount()
*-------------------------------------------------------
*) Description: Returns the number of files in the
*) file table.
*------------------- Usage Section ---------------------
*$ Scope:
*$ Parameters:
*$ Usage:
*$ Returns: Numeric
*$ Notes:
*-------------------------------------------------------
*! Copyright:
*! Flash Creative Management, Inc., 1999
*! Author: Michael G. Emmons
*! Architect: Michael G. Emmons
*-------------------------------------------------------
PROCEDURE GetFileCount()
RETURN THIS.nFileCount
ENDPROC
*///////////////////////////////////////////////////////
*---------------- Location Section ---------------------
*} Library: CFILES.PRG
*} Class: CFileRepository
*} Method: ZapFileTable()
*-------------------------------------------------------
*) Description: Removes all files from the file table
*------------------- Usage Section ---------------------
*$ Scope:
*$ Parameters:
*$ Usage:
*$ Returns: Logical
*$ Notes:
*-------------------------------------------------------
*! Copyright:
*! Flash Creative Management, Inc., 1999
*! Author: Michael G. Emmons
*! Architect: Michael G. Emmons
*-------------------------------------------------------
PROCEDURE ZapFileTable()
LOCAL lnSelected
lnSelected = SELECT(0)
SELECT (THIS.cFileTable)
ZAP
THIS.nFileCount = 0
SELECT (lnSelected)
ENDPROC
*///////////////////////////////////////////////////////
*---------------- Location Section ---------------------
*} Library: CFILES.PRG
*} Class: CFileRepository
*} Method: SelfTest()
*-------------------------------------------------------
*) Description: Tests the various methods of the class.
*------------------- Usage Section ---------------------
*$ Scope:
*$ Parameters:
*$ Usage:
*$ Returns: Logical
*$ Notes:
*-------------------------------------------------------
*! Copyright:
*! Flash Creative Management, Inc., 1999
*! Author: Michael G. Emmons
*! Architect: Michael G. Emmons
*-------------------------------------------------------
PROCEDURE SelfTest()
LOCAL llRetVal, lnFileCount, laFiles
IF FILE("CFILES_SELFTEST.DBF")
ERASE("CFILES_SELFTEST.DBF")
ENDIF
IF !FILE("CFILES_SELFTEST1.PRG")
STRTOFILE( "THIS FILE USED FOR TESTING PURPOSES ONLY", "CFILES_SELFTEST1.PRG", .T. )
ENDIF
IF !FILE("CFILES_SELFTEST2.PRG")
STRTOFILE( "THIS FILE USED FOR TESTING PURPOSES ONLY", "CFILES_SELFTEST2.PRG", .T. )
ENDIF
THIS.cFileTable = "SELFTEST.DBF"
THIS.OpenFileTable()
THIS.ZapFileTable()
llRetVal = THIS.AddFile("CFILES_SELFTEST1.PRG", "CFILES_SELFTEST1.PRG") AND ;
THIS.AddFile("CFILES_SELFTEST2.PRG", "CFILES_SELFTEST2.PRG")
IF !llRetVal
RETURN .F.
ENDIF
lnFileCount = THIS.GetFileCount()
IF lnFileCount # 2
RETURN .F.
ENDIF
THIS.RemoveFile("CFILES_SELFTEST1.PRG")
lnFileCount = THIS.GetFileCount()
IF lnFileCount # 1
RETURN .F.
ENDIF
THIS.AddFile("CFILES_SELFTEST1.PRG", "CFILES_SELFTEST1.PRG")
THIS.AddFile("CFILES_SELFTEST1.PRG", "CFILES_SELFTEST1.PRG")
THIS.AddFile("CFILES_SELFTEST1.PRG", "CFILES_SELFTEST1.PRG")
THIS.GetFileList(@laFiles)
llRetVal = THIS.AddFile("CFILES_SELFTEST1.PRG", "CFILES_SELFTEST1.PRG")
IF llRetVal
RETURN .F.
ENDIF
llRetVal = THIS.RemoveFile("CFILES_SELFTEST3.PRG")
IF llRetVal
RETURN .F.
ENDIF
llRetVal = THIS.ContainsFile("CFILES_SELFTEST3.PRG")
IF llRetVal
RETURN .F.
ENDIF
llRetVal = THIS.ContainsFile("CFILES_SELFTEST1.PRG")
IF NOT llRetVal
RETURN .F.
ENDIF
RETURN .T.
ENDPROC
*///////////////////////////////////////////////////////
ENDDEFINE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -