-1

Could someone help me to write a macro for AS400 program that will refresh a specific page every 5 minutes. It should be an infinite loop that I can stop by clicking the stop button in the program. I tried to record the macro, but I can`t figure out how to make the loop.

Thank you!

This is what I got when tried to record the macro... (.mac file)

[PCOMM SCRIPT HEADER]
LANGUAGE=VBSCRIPT
DESCRIPTION=
[PCOMM SCRIPT SOURCE]
OPTION EXPLICIT
autECLSession.SetConnectionByName(ThisSessionName)

REM This line calls the macro subroutine
subSub1_

sub subSub1_()
   autECLSession.autECLOIA.WaitForAppAvailable

   autECLSession.autECLOIA.WaitForInputReady
   autECLSession.autECLPS.SendKeys "[pf5]"

   autECLSession.autECLPS.WaitForAttrib 10,1,"00","3c",3,10000

   autECLSession.autECLPS.Wait 781 

   autECLSession.autECLOIA.WaitForAppAvailable

   autECLSession.autECLOIA.WaitForInputReady
   autECLSession.autECLPS.SendKeys "[pf5]"

   autECLSession.autECLPS.WaitForAttrib 10,1,"00","3c",3,10000

   autECLSession.autECLPS.Wait 1125 

   autECLSession.autECLOIA.WaitForAppAvailable

   autECLSession.autECLOIA.WaitForInputReady
   autECLSession.autECLPS.SendKeys "[pf5]"
end sub
johnsnow333
  • 9
  • 1
  • 5

2 Answers2

0

One way to loop is DO WHILE or DO UNTIL. You'll probably want to display a message box to ask the user to exit. Try:

Do While 1 = 1
   subSub1_
   result = MsgBox("Exit?", vbOK, "Exit?")
   If result = vbOK
     Exit Do
   End If
Loop

Not tested. See the VBScript Language Reference on the Microsoft MSDN web site for more information. For more information on modal vs non-modal, see Stack Overflow question 22513413

Community
  • 1
  • 1
Buck Calabro
  • 7,558
  • 22
  • 25
0

Create your display with DFRWRT(*yes) RSTDSP(*yes) then in CLP OVRDSPF Display WAITRCD(&SECONDS)

Your program will wake up after the number of &SECONDS expire. Program will become active and code accordingly to refresh each time it wakes up.