Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP OLE CLASS with errors
Message
From
30/05/2012 17:07:08
Victor Chignes
Inteliventas
Peru
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows 7
Miscellaneous
Thread ID:
01544802
Message ID:
01544848
Views:
33
Thanks Naomi.....that's it
>>I already commented the line but the error continues
>
>Make sure to run
>
>ON ERROR
>
>and re-test again.
>
>Also, which line of code generates the error?
>
>>>You can not do on error this.CatchError
>>>
>>>You better put call to CatchError into Error method of this class instead.
>>>
>>>>Hello All:
>>>>I have this VFP OLE class
>>>>
>>>>Define Class bIRexGenerador As Session OlePublic
>>>>
>>>>DataSession = 2 && Private Session
>>>>
>>>>PROCEDURE Generar
>>>>
>>>>PARAMETERS formatfile, outputfile,lclosefile,lsaveConfig,lAllowUserInteraction
>>>>	SET DELETED ON
>>>>	*!*	CLEAR ALL
>>>>	*!*	RELEASE ALL
>>>>	SET safety off
>>>>	*SET EXCLUSIVE ON
>>>>	SET EXCLUSIVE OFF
>>>>	CLOSE ALL
>>>>
>>>>	lcOldError = ON("ERROR")
>>>>	runId=SYS(2015)
>>>>	logId=0
>>>>	ON ERROR this.catchError()
>>>>	#include EXCEL.H
>>>>	[code]
>>>>	
>>>>ENDPROC
>>>>		
>>>>FUNCTION logs
>>>>	LPARAMETERS x
>>>>		IF ! ISNULL(oErr) AND TYPE("oErr") = "O" 
>>>>		  IF !hayError
>>>>		      ErrorEncontrado = "Error"+STR(oErr.ErrorNo)+[  LineNo: ] + STR(oErr.LineNo) +[  Message: ] + oErr.Message +[  Procedure: ] + oErr.Procedure +[  Details: ] + oErr.Details +[  StackLevel: ] + STR(oErr.StackLevel) +[  LineContents: ] + oErr.LineContents +[  UserValue: ] + oErr.UserValue 
>>>>		  ENDIF
>>>>	    ELSE
>>>>		  IF !hayError    
>>>>	    	  ErrorEncontrado =""
>>>>	      ENDIF
>>>>	      
>>>>	    ENDIF
>>>>	     
>>>>		**INSERT INTO log VALUES (x, DATETIME(), linea,user, formatfile, outputfile, ErrorEncontrado)
>>>>		INSERT INTO log VALUES (x, DATETIME(), fcRow,"Demo", formatfile, outputfile, ErrorEncontrado,RunId,LogId)
>>>>		logId=LogId+1
>>>>		hayError=.F.
>>>>		**? x 
>>>>	RETURN .t.
>>>>
>>>>ENDfunc 
>>>>
>>>>
>>>>FUNCTION GetSheet
>>>>	LPARAMETERS wbName,oXcel
>>>>	Encontrado=.f.
>>>>	FOR i=1 TO oXCEL.worksheets.Count
>>>>		IF UPPER(oXcel.worksheets(i).Name) = UPPER(wbName)
>>>>			Encontrado=.T.
>>>>			RETURN oXcel.worksheets(i)
>>>>		ENDIF
>>>>	ENDFOR
>>>>	oXcel.worksheets.ADD
>>>>	xlSheet = oXcel.activesheet
>>>>	xlSheet.NAME = wbName
>>>>
>>>>	RETURN xlSheet 
>>>>ENDfunc
>>>>
>>>>FUNCTION valor
>>>>	LPARAMETERS x
>>>>	retval=""
>>>>	IF !ISNULL(x)
>>>>		DO case
>>>>			CASE TYPE("x")="C"
>>>>				retval=x
>>>>			CASE TYPE("x")="N"
>>>>				retval=STR(x)
>>>>		ENDCASE
>>>>	ENDIF
>>>>	RETURN retval
>>>>ENDfunc
>>>>
>>>>PROCEDURE CatchError
>>>>	hayError=.t.
>>>>	ErrorEncontrado =  'error #' + transform( error() ) + ': "' + message() + '"' + 'program:  ' + Program( Program(-1)-1) + 'line #' + transform( lineno() ) + ":  " + message(1)
>>>>	=this.logs(errorencontrado)
>>>>	RETURN
>>>>ENDPROC
>>>>
>>>>ENDDEFINE
>>>>
>>>>
>>>>
>>>>It compiles and instantiates without error
>>>>When I use it the generar proc get this error:
>>>>"This can only be used in a method"
>>>>
>>>>Any help?
>>>>
>>>>Thanks in advance
Previous
Reply
Map
View

Click here to load this message in the networking platform