Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


How to stop a continuous loop w/ button

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,61624
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> How to stop a continuous loop w/ button
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 How to stop a continuous loop w/ button - 6/19/2008 4:21:18 AM   
  boomer

 

Posts: 33
Score: 0
Joined: 6/17/2008
Status: offline
I have created a .hta script that outputs a continuous loop of a ping command.  Now I have a delima, how do I create a .hta button to stop this process without closing the program?  In other words, I need a "stop execution/processing" button to end the output of the pings.  Thank you in advanced.
 
 
Post #: 1
 
 RE: How to stop a continuous loop w/ button - 6/19/2008 5:39:26 AM   
  Rischip


Posts: 502
Score: 2
Joined: 3/26/2007
Status: offline
Can you post the code?

Setup the button to call a routine which sets a flag. In the loop check the value of the flag and if it is set then exit the routine.

While True
   If Flag = False (Or True your choice) Then Exit Sub (Or Function)
   Do pingloop
   And so On
Wend 

_____________________________

Rischip
Author of - The Grim Linker

(in reply to boomer)
 
 
Post #: 2
 
 RE: How to stop a continuous loop w/ button - 6/19/2008 5:58:34 AM   
  boomer

 

Posts: 33
Score: 0
Joined: 6/17/2008
Status: offline
 
Hi Rischip,

I think I found a solution to my problem by calling another subroutine to stop the loop.  I do have another problem with my script.  How do I color code anything after .value = " "  I need to have "is unreachable."  color coded RED. The <span style=" or <font> tags will not work after the equal "=" sign.  Below is my subroutine:



Sub Script_1
Dim taDisplay
Machine = "computer1"
  Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._
       ExecQuery("select * from Win32_PingStatus where address = '"_
           & machine & "'")
   For Each objStatus in objPing
   Set taDisplay = document.GetElementById( "taDisplay" )

       If IsNull(objStatus.StatusCode) or objStatus.StatusCode<>0 Then
            taDisplay.Value = machine & " is unreachable." & vbCrLf &  taDisplay.Value
       Else
            taDisplay.Value = machine & " is up." & vbCrLf &  taDisplay.Value
    End If
Next
script_2

End Sub

(in reply to Rischip)
 
 
Post #: 3
 
 RE: How to stop a continuous loop w/ button - 6/19/2008 6:14:50 AM   
  Rischip


Posts: 502
Score: 2
Joined: 3/26/2007
Status: offline
Need more code... I can't tell what taDisplay is.

But you could try this.

taDisplay.Value = machine & " <P style="color: red;">is unreachable.</P>" & vbCrLf &  taDisplay.Value

but you should probably be using innerhtml and not .Value

_____________________________

Rischip
Author of - The Grim Linker

(in reply to boomer)
 
 
Post #: 4
 
 RE: How to stop a continuous loop w/ button - 6/19/2008 6:23:06 AM   
  boomer

 

Posts: 33
Score: 0
Joined: 6/17/2008
Status: offline
Hi Rischip, the code you gave did not work -- when I pasted in your code line, I got the error code: "Expected end of statement"
Any other suggestions.  I haven't played around with innerhtml too much.

(in reply to Rischip)
 
 
Post #: 5
 
 RE: How to stop a continuous loop w/ button - 6/19/2008 6:28:04 AM   
  Rischip


Posts: 502
Score: 2
Joined: 3/26/2007
Status: offline
I typoed

taDisplay.Value = machine & " <P style=""color: red;"">is unreachable.</P>" & vbCrLf &  taDisplay.Value

or

taDisplay.Value = machine & " <P style='color: red;'>is unreachable.</P>" & vbCrLf &  taDisplay.Value

_____________________________

Rischip
Author of - The Grim Linker

(in reply to boomer)
 
 
Post #: 6
 
 RE: How to stop a continuous loop w/ button - 6/19/2008 6:37:40 AM   
  ehvbs

 

Posts: 2201
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hold your horses: taDisplay is a <textarea>, so no colors possible (and .Value can take
a string and nothing else!

(in reply to Rischip)
 
 
Post #: 7
 
 RE: How to stop a continuous loop w/ button - 6/19/2008 6:45:51 AM   
  boomer

 

Posts: 33
Score: 0
Joined: 6/17/2008
Status: offline
Riship, no joy!  It displays "server1 <p style=color: red; ">is unreachable.</p> in the textarea.  Ehvbs must be correct as no color are allowed in the <textarea>.  Can I use colors with innterhtml?  Any work around?

(in reply to Rischip)
 
 
Post #: 8
 
 RE: How to stop a continuous loop w/ button - 6/19/2008 6:53:02 AM   
  ehvbs

 

Posts: 2201
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
No, boomer,

you can't use innerHTML, because you prepend plain text to the plain text already in the textarea.
You really should start some research into the basics of dynamic HTML!

Regards

ehvbs

(in reply to boomer)
 
 
Post #: 9
 
 RE: How to stop a continuous loop w/ button - 6/23/2008 12:47:42 AM   
  Rischip


Posts: 502
Score: 2
Joined: 3/26/2007
Status: offline
You will need to change the html tag from a text area to something that supports HTML. A DIV should work in simlar fashion.

_____________________________

Rischip
Author of - The Grim Linker

(in reply to boomer)
 
 
Post #: 10
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> How to stop a continuous loop w/ button Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts