Jump to content
Macro Express Forums
koden

Stop A Macro When Error?

Recommended Posts

Hello guys and girls :D

 

I use a macro in a IBM 3270 session.

 

The macro opens a mail inbox.

Opens the first mail and copy whats inside and delete.

Go to another program and put it in there.

 

Go back to the 3270 and do the same again.

 

But sometimes it don't make a click in the other program. Prberly because the other program is slow sometimes, and it do not open up before the macro clicks.

 

My macro use repeat, and sometimes it repeat 100 times.

 

So when i get the error in the other program, and i'm not there, it sometimes deletes a lot in the 3270, without having pastet it in anywhere.

It's gone.

 

Here is my question :P

 

Is it possible to insert a function in the macro, that stops the macro running, if the macro run into a problem???

 

Thanks...

Share this post


Link to post
Share on other sites

Yes. Macro Stop. However you might want to use a Repeat Exit instead. Depends how your macro is structures.

Share this post


Link to post
Share on other sites

I can find this in help:

 

Macro Stop

 

The Macro Stop command allows you to stop the execution of a macro. You may want to use this in conjunction with a conditional statement. If a desired condition is not met, you may wish to terminate the macro.

 

 

But where do I put it?

After repeat end?

And will it only be activated, if the macro have an error while running??

Share this post


Link to post
Share on other sites

Don’t be offended, no one is making fun of you, jowensii is just agreeing with my joke.

 

I do not know your exact situation so I speak in generalities, sorry. Let me see if I can give you a better explanation.

 

The most important part of what you are trying to do it to have some way of determining if there is an error. ME will blindly keep firing at a program regardless of what is happening. So if you have it type information into a field and the program complains that the input is invalid ME will just keep typing. It has no way of seeing that error message. You need to devise some sort of test in order to see if something is going wrong. Problem is I am not familiar with your system so I can’t give you any good examples. But maybe a simple example would help me explain.

 

Let’s say I command Notepad to open a file and type something. Now I would do a CTRL+O to get the open file dialog box. Once the dialog box is open I would enter the file name test.txt and hit enter. If test.txt exists then my macro will type “This is a test” and this would work. But let’s say test.txt does not exist. In this case an error dialog box pops up telling me that this file does not exist. But ME will just try typing because it can’t ‘see’ this dialog box. So in this case I would have a test after entering the file name to see if an error dialog window popped up. If it did I would pause the macro so the user could fix the situation or abort. When possible you should try to test first. In this case I would ask ME to check to see if the file exists and is ready. But I’m guessing you are in some sort of terminal emulation program so that would not apply to you.

 

You first task is to think of how you can tell if something is wrong. Then you need to figure out how ME could test to see if things are working. If in your system you enter text into a form and the terminal emulator displays a message indicating it worked. Have ME do a text capture of the screen and test for this after every time. If it finds the string “Error” then you need to execute an abort.

 

Wow, x3270. Now that goes back a ways. I’ve seen those in museums!

 

Are you using Telnet? If you are you might consider having ME generate scripts and then run the scripts. This would eliminate many timing errors. If you are using a TE (terminal emulator) you might look for a TE that you can program. I used to write TE front ends for old Digital mainframe systems to run on Windows via serial interface and there are many you can program with hot buttons to do complex tasks and perform logical decisions. The benefit here is that it eliminates the flow control and timing problems. I used one called ProComm but I haven’t seen it for years.

 

Give us some more info and maybe we can help more. Sorry I can’t be more specific.

 

Good luck!

Share this post


Link to post
Share on other sites

As Cory has mentioned, you seem to have timing errors. You could look out for error messages, as he suggested, but you should also look out for "processing" messages and just plain blank screens (which I have occasionally encountered on some TEs).

 

Another way out is to remove any potentially destructive actions from your macro. In your case, perhaps you could remove the "delete mail" part and just do that manually instead. That way at least, if your macro goes wrong it won't do so much damage.

Share this post


Link to post
Share on other sites

Okay.. Thanks guys...it's okay with a little fun :-)

 

About 3270 I can say that it is used very lot in the financial sector in Denmark, because it's so stabil.

We have almost never problems with or mainframe, what we def. not can say about the PC's and the programs on this.

When my macro stops it's newer in the 3270 part :-)

 

Okay...anyway...

 

I have in the 3270 a mail system.

I get every day 100 mails.

This mails have to be registred in another system that's named USD.

 

My macro goes to the 3270 opens the first mail,copy,delete

and then it goes to the USD program where I have to register every mail.

In the USD the macro opens a case, put inf. in diff. fields and paste the mail in to the last field and at the end clicking OK.

 

back to the 3270 and repeat as many times i have set.

 

The problem is in the USD, that sometimes it takes time to open a case (if the USD server is busy). but this my macro can't see.

Sometimes when the case has opened, there can be waiting time in the case and so on.

 

I think I have an idea to resolve it, but I don't now if it's possible.

 

In the USD system the last thing the macro does is clickin OK before REPEAT END.

Can I but a function in the macro that says:

 

If clicking OK not happens, then stop the macro???

Maybe in the repeat END function ?

Share this post


Link to post
Share on other sites

I still don’t understand your systems well enough to advise but I’ll see if I can help some more. One thing I want to tell you though. Please don’t get discouraged, this sounds like something that ME will work perfectly for. Stick with it and you will have a solution. We are just having difficulties communicating!

 

First please describe the program that is running on your computer. Is it a terminal emulator, Telnet, or some GUI (Graphical User Interface) software? I have only ever heard of telnet or TEs being used on such systems but your message suggests that you are using a mouse to click an OK button. Please tell us which it is as this make a fundamental difference on how to approach the problem. I have an easy suggestion for you. Can you take a screen capture CTRL+PRNSCRN of the applications as well as the screen with the “OK” and post them here? Make sure not to have any sensitive information in there. This will save a lot of explanation on your part.

 

While I wait for your response I want to take a stab at it again. If your system is presenting you with a GUI interface with Windows Common Controls things will be very easy. Again I don’t know how your program works but if something pops up with an OK button in it you can have ME wait for the control to appear before clicking OK. Or you can wait for a window to disappear before proceeding.

 

To do smart timing you need some sort of test. When you do some action that might have a delay what can you have ME watch for to test if it’s done? Does the screen change any? Is there a box that pops up? If we could see a video of your system in action we could better advise. All I can do is speak in generalities.

 

Here is one trick that might help. When I have two applications with possible timing problems I read all the information from one program and write it all to a file. Then I read the information from the program again writing to another file. Then I compare the two files line by line. If they do not agree I have it go back until it does! Then I go back and delete the records from the original system. If you are familiar with accounting you use this system to avoid errors in batches. Different data entry clerks enter the data in two batches and if the checksums don’t match there is an error within and it has to be done again. Now you could read in the data one entry at a time and compare but I think if there is a glitch in the network it’s likely you might read bad data twice that would pass comparison.

 

Also I like to stay in one application and write everything to a CSV file then switch to the other program to enter the data. This avoids constantly switching back and forth which can cause timing problems. And of course if both have an error rate of N then switching back and forth raises the error rate to N squared. With my method the error rate is only N or, depending on how you do it, 2N.

 

Hope this helps!

Share this post


Link to post
Share on other sites
But sometimes it don't make a click in the other program. Prberly because the other program is slow sometimes, and it do not open up before the macro clicks.

 

Does this occur in PIC 1, 2, or 3.

Share this post


Link to post
Share on other sites

Sorry, had a client whose server crashed. I got your post and I'll look it over here in a bit.

Share this post


Link to post
Share on other sites

Thanks for the screen shots. This helps a lot.

 

Is it in the “Session A” (let’s call it “black”) window where the error is occurring? If it is, can you send a screen shot of the error you would see if there is a displayed error?

 

Please explain in more detail what happens when you select a mail item in the black window. Is it viewed on screen or is it a text file that gets saved to disk somewhere? Maybe you could include the code from your macro to show us this. Just copy the commands in the script editor and paste into your message and then highlight them and hit the “Code” button in the message editor.

 

Let’s assume that you select an item and hit a command key to view that item. Since there may be a delay you might make an error by typing before the screen is ready. What I would do is set up some type of test to see if the system responded. For instance on the system I used to use there was a command to capture all the text in the terminal emulator window to a text file or to the clipboard. Now let’s say the next window you would see had the text “View email” at the top. What I would do is to copy all the screen text to my clipboard every couple of seconds and then search to see if that text exists in the clipboard. Since “View email” does not exist in the prior screen the macro would not advance until this condition was met. This way you will have no errors.

 

Does your terminal emulation software have the ability to dump the screen to the clipboard or file as I described before? We just need some way to read in what is on the screen for ME to evaluate.

 

Another suggestion is that you might want to slow down the keystroke delay when in this window. This will give a little pause between each keystroke. Often as little as 200ms will avoid a lot of problems and doesn’t increase the run time of the macro a significant amount.

Share this post


Link to post
Share on other sites

Hello Cory...

Thanks for coming back...

 

It's running ok now. I have put some pause time in.

But sometimes it failed. But it's not very much.

 

The black window is not the problem.

It's the other one (number 3).

 

But as i write there is not so much errors anymore.

 

But it would be good to have a stop, when the macro have a problem, so that I don't have to look at the screen while running.

TheMacro.mxe

Share this post


Link to post
Share on other sites

Well if it's with the last window then I think it would be a lot easier to fix given it’s a windows program. Does it give an error message or is the problem that it just hangs for a while? If it hangs can you give me a screen shot of the second window?

Share this post


Link to post
Share on other sites

On monday i'm back on work, and will send you screen shot.

 

What sometimes hapens is that when the macro click for opening the window, the server is slow or the network is slow, and it takes to long time to open the window.

The macro then already is going on with next step.

 

or..

 

Sometimes i have other programs that starts because I have forgotten to disable them while the macro is running.

 

or..

 

The macro sometimes just don't make the mouse click as it supose to do (not so often, but it hapens...maybe it's something on my pc thats stops it clicking)

 

So as you can see, the best would be if the macro could stop if ANYTHING goes wrong.

 

----------------------------------------------------------------------------------------------

 

 

I will send screen shots, but until that I will try to explain it again:

 

1.

First the macro activate the black window. Opens the first mail,copy the first mail,delete the first mail ( I have never hat errors in the black window. The 3270 mainframe). We call this picture 1.

 

2.

Then the macro activate the windows window called "service desk"

We call this picture 2.

 

3.

In the service desk window the macro clicks the button "new request".

And "new request" opens up. In this picture the macro fill out some fields with text and mouse click. This we call window 3.

 

 

In window 3 the macro ends with clicking a button called OK, and the picture 3 shut down. Back is the picture 2 and 1. They never shut down. Picture one just go in background, when 2 is active and 2 in background when 1 is active.

And 1 and 2 in background when 3 is open.

 

 

Maybe this error function/script is possible to put in?:

 

 

If the last window (number 3) is NOT gone from the screen, then don't go to the "black" window (the 3270) and repeat.

 

Is there a function that can be put in, and that stops the macro if the windows window(number 3) has NOT shut down ??

 

 

Do you understand or is it to bad english :-)) ?

Share this post


Link to post
Share on other sites

You are doing an excellent job with your English. It’s just the technical lingo is sometimes difficult.

 

What sometimes hapens is that when the macro click for opening the window, the server is slow or the network is slow, and it takes to long time to open the window.

 

This is pretty simple then. In the timing section look for the command Wait for Window. This will wait for the next window by title before proceeding. I often add a one second delay after that.

 

Sometimes i have other programs that starts because I have forgotten to disable them while the macro is running.

 

Look in the script editor and click on the Scope tab. In there you can set it so that ME only runs in windows with specific titles or of specific programs. This will prevent it from running when another program pops up. Click here for an example.

 

Also you can check a the start for any processes running that might cause problems. I have a client who uses WinFax and it sometimes has a popup notification for new faxes. I check to see if it’s running and if it is pause and tell the user to close it. Click here for an example.

 

Also I suggest you copy all your emails from the old 3270 to file then review them all. Once satisfied they are all correct and there were no interruptions move on to another section of the macro which will delete them all. Then move to the destination system and put them all in there in a similar fashion.

 

The macro sometimes just don't make the mouse click as it supose to do (not so often, but it hapens...maybe it's something on my pc thats stops it clicking)

 

This would require some investigation. I am sure it is firing but there may be some other problem.

 

A word of advice. When possible use keyboard shortcut and navigation. In my experience it’s much more reliable. As an example use CTRL+N nor a new mail message instead of clicking on the “New” button. Also clicking on common controls is very useful. Clcik here for an example.

 

So as you can see, the best would be if the macro could stop if ANYTHING goes wrong.

 

Of course but until they perfect Artificial Intelligence that’s not going to happen in any computer system. They are blind unless you tell them what to look for.

 

In window 3 the macro ends with clicking a button called OK, and the picture 3 shut down. Back is the picture 2 and 1. They never shut down. Picture one just go in background, when 2 is active and 2 in background when 1 is active.

And 1 and 2 in background when 3 is open.

 

You need to study the Window/Programs section of commands. Especially the activate and Launch. Then look at the Timing section. Especially the “Wait for windows” commands. Let’s call it WfW. In this case in Window 2 when click the button I would WfW with “Request” in the title. Once I did my thing in there and closed this window I would WfW with the title of “Service Desk”. This is all very simple.

 

I hope this helps. I think I understand now what you are doing and with these timing controls you will succeed.

 

Good luck!

Share this post


Link to post
Share on other sites

I use this to stop my macro:

 

If Window Title "Request" is running

Macro Stop

End If

 

 

Typical problem is that this window does not close.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...