mibuso.com

Microsoft Business Solutions online community
It is currently Sat May 25, 2013 9:48 pm

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: How simply to do "try-except" in NAV
PostPosted: Thu Oct 25, 2007 9:19 am 
Offline

Joined: Wed May 10, 2006 11:25 am
Posts: 149
Location: Kiev
Country: Ukraine (ua)
Hi
I propose simple method for catch an errors in NAV.

Need such Automation:
VBScript Automation 'Microsoft Script Control 1.0'.ScriptControl

Example:


IF NOT ISCLEAR(VBScript) THEN
CLEAR(VBScript);
CREATE(VBScript);

VBScript.Language := 'VBScript';

Source := STRSUBSTNO('' +
'Function TryExceptMethod' + '%1%1' +
' On Error Resume Next' + '%1%1' +
' TryExceptMethod = FALSE' + '%1%1' +
' a = 10 %2 0' + '%1%1' + // except!!!
' IF Err.Number = 0 THEN' + '%1%1' +
' TryExceptMethod = TRUE' + '%1%1' +
' END IF' + '%1%1' +
'End Function','#','\')
;

WHILE STRPOS(Source,'##') > 0 DO BEGIN
Source[STRPOS(Source,'#')] := 13;
Source[STRPOS(Source,'#')] := 10;
END;

VBScript.AllowUI := FALSE;
VBScript.AddCode(Source);
MESSAGE('Result = %1',VBScript.Eval('TryExceptMethod'));

CLEAR(VBScript);

The kernel of the problem:
Use a VBScript (JScript) Automation and command "On Error Resume Next".

p.s. you can pass a variables from NAV to VBScript like Automation etc... so VBScript.AddObject('objConnection',ADOConnection);
and execute all methods it from script.

Goog luck!!!

_________________
Yaroslav Gaponov


Top
 Profile E-mail WWW  
 
 Post subject:
PostPosted: Thu Oct 25, 2007 10:28 pm 
Offline

Joined: Thu Jul 17, 2003 10:52 pm
Posts: 638
Location: Capelle a/d IJssel
Country: Netherlands (nl)
This way you circumvent the error in NAV?

_________________
Create dynamic Excel or Word documents, ReportX


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 26, 2007 8:33 am 
Offline

Joined: Wed May 10, 2006 11:25 am
Posts: 149
Location: Kiev
Country: Ukraine (ua)
Hi

I use like solution for catch an errors for work with ADO Automation when I need to get a list databases on server. If some database in suspend status than user show an errors.

So if you need catch an errors for some Automation you can pass it as variable to script and execute the problem method.

_________________
Yaroslav Gaponov


Top
 Profile E-mail WWW  
 
 Post subject: Hi
PostPosted: Fri Oct 26, 2007 10:57 am 
Offline

Joined: Tue Aug 07, 2007 11:06 am
Posts: 22
Location: New Delhi
Country: India (in)
Hi

I have Compiled the code U have provided.
Fine But I did't able to understand How the 'Add Object' thing works.
I have added for ADO connection the Automation Variable 'Microsoft Active X Control Object Library 2.7'.

Can you Plz Explain How we able to track errors with this code.

Regards
Kiran.

_________________
Hi


Top
 Profile  
 
 Post subject: Re: Hi
PostPosted: Fri Oct 26, 2007 11:25 am 
Offline

Joined: Wed May 10, 2006 11:25 am
Posts: 149
Location: Kiev
Country: Ukraine (ua)
Hi

I think all clear in this example.

CREATE(objConnection);
objConnection.[SOME_PARAMETERS] := [SOME_VALUES]
...
VBScript.AddObject('objConnectionXXX',objConnection);
...
Source := STRSUBSTNO('' +
'Function Test' + '%1%1' +
' Test = FALSE' + '%1%1' +
' On Error Resume Next' + '%1%1' +
' objConnectionXXX.[SOME_METHOD_FOR_EXAMPLE]' + '%1%1' +
' IF Err.Number = 0 THEN' + '%1%1' +
' Test = TRUE' + '%1%1' +
' END IF' + '%1%1' +
'End Function','#')
;

...

_________________
Yaroslav Gaponov


Top
 Profile E-mail WWW  
 
 Post subject: Re: How simply to do "try-except" in NAV
PostPosted: Tue Sep 28, 2010 6:03 pm 
Offline

Joined: Fri Dec 01, 2006 12:01 pm
Posts: 156
Location: London
Country: United Kingdom (uk)
=D> =D> =D> =D>
I just want to say you are a very clever guy Yaroslav!
Thank you for sharing!

_________________
Why don't you try my compare tool?
http://www.mibuso.com/dlinfo.asp?FileID=1123


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to: