Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
;#
;# Author : PReS Connections
;# : http://www.presconnections.com
;#
;# File name : PRSFile.pdi
;# Version : 1.0
;# Date : 02nd September 2009
;#
;# Purpose : PRSFILE.dll examples
;#
;###########################################################
RECORD
INTERNAL
START
aFrom = "C:\\\\Test.txt"
aTo = "C:\\\\Temp\\\\Test.txt"
; Call subrouitne
nResult = GOSUB PRSFile(aFrom, aTo, 100)
PROMPT aReturnMessage
EXIT
;###########################################################
;#
;# SUBROUTINE PRSFile (Source file, Destination file, Action)
;#
;# Action Description
;# ====== ==========================================================
;# 100 Copy file
;# Copies the nominated file. The destination may be the current
;# directory, or a different drive/directory (providing it is valid).
;#
;# 101 Move file
;# Moves the nominated file. The destination may be the current
;# directory, or a different drive/directory (providing it is valid).
;#
;# 102 Rename file
;# Renames the current file. By definition, the assumption is that the
;# destination file is in the same directory (otherwise, a Move function
;# could have been used instead).
;#
;# 103 If - exist
;# This function tests to see if the nominated file is present.
;#
;#
;# 104 Get file info
;# This function retrieves information on the file: including size,
;# read/write access and date/time stamp. This function records information
START
n_USERHOOK[5] = 0
USERHOOK "PRSFile" , n_USERHOOK, a_source, a_FileInfo
; File size
n_FileSzie = n_USERHOOK[2]
; Read access indicator: 1 = TRUE, 0 = FALSE
n_ReadAccess = n_USERHOOK[3]
; Write access indicator: 1 = TRUE, 0 = FALSE
n_WriteAccess = n_USERHOOK[4]
; Date Created
n_USERHOOK[5] = 1
USERHOOK "PRSFile" , n_USERHOOK, a_source, a_FileInfo
a_Created = a_FileInfo
BREAK
CASE (111)
; Append file
; Allows the attachment of a file. See the topic, Append File for more
information
BREAK
DEFAULT
BREAK
}
GOSUB CheckReturnCode(n_USERHOOK[1])
RETURN(n_USERHOOK[1])
;###########################################################
;#
;# SUBROUTINE CheckReturnCode (PRSFILE return Code)
;#
;###########################################################
NUMERIC n_code
START
SWITCH (n_code){
CASE (0)
aReturnMessage = "Success"
BREAK
CASE (1)
aReturnMessage = "Source file doesn't exist"
BREAK
CASE (2)
aReturnMessage = "Target file exists"
BREAK
CASE (3)
aReturnMessage = "File/Path not found"
BREAK
CASE (4)
aReturnMessage = "Cannot move to a different device"
BREAK
CASE (5)
aReturnMessage = "Unknown error"
BREAK
CASE (6)
aReturnMessage = "Invalid function code"
BREAK
CASE (7)
aReturnMessage = "Error accessing file"
BREAK
CASE (8)
aReturnMessage = "Memory allocation error"
BREAK
CASE (9)
aReturnMessage = "Missing second filename"
BREAK
CASE (10)
aReturnMessage = "Target and source are the same"
BREAK
CASE (11)
aReturnMessage = "Directory is not empty"
BREAK
CASE (12)
aReturnMessage = "Insufficient space for return string"
BREAK
CASE (13)
aReturnMessage = "Target device full"
BREAK
CASE (14)
aReturnMessage = "Printer error"
BREAK
CASE (15)
aReturnMessage = "Network error"
BREAK
DEFAULT
aReturnMessage = "No message available"
BREAK
}
RETURN