udfFileAdd
bln udfFileAdd (str, str, str)
;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfFileAdd (strFileInA, strFileInB, strFileOut)
If strFileOut == "" Then Return @FALSE ; We must have at least the new file name.
intSizeA = FileSize (strFileInA)
intSizeB = FileSize (strFileInB)
Switch @TRUE
Case intSizeA == 0 && intSizeB == 0
   Return @FALSE
Case intSizeA == 0 && intSizeB > 0
   Return FileCopy (strFileInB, strFileOut, @FALSE)
Case intSizeA > 0 && intSizeB == 0
   Return FileCopy (strFileInA, strFileOut, @FALSE)
Case intSizeA > 0 && intSizeB > 0
   If FileCopy (strFileInA, strFileOut, @FALSE) Then Return FileAppend (strFileInB, strFileOut)
EndSelect
Return @FALSE
;..........................................................................................................................................
; This UDF concatenates two files into a newly created combined file.
; The return value is a boolean @TRUE or @FALSE to indicate if the process was done succesfully or not.
;
; Detlev Dalitz.20010713.20090716.
;..........................................................................................................................................
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------


; Test.

; Create test environment.
strFileInA = FileCreateTemp ("_A_")
strFileInB = FileCreateTemp ("_B_")
strFileOut = FileCreateTemp ("_C_")

; We use this script to create test data.
strThisFile = IntControl (1004, 0, 0, 0, 0)
blnResult = FileCopy (strThisFile, strFileInA, @FALSE)
blnResult = FileCopy (strThisFile, strFileInB, @FALSE)

For intTestcase = 1 To 5
   Switch intTestcase
   Case 1
      blnResult = udfFileAdd (strFileInA, strFileInB, strFileOut)
      Break
   Case 2
      blnResult = udfFileAdd ("", strFileInB, strFileOut)
      Break
   Case 3
      blnResult = udfFileAdd (strFileInA, "", strFileOut)
      Break
   Case 4
      blnResult = udfFileAdd ("", "", strFileOut)
      Break
   Case 5
      blnResult = udfFileAdd ("", "", "")
      Break
   EndSelect

   strMsgTitle = "Demo: udfFileAdd (strFileInA, strFileInB, strFileOut)"
   strMsgText = "Test" : intTestcase : @TAB : "blnResult=" : blnResult
   Display (2, strMsgTitle, strMsgText)
   If FileExist (strFileOut)
      RunZoomWait ("notepad.exe", strFileOut) ; Take a look and wait for closing notepad.
      blnResult = FileDelete (strFileOut)
   Else
      Display (2, strMsgTitle, "No file to view ...")
   EndIf
Next

; Cleaning.
blnResult = FileDelete (strFileInA)
blnResult = FileDelete (strFileInB)
blnResult = FileDelete (strFileOut)
Exit
;------------------------------------------------------------------------------------------------------------------------------------------