Dealing with errors caused by external script

9 posts / 0 new
Last post
laura.garner
Offline
Joined: 09/04/2014 - 19:12
Dealing with errors caused by external script

Hi,
I have a master script that calls smaller scripts using Client.RunIDEAScriptEx. Every  now and then (and more often than I'd like), something has changed which causes one of the scripts to fail - often it is something to do with the source data, but not always.
I have a simple error handler in both master and called scripts to give me a message about what went wrong and stop running the script. The problem is, my master script just pops up a message which tells me the called script failed and then it keeps running. It seems like the master script doesn't recognise the problem as an actual error, so it just keeps going.
How do I get my master script to stop if the called script has an error?
Any help is greatly appreciated.
RegardsLaura

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Laura and welcome to the site.

There is a function called Client.RunIDEAScriptRV which is suppose to be able to return values from the second script.  Per the IDEA 8.5 documentation:

Run another IDEAScript and return four variables to the caller. In order for values to be returned, the called script must assign the values back to the global constants arg1, arg2, arg3, and arg4, repsectively.

Unfortunately I can't seem to get it to work, I will have to check to see if the version 9 documentation is any better on this one.

Another option is to write a text file on your harddrive saying that the script failed, each time you return from a secondary script the main script tests to see if the text file exists and if it does it aborts the other tests.  If you want to try this out let me know and I can help you with the code if you wish.  I will also see if V9 has better documentation on using the Client.RunIDEAScriptRV function.

laura.garner
Offline
Joined: 09/04/2014 - 19:12

Thanks Brian. I also couldn't get Client.RunIDEAScriptRV to work, so I'm glad it wasn't just me! I can certainly use the text file work around, and if you manage to get the RV script to return values I'd love to know.
Thanks again
Laura

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Laura,

I tried playing with it again on V9 last night and couldn't get it to work.  When I have a chance I will try and get an answer from one of the gurus at IDEA on how it should function.  Until then using a text file is probably the only way around it.

Thanks

Brian

laura.garner
Offline
Joined: 09/04/2014 - 19:12

Thanks Brian. I've already put together the script to use the text file as a prompt, so I will use that for now.
RegardsLaura

shlomit
Offline
Joined: 04/30/2014 - 03:13

Hi,
I just tried RunIDEAScriptRV function on V9, and it worked fine. Here is code of both scripts.
Hope it helped,
Shlomit
 

Images: 
Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Sholmit, thanks for the solution but it seems you can only either send variables or receive them you can't seem to do both.  So depending if you need to both send and recieve it still seems you would have to write the variables to a text file for one or the other direction.  

shlomit
Offline
Joined: 04/30/2014 - 03:13

I thought so too (and it also seems so from the description of the function: "Run another IDEAScript macro and return four variables to the caller."). But actually it works on both directions at the same time (even with a same variable - so you can use it like ByRef parameter).
The solution of a text file still will the best way when you have to deal with more then 4 variables.
Was glad to find it out, especially after all help I got from your forum, Brian!

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Thanks for the information shlomit, glad that you enjoy the site.