Page 1 of 1 1
Topic Options
#210155 - 2015-03-24 09:38 AM IDispatch pointers not allowed in expressions
Dynamite Dan Offline
Fresh Scripter

Registered: 2003-04-29
Posts: 20
Loc: België
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)

Top
#210156 - 2015-03-24 10:50 AM Re: IDispatch pointers not allowed in expressions [Re: Dynamite Dan]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
See if changing $file to $file.name helps.
_________________________
(... better days ahead)

Top
#210157 - 2015-03-24 11:51 AM Re: IDispatch pointers not allowed in expressions [Re: Allen]
Dynamite Dan Offline
Fresh Scripter

Registered: 2003-04-29
Posts: 20
Loc: België
Following lines don't produce any output, however the program does not stop with the error See last comment

 Code:
		IF $Start_TD1 <> $Start_TD2
			WriteLog( "Processing time file  => " + $File.Name + TimeDiff($Start_TD1,$Start_TD2),1)
		ENDIF


Edited by Dynamite Dan (2015-03-24 03:21 PM)

Top
#210158 - 2015-03-24 01:05 PM Re: IDispatch pointers not allowed in expressions [Re: Dynamite Dan]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
When you say any output you mean that it no longer logs anything?
_________________________
!

download KiXnet

Top
#210159 - 2015-03-24 02:10 PM Re: IDispatch pointers not allowed in expressions [Re: Lonkero]
Dynamite Dan Offline
Fresh Scripter

Registered: 2003-04-29
Posts: 20
Loc: België
Yes, i wrote some functions in seperate modules that i load in a main script (if used)

This is the function
 Code:
Function WriteLog($LogMessage, optional $ScreenLog)
	$LogLine = $CurrentDate + " " + @TIME + " " + $LogMessage
	IF $ScreenLog <> 2
		$NUL = WRITELINE (5,$LogLine + @CRLF)
	ENDIF
	IF $ScreenLog > 0
		? $LogLine
	ENDIF
EndFunction


In the script i load the functions first from the logondrive
 Code:
Call @LDRIVE + "Fnt_Writelog.kx"


This Writelog function does allow me to chose which info is diplayed and/or logged.

I was mistaking in my previous post because i did not reviewed the latest logfile.
Using the $file.Name parameter does provide the name (in string context) to the logfile.



Edited by Dynamite Dan (2015-03-24 03:23 PM)

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.139 seconds in which 0.11 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org