![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | New to VBS.. HI everyone... I am just starting out learning VBS...so I'd appreciate any help with this... Is there a way in VBS to see each line as it executes? Similar to ECHO ON in bat files, I'd like to see each line as it executes and the values that are being set in the variables. Thank you |
My System Specs![]() |
| | #2 (permalink) |
| | Re: New to VBS.. <nickjax01@xxxxxx> wrote in message news:39861fd6-0c41-441b-89a1-bf551c24c5cc@xxxxxx Quote: > HI everyone... > > I am just starting out learning VBS...so I'd appreciate any help with > this... > > Is there a way in VBS to see each line as it executes? Similar to ECHO > ON in bat files, I'd like to see each line as it executes and the > values that are being set in the variables. > > Thank you environment that helps. It could be possible to create a script that reads lines from another a very simple script, echos each line, then executes it. However, complications quickly arise when statements cannot be run in isolation one line at a time. For example lines continued on several lines. And For Each, If Then, Do Until and other loops would be impossible. Also, I see no way to show the values of variables. A quick try follows. First an example script that can be executed one line at a time: ======= Option Explicit Dim lngValue1, lngValue2, lngValue3 lngValue1 = 3 lngValue2 = 5 lngValue3 = lngValue1 + lngValue3 Wscript.Echo lngValue3 ======= Then, if the above is saved in the file c:\Scripts\Example.vbs, the following VBScript program will read each line, echo it to the console, and execute each line: ======= Option Explicit Dim strScriptFile, objFSO, objFile, strLine Const ForReading = 1 ' Specify the VBScript program to run. strScriptFile = "c:\Scripts\Example.vbs" ' Open the file. Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile(strScriptFile, ForReading) ' Read each line of the file. Do Until objFile.AtEndOfStream strLine = objFile.ReadLine ' Echo the line to the console. Wscript.Echo strLine ' Run the line. Execute strLine Loop ' Clean up. objFile.Close ======= If run at a command prompt with cscript, the output would be: ========== Option Explicit Dim lngValue1, lngValue2, lngValue3 lngValue1 = 3 lngValue2 = 5 lngValue3 = lngValue1 + lngValue3 Wscript.Echo lngValue3 3 ========= However, I believe there are just too many complications to make this workable. Maybe someone knows how to run VBScript programs in VB IDE, for example. -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- |
My System Specs![]() |
| | #3 (permalink) |
| | Re: New to VBS.. "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote in message news:ugSok95lJHA.1388@xxxxxx Quote: > > <nickjax01@xxxxxx> wrote in message > news:39861fd6-0c41-441b-89a1-bf551c24c5cc@xxxxxx Quote: >> HI everyone... >> >> I am just starting out learning VBS...so I'd appreciate any help with >> this... >> >> Is there a way in VBS to see each line as it executes? Similar to ECHO >> ON in bat files, I'd like to see each line as it executes and the >> values that are being set in the variables. >> >> Thank you > There certainly is nothing builtin that does this, and I don't know of any > environment that helps. It could be possible to create a script that reads > lines from another a very simple script, echos each line, then executes > it. However, complications quickly arise when statements cannot be run in > isolation one line at a time. For example lines continued on several > lines. And For Each, If Then, Do Until and other loops would be > impossible. Also, I see no way to show the values of variables. > > A quick try follows. First an example script that can be executed one line > at a time: > ======= > Option Explicit > > Dim lngValue1, lngValue2, lngValue3 > > lngValue1 = 3 > lngValue2 = 5 > lngValue3 = lngValue1 + lngValue3 > Wscript.Echo lngValue3 > ======= > Then, if the above is saved in the file c:\Scripts\Example.vbs, the > following VBScript program will read each line, echo it to the console, > and execute each line: > ======= > Option Explicit > > Dim strScriptFile, objFSO, objFile, strLine > > Const ForReading = 1 > > ' Specify the VBScript program to run. > strScriptFile = "c:\Scripts\Example.vbs" > > ' Open the file. > Set objFSO = CreateObject("Scripting.FileSystemObject") > Set objFile = objFSO.OpenTextFile(strScriptFile, ForReading) > > ' Read each line of the file. > Do Until objFile.AtEndOfStream > strLine = objFile.ReadLine > ' Echo the line to the console. > Wscript.Echo strLine > ' Run the line. > Execute strLine > Loop > > ' Clean up. > objFile.Close > ======= > If run at a command prompt with cscript, the output would be: > ========== > Option Explicit > > Dim lngValue1, lngValue2, lngValue3 > > lngValue1 = 3 > lngValue2 = 5 > lngValue3 = lngValue1 + lngValue3 > Wscript.Echo lngValue3 > 3 > ========= > However, I believe there are just too many complications to make this > workable. Maybe someone knows how to run VBScript programs in VB IDE, for > example. Not sure if any of these can be set to display the staement as it is being executed, however, ECHO ON in batch files is an extremely limited debugging tool, and it cannot display variable values unless you code it to do so. /Al |
My System Specs![]() |
| | #4 (permalink) |
| | Re: New to VBS.. Or use a script debugger such as Visual Studio. Even the free versions can do this I believe. You can then step through the code line by line. -- Joe Fawcett (MVP - XML) http://joe.fawcett.name "Al Dunbar" <alandrub@xxxxxx> wrote in message news:%23wZYVP6lJHA.1288@xxxxxx Quote: > > "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote in > message news:ugSok95lJHA.1388@xxxxxx Quote: >> >> <nickjax01@xxxxxx> wrote in message >> news:39861fd6-0c41-441b-89a1-bf551c24c5cc@xxxxxx Quote: >>> HI everyone... >>> >>> I am just starting out learning VBS...so I'd appreciate any help with >>> this... >>> >>> Is there a way in VBS to see each line as it executes? Similar to ECHO >>> ON in bat files, I'd like to see each line as it executes and the >>> values that are being set in the variables. >>> >>> Thank you >> There certainly is nothing builtin that does this, and I don't know of >> any environment that helps. It could be possible to create a script that >> reads lines from another a very simple script, echos each line, then >> executes it. However, complications quickly arise when statements cannot >> be run in isolation one line at a time. For example lines continued on >> several lines. And For Each, If Then, Do Until and other loops would be >> impossible. Also, I see no way to show the values of variables. >> >> A quick try follows. First an example script that can be executed one >> line at a time: >> ======= >> Option Explicit >> >> Dim lngValue1, lngValue2, lngValue3 >> >> lngValue1 = 3 >> lngValue2 = 5 >> lngValue3 = lngValue1 + lngValue3 >> Wscript.Echo lngValue3 >> ======= >> Then, if the above is saved in the file c:\Scripts\Example.vbs, the >> following VBScript program will read each line, echo it to the console, >> and execute each line: >> ======= >> Option Explicit >> >> Dim strScriptFile, objFSO, objFile, strLine >> >> Const ForReading = 1 >> >> ' Specify the VBScript program to run. >> strScriptFile = "c:\Scripts\Example.vbs" >> >> ' Open the file. >> Set objFSO = CreateObject("Scripting.FileSystemObject") >> Set objFile = objFSO.OpenTextFile(strScriptFile, ForReading) >> >> ' Read each line of the file. >> Do Until objFile.AtEndOfStream >> strLine = objFile.ReadLine >> ' Echo the line to the console. >> Wscript.Echo strLine >> ' Run the line. >> Execute strLine >> Loop >> >> ' Clean up. >> objFile.Close >> ======= >> If run at a command prompt with cscript, the output would be: >> ========== >> Option Explicit >> >> Dim lngValue1, lngValue2, lngValue3 >> >> lngValue1 = 3 >> lngValue2 = 5 >> lngValue3 = lngValue1 + lngValue3 >> Wscript.Echo lngValue3 >> 3 >> ========= >> However, I believe there are just too many complications to make this >> workable. Maybe someone knows how to run VBScript programs in VB IDE, for >> example. > Third party IDE's exist, for example, PrimalScript from Sapien > Technologies. Not sure if any of these can be set to display the staement > as it is being executed, however, ECHO ON in batch files is an extremely > limited debugging tool, and it cannot display variable values unless you > code it to do so. > > /Al > > |
My System Specs![]() |
| | #5 (permalink) |
| | Re: New to VBS.. Thanks for all of your suggestions! "Joe Fawcett" <joefawcett@xxxxxx> wrote in message news:%234mMDO$lJHA.3644@xxxxxx Quote: > Or use a script debugger such as Visual Studio. Even the free versions can > do this I believe. You can then step through the code line by line. > > -- > > Joe Fawcett (MVP - XML) > > http://joe.fawcett.name > > "Al Dunbar" <alandrub@xxxxxx> wrote in message > news:%23wZYVP6lJHA.1288@xxxxxx Quote: >> >> "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote in >> message news:ugSok95lJHA.1388@xxxxxx Quote: >>> >>> <nickjax01@xxxxxx> wrote in message >>> news:39861fd6-0c41-441b-89a1-bf551c24c5cc@xxxxxx >>>> HI everyone... >>>> >>>> I am just starting out learning VBS...so I'd appreciate any help with >>>> this... >>>> >>>> Is there a way in VBS to see each line as it executes? Similar to ECHO >>>> ON in bat files, I'd like to see each line as it executes and the >>>> values that are being set in the variables. >>>> >>>> Thank you >>> >>> There certainly is nothing builtin that does this, and I don't know of >>> any environment that helps. It could be possible to create a script that >>> reads lines from another a very simple script, echos each line, then >>> executes it. However, complications quickly arise when statements cannot >>> be run in isolation one line at a time. For example lines continued on >>> several lines. And For Each, If Then, Do Until and other loops would be >>> impossible. Also, I see no way to show the values of variables. >>> >>> A quick try follows. First an example script that can be executed one >>> line at a time: >>> ======= >>> Option Explicit >>> >>> Dim lngValue1, lngValue2, lngValue3 >>> >>> lngValue1 = 3 >>> lngValue2 = 5 >>> lngValue3 = lngValue1 + lngValue3 >>> Wscript.Echo lngValue3 >>> ======= >>> Then, if the above is saved in the file c:\Scripts\Example.vbs, the >>> following VBScript program will read each line, echo it to the console, >>> and execute each line: >>> ======= >>> Option Explicit >>> >>> Dim strScriptFile, objFSO, objFile, strLine >>> >>> Const ForReading = 1 >>> >>> ' Specify the VBScript program to run. >>> strScriptFile = "c:\Scripts\Example.vbs" >>> >>> ' Open the file. >>> Set objFSO = CreateObject("Scripting.FileSystemObject") >>> Set objFile = objFSO.OpenTextFile(strScriptFile, ForReading) >>> >>> ' Read each line of the file. >>> Do Until objFile.AtEndOfStream >>> strLine = objFile.ReadLine >>> ' Echo the line to the console. >>> Wscript.Echo strLine >>> ' Run the line. >>> Execute strLine >>> Loop >>> >>> ' Clean up. >>> objFile.Close >>> ======= >>> If run at a command prompt with cscript, the output would be: >>> ========== >>> Option Explicit >>> >>> Dim lngValue1, lngValue2, lngValue3 >>> >>> lngValue1 = 3 >>> lngValue2 = 5 >>> lngValue3 = lngValue1 + lngValue3 >>> Wscript.Echo lngValue3 >>> 3 >>> ========= >>> However, I believe there are just too many complications to make this >>> workable. Maybe someone knows how to run VBScript programs in VB IDE, >>> for example. >> Third party IDE's exist, for example, PrimalScript from Sapien >> Technologies. Not sure if any of these can be set to display the staement >> as it is being executed, however, ECHO ON in batch files is an extremely >> limited debugging tool, and it cannot display variable values unless you >> code it to do so. >> >> /Al >> >> > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |