Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Help. Output data to a multi-column textbox

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Help. Output data to a multi-column textbox
  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 >>
 Help. Output data to a multi-column textbox - 6/18/2008 1:12:15 AM   
  boomer

 

Posts: 33
Score: 0
Joined: 6/17/2008
Status: offline
Does anyone have a script that outputs data to a textarea (multi-column textbox)?  I am trying to create a .hta script that outputs a constant ping to a textbox.  Thank you in advanced.
 
 
Post #: 1
 
 RE: Help. Output data to a multi-column textbox - 6/18/2008 3:12:29 AM   
  ehvbs

 

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

try <yourTextArea>.Value = <StringYouWantToShow> or
     <yourTextArea>.Value = <StringYouWantToPrepend> & <yourTextArea>.Value

appending of course is similar.

Good luck!

ehvbs

(in reply to boomer)
 
 
Post #: 2
 
 RE: Help. Output data to a multi-column textbox - 6/18/2008 4:18:17 AM   
  boomer

 

Posts: 33
Score: 0
Joined: 6/17/2008
Status: offline
Hi ehvbs, thank you for the reply.  Is it possible to use your example inconjunction with a document.write command?  Here is part of the script I would like to display in a textbox. 

For Each machine in aMachines
   Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._
       ExecQuery("select * from Win32_PingStatus where address = '"_
           & machine & "'")
   For Each objStatus in objPing
       If IsNull(objStatus.StatusCode) or objStatus.StatusCode<>0 Then
            document.write("<font color=black>" & Machine & " </font><font color=#FF0000> .......is unreachable </font><BR>")
       Else
            document.write("<font color=black>" & Machine & " </font><font color=#00FF00>.......is up </font><BR>")
       End If
   Next
Next

(in reply to ehvbs)
 
 
Post #: 3
 
 RE: Help. Output data to a multi-column textbox - 6/18/2008 4:41:14 AM   
  ehvbs

 

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

while it is possible to document.write the <textarea> and its value, in my opinion it's
a fatal design error to have document.write in a .HTA (ok, all you .HTA fans - I'm waiting
for your counter arguments).

So my advice is to have something like

  ...
  <textarea id="taDisplay" ...>...</textarea>
  ...

in the HTML part and

  Dim taDisplay : Set taDisplay = document.GetElementById( "taDisplay" )
  ...
   If IsNull(objStatus.StatusCode) or objStatus.StatusCode<>0 Then
       taDisplay.Value = machine & " is unreachable." & vbCrLf &  taDisplay.Value
  ...

in the code.

Good luck!

ehvbs

(in reply to boomer)
 
 
Post #: 4
 
 RE: Help. Output data to a multi-column textbox - 6/18/2008 5:16:22 AM   
  boomer

 

Posts: 33
Score: 0
Joined: 6/17/2008
Status: offline
Thanks ehvbs, I will give it a whirl.

(in reply to ehvbs)
 
 
Post #: 5
 
 RE: Help. Output data to a multi-column textbox - 6/18/2008 6:18:24 AM   
  boomer

 

Posts: 33
Score: 0
Joined: 6/17/2008
Status: offline
ehvbs, It worked the first time!  Thanks.  Now I am curious, what does "document.GetElementById" actually do?  Tried to google it but could not find the definition.

(in reply to boomer)
 
 
Post #: 6
 
 RE: Help. Output data to a multi-column textbox - 6/18/2008 7:01:27 AM   
  TNO


Posts: 1284
Score: 12
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
it does exactly what it says it does. It gets an element on the page by its id name.

to find it on google you will have to use its JavaScript syntax name (case sensitive):

document.getElementById

http://developer.mozilla.org/en/docs/DOM:document.getElementById

Also, on a  side note, don't use <font> tags. Use <span style="Foo">Bar</span> instead

_____________________________

To iterate is human, to recurse divine. -- L. Peter Deutsch

(in reply to boomer)
 
 
Post #: 7
 
 RE: Help. Output data to a multi-column textbox - 6/18/2008 8:03:42 AM   
  boomer

 

Posts: 33
Score: 0
Joined: 6/17/2008
Status: offline
Thanks TNO for the definition.  And you read my mind, I was having difficulties with the <fonts> tags

(in reply to TNO)
 
 
Post #: 8
 
 RE: Help. Output data to a multi-column textbox - 6/18/2008 9:54:50 AM   
  TNO


Posts: 1284
Score: 12
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
font tags are a really old way of doing things. CSS is the solution for all your formatting woe's

_____________________________

To iterate is human, to recurse divine. -- L. Peter Deutsch

(in reply to boomer)
 
 
Post #: 9
 
 RE: Help. Output data to a multi-column textbox - 6/19/2008 12:34:27 AM   
  boomer

 

Posts: 33
Score: 0
Joined: 6/17/2008
Status: offline
Ok, I ran into another snag - still new at vbscript.  How can I make this script do continous loop.  I am trying to create a script that will do a continous ping and output the results every 5 seconds. 

Here are my questions: 

1.  What is the .hta equivalent to vbscript wscript.sleep()
2.   Can you use the "DO" and "LOOP" command inside a "IF,THEN,ELSE"?
3.  Do I need to make a LOOP outside of the " For Each objStatus in objPing" line?

Here is part of the code I am working on; how can I make this output the ping results every 5 seconds:

Sub Server1
Dim taDisplay
Machine = "Server1"
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._
      ExecQuery("select * from Win32_PingStatus where address = '"_
          & machine & "'")
  For Each objStatus in objPing
  Set taDisplay = document.GetElementById( "taDisplay" )
Do 
      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
Loop
Next
End Sub

< Message edited by boomer -- 6/19/2008 12:53:37 AM >

(in reply to TNO)
 
 
Post #: 10
 
 RE: Help. Output data to a multi-column textbox - 6/19/2008 6:48:59 AM   
  ehvbs

 

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

your ping-action in Sub Server1 is a selfcontained task (including the output to the textarea.
So the best way to do it many times (every 5 secs) is to use this Sub with SetInterval (and
ClearInterval). But you should consult a good book or tutorial about DHTML before you write
your first line of code.

Regards

ehvbs

(in reply to boomer)
 
 
Post #: 11
 
 RE: Help. Output data to a multi-column textbox - 6/19/2008 8:36:22 AM   
  ehvbs

 

Posts: 2201
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
If you are seriously interested in .HTA programming, you should organize your
learning/programming in a systematic way. I don't claim that this way is the only one
or the best, but it works for me:

(1) Start with a simple template:


      

This gives you a very simple .hta with the most important sections in the simplest version:

  -  an Application object

  -  a meta section specifying encoding and script language

  -  a style section (here you can start to trash your font tags)

  -  a code section (with all the ugly formalisms done)

  -  a html body you can fill out later

The reload button/sub allows you to keep the code in your editor, save it after changes,
and reload/refresh the currently running .hta.

Add the HTML element you need to do the ping job:


      

If you do fc on the template and the first step on ping.hta, you'll see the changes/additions:


      

Title & Name (trivial); application globals to store HTML elements for further/frequent use and variables
to keep track of important/relevant states of the program/application; two subs to start and stop the
ping task (no real action yet, but they show how to avoid starting/stopping twice/in the wrong order);
initializing (of the globals) in OnLoadBody (after the elements are ready); the minimal set of elements
for the ping task: two buttons and a textarea to talk to the user.

Test it to see if I messed it up: Can you start ping twice or stop it when it is not running? Play with the
CSS (make the meta button yellow), ...

Next Step: Using SetInterval with a Fake Ping sub:


      

Not so much new code:


      

It's just a new sub and the using of Set/ClearInterval. Testing should show that after
starting the (fake) ping, the sub is called every 2 secs, and that you can start and
stop the action correctly.

Last step: Replace FakePink with RealPing:


      

Give this approach a chance, try it with two or three (simple) projects - and blame me here,
if it doesn't work for you. [Seriously: if it doesn't work for you, I hope you'll give some feedback
here, so that I (we?) can improve the procedure].

(in reply to ehvbs)
 
 
Post #: 12
 
 RE: Help. Output data to a multi-column textbox - 6/19/2008 9:46:49 AM   
  boomer

 

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

Thanks for the tips on the books -- With that said, I have only been working vbscript and HTA for only 2 months now.  I am beginner only trying to get my feet wet, so to speak -  to see if I want to continue in learning more advanced techniques.  So far I like it and plan on investing more time and money learning the tricks and trades as you have -- but for now it is nice to know I have people on the web who can help me and ease my beginner's pain.  We all have to start somewhere.  I don't want to waste a lot of money on books or school only to find out I don't want to continue.  But then again, I don't want to waste your time on beginner's trivial questions.  I am very grateful for all you help and time.  Thanks again for posting the script templates!!

(in reply to ehvbs)
 
 
Post #: 13
 
 RE: Help. Output data to a multi-column textbox - 6/19/2008 10:03:58 AM   
  boomer

 

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

I just tried the last one.  Really like how the scripts gives the time stamp.  Still trying to understand how it all works, especially how you got the ping to stop.  Thanks again for the scripts.  I'll check back once I do more research on your awesome scripts.


(in reply to boomer)
 
 
Post #: 14
 
 RE: Help. Output data to a multi-column textbox - 6/19/2008 5:06:44 PM   
  ehvbs

 

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

(1) you don't need to be apologetic about just starting with VBScript

(2) my posting wasn't about tricks, but about the basics

(3) there are public libraries & the Internet (money isn't an argument for not reading)

(4) 'just tried the last one' was the worst possible approach - if you'd started with the first
      and worked thru up to the last and had looked up SetInterval and ClearInterval, you wouldn't
      have to to ask about stopping the ping.

The scolding done, I must add that

(1) 'getting the work done' is important too

(2) not being dounted by problems and unrelentingly working on their solution
       is a laudable trait of character too

(3) sometimes it's difficult to force Google or a book to spit out the relevant info; so
       asking for help is peerfectly legitimate

So keep up your good work (but try to lay some sustainable foundation)

Regards

ehvbs

(in reply to boomer)
 
 
Post #: 15
 
 
 
  

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 >> Help. Output data to a multi-column textbox 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