Link to home
Start Free TrialLog in
Avatar of bhrugu123
bhrugu123Flag for United States of America

asked on

Fuction I want to add Argument

We want to modify the total number of half-seconds (or number of times the loop executes), not the number of milliseconds that the sleep method pauses.

My fuction is
function BlueZone_WaitForPrompt(objHost, strPrompt, strError)
{
      var timer = 0;
      var bzError =0;
      var x = new Object();                 
      var y = new Object();
      var buffer = new Object();
      var ErrorBuffer = new Object()
      
      var iTimerMax = 90;
      if (strPrompt == '<N>') {
            iTimerMax = 20;
      }

      while (timer < iTimerMax)
       {
            // Read from the current cursor location...
            objHost.GetCursor(y, x);
            objHost.ReadScreen(buffer, strPrompt.length, y.Num, x.Num - strPrompt.length);
            if (strPrompt == buffer.Str) {
                  CourWndAutomation.Sleep(500);
                  return true;
            }

            timer++;

            if(strPrompt == VERIFY_NEW_PW_PROMPT && doForcePasswordReset==false){
                  //Special case, read line returned from system above cursor
                  objHost.ReadScreen(Errorbuffer, VERIFY_PW_ERROR.length, y.Num - 2, VERIFY_PW_ERROR.x);
                  Errorbuffer.Str = Errorbuffer.Str.trim();
                  if((Errorbuffer.Str != "") && (Errorbuffer.Str != ADMINPASSWORD_PROMPT.trim())){
                        strError = buffer.Str;
                        break;
                  }
            } 

            CourWndAutomation.Sleep(500);
      }

      if (strError != "") {
            Log("Error: The value " + buffer.Str + " did not match the expected value " + strPrompt) //Log out what has been read from screen
            throw(strError);
      }
return false

Open in new window

Avatar of rohypnol
rohypnol
Flag of Romania image

Maybe this will help.

Regards,
Tom
// added parameter "loopCount"
// if you don't want it as a parameter, remove it from the parameters list in the function declaration and after the "var loopNr = 1" line add this:    var loopCount = 50;    and replace 50 with the number of times you want to loop
 
function BlueZone_WaitForPrompt(objHost, strPrompt, strError, loopCount)
{
      var bzError =0;
      var x = new Object();                
      var y = new Object();
      var buffer = new Object();
      var ErrorBuffer = new Object()
 
      var loopNr = 1;
      
      while (loopNr <= loopCount)
       {
            // Read from the current cursor location...
            objHost.GetCursor(y, x);
            objHost.ReadScreen(buffer, strPrompt.length, y.Num, x.Num - strPrompt.length);
            if (strPrompt == buffer.Str) {
                  CourWndAutomation.Sleep(500);
                  return true;
            }
 
            if(strPrompt == VERIFY_NEW_PW_PROMPT && doForcePasswordReset==false){
                  //Special case, read line returned from system above cursor
                  objHost.ReadScreen(Errorbuffer, VERIFY_PW_ERROR.length, y.Num - 2, VERIFY_PW_ERROR.x);
                  Errorbuffer.Str = Errorbuffer.Str.trim();
                  if((Errorbuffer.Str != "") && (Errorbuffer.Str != ADMINPASSWORD_PROMPT.trim())){
                        strError = buffer.Str;
                        break;
                  }
            }
 
            CourWndAutomation.Sleep(500);
            loopNr++;
      }
 
      if (strError != "") {
            Log("Error: The value " + buffer.Str + " did not match the expected value " + strPrompt) //Log out what has been read from screen
            throw(strError);
      }
return false
 
}

Open in new window

Avatar of bhrugu123

ASKER

what is actully loopcount do?
ASKER CERTIFIED SOLUTION
Avatar of rohypnol
rohypnol
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
if i add that i can run application faster or what? OR DO YOU KNOW ANY ANOTHER WAY TO DO IT?
I don't know if your application will run faster or not because I have no idea about the rest of the code nor the purpose of this function nor what it's actually doing... I just gave you an answer to what you've asked.
IF i give you code so you can let me know that right way to do or not this is whole code.
okay thanks
Question: "We want to modify the total number of half-seconds (or number of times the loop executes), not the number of milliseconds that the sleep method pauses."
I gave the user a way (and hinted them on another one) they can change the number of times the loop executes. That may not be what they're looking for but it's the answer to the question.

Thanks,
Tom