Alert Boxes

whwar9739

Member
So here is the situation. I have one program that is displaying a message as an alert box. What I would like to be able to do is run this program from another program and suppress the alert box or find a way to clear it from the screen programmatically. As it is now I have to press enter or space while the program is running to move past the alert box. Below is some example code to try to explain what is happening.

Initial Program:
Code:
/* example1.p */
FOR EACH xtbl NO-LOCK:
   WHERE xtbl.field = 1:
      FOR EACH xtbl2 EXCLUSIVE-LOCK
         WHERE xtbl2.field = xtbl.field:
            IF xtbl.field2 = "Z"
            THEN DO:
               xtbl2.field3 = 1.
               MESSAGE "Field3 = 1." VIEW-AS ALERT-BOX.
             END.
             ELSE DO:
                xtbl2.field3 = 0.
                MESSAGE "Field3 = 0." VIEW-AS ALERT-BOX.
             END.
       END.
END.
Code to run above program.
Code:
/* example2.p */
RUN example1.p.
 

StuartT

Member
you could do the following:
if program-name(2) <> "example2.p" then
message .....

program-name(2) returns the calling program so if the program is being run from example2.p then the message will not be displayed, but it will if it is run in isolation or from another program
 

whwar9739

Member
I guess I forgot to include this in my original set of limitations. I do not have the ability to change the initial program. I have to try to suppress the output from the calling program.
 

whwar9739

Member
Would you think that I could use something similar to the following?

Code:
RUN example1.p.
INPUT THROUGH echo '\n'.
INPUT CLOSE.
[\code]

Basically trying to send a carriage return to the system to clear the message from the screen.

Thanks,
 

StuartT

Member
nope, that will run the program first then try to process the input through once the program has finished running.
 

whwar9739

Member
Now just another thought. What if you flipped that to be:

Code:
INPUT THROUGH echo '\n'.
RUN example1.p.
INPUT CLOSE.
 

whwar9739

Member
Nope, that does not work either. Just tried it out. I also tried INPUT FROM /dev/null. and that did not work either. Open to any other suggestions anyone has.

Thanks,
 

StuartT

Member
To the best of my knowledge it is not possible to do what you require, the program with the messages in it would have to be amended.
 
The code you post is odd; I presume it is just for example.

The limitations you describe are odd also. Is this an academic exercise?

Anyway, run it in batch mode and you won't have your messages.
 

whwar9739

Member
Knut you are correct that in batch mode the alert-box is not an issue. However I dont always run in a batch mode.

The issue is that example1 is part of developed software at my company that I do not have the access to change. I am creating an internal tool that is running that program and would just like to suppress the alert box entirely or by pass needing to press enter on the alert box. Unusual circumstances understandably but it is what I have to work with.
 

4GLNewbie

Member
If you want only to close the specific warning-box you could try to write a vb-script ( or another kind of language of your choice ) that checks if there are windows opened with a specific title ( i.e. ) and closes the window.

It seems to me the only way to proceed if you cant modify the original code.
I hope this helps someway.
 
Knut you are correct that in batch mode the alert-box is not an issue. However I dont always run in a batch mode.

The issue is that example1 is part of developed software at my company that I do not have the access to change. I am creating an internal tool that is running that program and would just like to suppress the alert box entirely or by pass needing to press enter on the alert box. Unusual circumstances understandably but it is what I have to work with.

What I am saying is that because the called program you gave an example of doesn't have any parameters, it shouldn't make a difference if you run it from batch - though you may need to handle synchronicity if you need to make sure it has finished before you continue with the rest of the calling code. Is there a reason why you can't shell out within your main program?

ie.

Code:
/* example2.p */
:
do some stuff
:
/* shell out to batch script which runs example1.p */
:
do some more stuff

end. /* example2.p */

In the example above you are doing exactly what you require, just spawning a separate session to do it.
 

whwar9739

Member
What I am saying is that because the called program you gave an example of doesn't have any parameters, it shouldn't make a difference if you run it from batch - though you may need to handle synchronicity if you need to make sure it has finished before you continue with the rest of the calling code. Is there a reason why you can't shell out within your main program?

ie.

Code:
/* example2.p */
:
do some stuff
:
/* shell out to batch script which runs example1.p */
:
do some more stuff

end. /* example2.p */
In the example above you are doing exactly what you require, just spawning a separate session to do it.


Thank you KnutHandsome. I didn't even think of doing it that way. And the rest of the code does not require that piece to have been run, nor do I feel that I need a verification that it has run. And even so I think I could put in a short pause after doing that just to ensure there are no lock issues.

Thanks again.
 
Top