Hi Greg,
Sounds like a good idea, I like it. If I would have some code in Error method of my object, would it still work?
Thanks.
>Hi Nadya,
>
>I see you are using VFP 8.0.
>
>Well TRY CATCH to the rescue.
>
>Do not have the obect destory itself premiturely. Perform it as a FINALLY operation and let the CATCH blocks process any errors the process throws.
>
>
>SET STEP ON
>
>*-- Create the Object.
>ox = CREATEOBJECT("DoThis")
>
>TRY
> *-- Run your process
> ox.RunThis()
>
>CATCH TO oError
> *-- Process the error message
> *-- The ErrorNo will always be 1098
> ? oError.Message
>FINALLY
> *-- Release the Object.
> ox=null
>ENDTRY
>
>*================
>
>DEFINE CLASS doThis as Custom
>
> PROCEDURE RunThis
> *-- do somthing and fail.
> LOCAL i
> *-- start of method
> FOR i=1 TO 10
> ?? "."
> NEXT
>
> *-- something happens, and the method fails,
> *-- so call ERROR with your cError message
> ERROR "My method failed"
>
> *-- Because the ERROR raised the error, and the CATCH caught it.
> *-- This part of the method is not ran.
> FOR i=1 TO 10
> ?? "."
> NEXT
>
> ENDPROC
>
>ENDDEFINE
>
>
>
>
>>Hi everybody,
>>
>>I'm creating a custom class called BusinessProcess. In this class I'm going to have RunProcess method. If some error conditions occur, I want to be able to stop the process immediatelly.
>>
>>I have cError property. If I set this property to something, it means, I have an error and want to stop. My question is: is it advisable to create a custom Release method (call Destroy() in it) and call this method in cError_Assign?
>>
>>Or there are better ideas?
>>
>>Thanks in advance.
If it's not broken, fix it until it is.
My Blog