Hello, I was putting together something I was going to use for a type of backup routine when I came across something I think is odd. I was curious if any one might be able to explain vbscript scope to me. If you look at the attached code I have remarked my question. Basically when I call this function the function modifies my tempSource with a trailing \.
Code:
option explicit
dim tempSource
dim tempDest
dim tempPath
dim tempFolder
dim e, t, s
tempSource = "C:\Test"
tempDest = "Y:\Transfer"
tempFolder = "TempFolder"
t = tempSource & "\" & tempFolder
s = tempSource & "\" & tempFolder
msgbox t
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'some how this line modifies t and returns the modifiction. In other words if
't is set above but is returned with a trailing \.
e = Copy_AcftRecords (tempSource, t , "*.doc")
msgbox s
msgbox t
function Copy_AcftRecords(source, destination, fileExt)
dim objFSO
dim overwrite
overwrite = true
set objFSO = CreateObject("Scripting.FileSystemObject")
if objFSO.FolderExists( source ) and objFSO.FolderExists( destination ) then
if right(destination, 1) <> "\" then
destination = destination & "\"
end if
if right(source, 1) <> "\" then
source = source & "\"
end if
source = source & fileExt
objFSO.CopyFile source, destination, overwrite
Copy_AcftRecords = true
end if
Copy_AcftRecords = False
end function