Welcome! Log In Create A New Profile

Advanced

WD11: Error Management

Posted by Udo 
Udo
WD11: Error Management
July 11, 2008 09:23AM
Hello

I write a new function. This function fill a Winword-Document.
This docoment has over 100 "FormField"-values.

I fill this "FormField" with:
s_MyDok>>content>>FormFields("MyAdress")>>result = "Hello"

s_MyDok>>content>>FormFields("Phone")>>result = "4711"

if all fields defined in the word-document then work this function without problems.

BUT

delete the customer one formfield in the Word-document, for example "MyAdress", then WINDEV give me a error-message.

I do not need this message. I want: Windev should ignore this error and continue with the next line.

In VB I have a statement: on error resume next.

I search a similar statement in WD.

Thanks for answers.
Udo
Sohan
Re: WD11: Error Management
July 11, 2008 12:33PM
Hi,

Check out "If Error: by program" and "When Exception: by program" which are in the header of each and every code section (a bit to the right, in blue, underlined). You can click on them.

/sohan
Udo
Re: WD11: Error Management
July 11, 2008 02:40PM
Hi Sohan
I have clicked the "When Exception" in the header line.
In my code is:
--
s_MyDok>>content>>FormFields("MyAdress")>>result = "Hello"
s_MyDok>>content>>FormFields("Phone")>>result = "4711"


CASE EXCEPTION:
IF ExceptionInfo(errCode) = 2205 then // field not found

END
--

If the FormField("MyAdress") is not in the Word-Doc, I get the errorcode 2205. That is fine.
I want ignore this and execute with the next code-line. (Here: s_MyDok>>content>>FormFields("Phone")>>result = "4711")

At the moment the programm leave the procedure if one field not in the word-Doc.

How can I tell WD: ignore the error and execute the next code line.

Piet van Zanten
Re: WD11: Error Management
July 11, 2008 05:45PM
Hi Udo,

Try this:
WHEN EXCEPTION IN
	s_MyDok>>content>>FormFields("MyAdress")>>result = "Hello"
DO
	//nothing	
END
WHEN EXCEPTION IN
        s_MyDok>>content>>FormFields("Phone")>>result = "4711"
DO
	//nothing	
END
You could save a lot of lines of code if you put your fieldnames and content in an array (look at StringToArray):
FOR i=1 _TO_ ArrayInfo(ar_FieldNames,tiDimension)
       WHEN EXCEPTION IN
	       s_MyDok>>content>>FormFields(ar_FieldNames)>>result = ar_FieldContent
       DO
	       //nothing	
       END
END
Best regards,
Piet
Sohan
Re: WD11: Error Management
July 11, 2008 06:38PM
Hi,

I would prefer:

WHEN EXCEPTION IN
	s_MyDok>>content>>FormFields(ar_FieldNames)>>result = ar_FieldContent
DO
	IF ExceptionInfo(errCode) = 2205 THEN
		// field not found; do nothing
	ELSE
		Error(ExceptionInfo(errFullDetails))
	END
END

Be carefull not to hide any errors you did NOT expect.

/sohan
Udo
Re: WD11: Error Management
July 11, 2008 06:55PM
Hi Sohan Hi Piet

Thanks for suggestions.

Udo
Piet van Zanten
Re: WD11: Error Management
July 11, 2008 08:28PM
Hi Sohan,

In principle you are right. On the other hand, there's not much error processing one can do if the substitution fails. And the end-user will not be happy clicking away continuous error screens.

Best regards,
Piet
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: