Sample script

The following example shows a sample script for an Omegaview Zoom. It demonstrates the constructs of the scripting language through user-defined functions, local variables, flow control and built-in emulator functions.

/*
 Omegaview Zoom Emulator Script
  Copyright(c) !IBM Corporation 2002, 2005
*/
// ---------------------------------------
// Check for Signon Panel
// 0 = not found
// 1 = found
// ---------------------------------------
int FUNCTION signonPanel()
{
  if ((findString("OMEGAVIEW") > 0) AND
   (findString("Sign On Panel") > 0) AND
   (findString("Userid") > 0) AND
   (findString("Password") > 0) )
  return TRUE;
  else
  return FALSE;
}

// ---------------------------------------
// Check for Signon Error
//  return 0 if no error
//            1 if the SignonError pop-up found
// ---------------------------------------
int FUNCTION signonErrorpop-up()
{
  if ((findString("OMEGAVIEW") > 0) AND
       (findString("User access denied") > 0) )
  return TRUE;

  return FALSE;
}

// ---------------------------------------
// Goto Command Panel
// 0 = not found
// 1 = found
// ---------------------------------------
int FUNCTION gotoCommandPanel()
{
  rc = TRUE; // be optimistic
 
  if (findString(CMD_PANEL_ID) < 0)
  {
     sendkey(DEFHOTKEY_CODE);
     waitforScreen();
     if (findString(CMD_PANEL_ID) < 0)
         rc = FALSE; // not found
 
  }

  return rc;
}

void FUNCTION displayError(int errCode)
{
  if (errCode == 4)
     msgBox("Application not available");
  else if(errCode == 8)
     msgBox("Application not available - no signon Panel");
  else if (errCode == 16)
     msgBox("Invalid Signon request");
  else if (errCode == 24)
     msgBox ("Internal Error - command Panel not found");
  else
     msgBox ("Unknown Error. rc = " + errCode);
}
// ---------------------------------------
// LOGON
//  @param - user userid
//  @param - pswd password
//
//  @returns 0, success
//            4, no logo screen
//            8, no signon Panel
//          16, signon error
//          24, no command Panel
 

int FUNCTION logon(string user,string pswd)
{
 rc = 0;
 if (user == null || user == "")
  return 1;

 sendkey("HOME");
 sendkey("TAB");sendkey("TAB");sendkey("TAB");
 sendstring("VGMVH"); // applid
 waitforscreen();
 waitforscreen(); // OV sends two screens (unlock)
 
 while (1)
 {
   if( findString("Press Enter to begin") < 0)
   {
     rc = 4;
     break;
   }
    // We have the Logo screen
   setCursor(1,1);
    sendkey("ENTER");
   waitforScreen();
 
   // Did we get the Signon Panel?
    if (signonPanel() == FALSE)
      {
       rc = 8; // no Logo
        break;
      }
 
    // do we have the F11 screen?
   if (findString("F11=CMW") < 0) // not found
   {
   // go the 4th field and do the magic
   sendKey("HOME");sendKey("TAB");sendKey("TAB");sendKey("TAB");
   setString("MVPM");
   sendKey("TAB");
   setString("MVPM");
 
    }
    else
   {
     sendKey("F11");
     waitforScreen();
     setstring("MVPM");
     sendKey("F24");
     WaitForScreen();
   }
   // now continue the logon
   sendKey("HOME");
   setString(user);
   sendKey("TAB");
   setString(pswd);
   sendKey("ENTER");
   waitforScreen();

   // if an error...
   if (signonErrorpop-up() == TRUE)
   {
     sendkey("F12"); // clear the pop-up
     waitForScreen();
     sendkey("F3"); // end the session
     waitForScreen();
     ;rc= 16; // signon error
     break;
   }
   rc = gotoCommandPanel();
   if (rc != 1)
     {
       rc = 24;
       break;
     }
   rc=0;
   break;
 }
 

 // success
 return rc;
}

// Main Program starts here

CMD_PANEL_ID = "KMVPMMAI";
DEFHOTKEY_CODE = "PA2";
EDITKEY_TAG = "=Cancel";
DEF_EDITKEY_TAG= "F12";

// prompt for the userid and password
// (can get this from system vars...)
userid = prompt("Enter UserID");
pswd = prompt("Enter Password","PSWD");

hide(); // don't show them the screen flicker

// perform the Logon
logon_complete = logon(userid,pswd);

if (logon_complete != 0)
{
  displayError(logon_complete);
  return;
}

// Logon was successful. So Zoom to the Omegamon
// (we're hard wire to IMS Workload
// until system parm passing is supported)
//
Setstring("KMVPMZM1");
sendkey("TAB");
setString("imsdc.wrt");
sendKey("ENTER");
waitforScreen();

show(); // show the results (should be the Omegamon screen)

// we don't want to show the Omegaview Command Screen
// so when they dismiss the Omegamon zoom, we will disconnect
while (1)
{
  waitforScreen(20000);
  if (findString(CMD_PANEL_ID) >= 0)
   {
     sendKey(DEF_EDITKEY_TAG);
     waitforScreen();
     break;
   }
 }