For some unknown reason do get IDispatch pointer errors.

 Code:
	$ListOfFiles = dirplus($TaskSource,"/a-d /s /m .log") 	
	WriteLog("Retrieving list op log files on Belsrv0101")
	FOR Each $File In $ListOfFiles
		WriteLog("Processing TechDoc File " + $File,1)
		WriteLog($Stars,1)
		$NUL = OPEN (6, $File)
		$CurrentFile = Readline(6)
		$CurrentFile1 = ""
			WHILE @ERROR = 0
			$CurrentFile = Substr($CurrentFile,2, LEN($CurrentFile)-2)
		
			IF (INSTRREV($CurrentFile, " ")) > 0
				$CurrentFileHasSpace = 1
			ENDIF
			WriteLog("TechDocFile " + $CurrentFile,1)

			IF (EXIST ("I:\Data\PRJ" + SUBSTR($CurrentFile,3)))
				$CurrentFile1 = "I:\Data\PRJ" + SUBSTR($CurrentFile,3)
				$CurrentFile2 = REPLACE ($CurrentFile,"Q:\","Z:\")
			ENDIF	

			IF (EXIST ("H:\Data\PRJ" + SUBSTR($CurrentFile,3)))
				$CurrentFile1 = "H:\Data\PRJ" + SUBSTR($CurrentFile,3)
				$CurrentFile2 = REPLACE ($CurrentFile,"Q:\","Z:\")
			ENDIF	

			IF (EXIST ($KSBE01_Prop + SUBSTR($CurrentFile,3)))
				$CurrentFile1 = REPLACE ($CurrentFile,"O:","X:")
				$CurrentFile2 = REPLACE ($CurrentFile,"O:","Y:")
			ENDIF

			IF LEN($CurrentFile1) < 2
				WriteLog("***** Could not find source location " + $CurrentFile,1)
			ENDIF

			IF NOT EXIST($CurrentFile1) 
				WriteLog("***** Could not find source file " + $CurrentFile1 + " *****",1)
			ELSE
				IF NOT EXIST (SUBSTR($CurrentFile2,1,INSTRREV($CurrentFile2, "\")))
					ChkDir2(SUBSTR($CurrentFile2,1,INSTRREV($CurrentFile2, "\")-1)) 
				ENDIF
				IF $CurrentFileHasSpace = 1
					$CurrentFile1 = Chr(34) + $CurrentFile1 + Chr(34)
					$CurrentFile2 = Chr(34) + $CurrentFile2 + Chr(34)
					$CurrentFileHasSpace = 0
					WriteLog("TechDocFile does contain space(s), adding quotes for copy" ,1)
				ENDIF
				WriteLog("COPY " + $CurrentFile1  + " " + $CurrentFile2,1)
				COPY $CurrentFile1 $CurrentFile2

			ENDIF
			$CurrentFile = Readline(6)
		LOOP
		$NUL = CLOSE (6)

		
		WriteLog("Moving " + $File + " to location " + $BELSRV0112_TD_FileCopy,1) 

		MOVE $File $BELSRV0112_TD_FileCopy 
		WriteLog($Stars,1)
		$Start_TD2 = TimeValue("Start_TD2")
		IF $Start_TD1 <> $Start_TD2
			WriteLog( "Processing time file " + Cstr($File)  + " => " + TimeDiff($Start_TD1,$Start_TD2),1)
		ENDIF

		$Start_TD1 = TimeValue("Start_TD1")	
		WriteLog($Stars,1)
	NEXT


The script does retrieve a list of files with each do contain some info which datafiles to copy. This retrieve & copy part does work well however when i write to the logfile again with the parameter $File it goes wrong.

This works
 Code:
WriteLog("Processing TechDoc File " + $File,1)

However further on the same script i get IDispatch error on this line
 Code:
WriteLog( "Processing time file " + Cstr($File)  + " => " + TimeDiff($Start_TD1,$Start_TD2),1)


When i start the script from the command line with the code it works
 Code:
		IF $Start_TD1 <> $Start_TD2
		  $DisplayStr = "Processing time file " + $File 
		  $NUL = $DisplayStr     ;Resolves IDispatch pointers not allowed in expressions
			WriteLog( $DisplayStr + " => " + TimeDiff($Start_TD1,$Start_TD2),1)
		ENDIF

however when i tokenise the script i do get back the same error


Edited by Dynamite Dan (2015-03-24 09:42 AM)