VBScriptInt
Tool to test VBScript (VBS) code. Full VBScript execution or simple sentence evaluation. Outputs to a text box enabling you to copy and paste the results. Includes tools to replace and escape strings, encode HTML, encode binary files and more.
Quick description
By Josep Vallshttp://josep.valls.name
Tool to test VBScript code. Full VBScript (VBS) execution or simple sentence evaluation. Outputs to a text box enabling you to copy and paste the results. Includes tools to replace and escape strings, encode HTML, encode binary files and more.
Overview
Handy tool to test code anywhere as do not require installation, uses HTA as a GUI to run the VBScript code so just Internet Explorer is required.
I used to write small VBS scripts for my customers and I needed a lot of message boxed to see what was going on when I didn’t had my developer tools with me, and when I discovered the Microsoft HTML Application ability to run VBScript I made this little tool to help me trace the results.
Just paste or write the code to the text box and evaluate it. Then I added a couple of functions to trace variables.
It helps to quickly evaluate simple sentences, or test if a component is registered or not.
I’ve added some additional functionality like replacing multiple pairs of strings at once, encoding text with quotation marks and carriage returns to be used within Visual Basic, encode HTML entities, encode binary files to use within Visual Basic, displaying binary files as HEX text and a Just-In-Time debugger toggle (by setting the registry).
In resume, it allows you to:
- Evaluate expressions and copy & paste the results.
- Trace variables easily
- Quickly encode text to be used within Visual Basic
- Quickly encode text to be used in HTML files
- Encode small binary files in Hex (Base 16) or Base 64.
- Display binary information from small files in a Hex editor like format.
- Encode small binary files into a kind of self extracting VBScript
- Toggle Just-In-Time debugging
Download
Downloads and additional documentation in the project page in Sourceforge.net
http://sourceforge.net/projects/vbscriptint/
Installation
No installation required. Just run (double click) the HTML Application (hta file).
Usage
Main window
Note: First of all you would change the interface language to English, select English from the Change language drop down.
Simple usage
Write in the first text area any VBScript code, write in the second text box the expression you would like to be displayed in the output text area at the bottom and press the Evaluate button.
Example, write in the first text area:
'Write your code here. msg = "Write your code" msg = msg & " here"
Write in the second text box:
msg
Click the Evaluate button and in the results text area will appear content of the msg variable:
Write your code here
Button explanation
- Reset button: Blank all the text boxes.
- How-to? button: Displays a simple example covering the text objects in the main window. Read the explanation under the Advanced usage through objects topic below.
- Reference button: Loads another example with some automate objects defined which use the internal tracing functions. Read the explanation under the Advanced usage through internal functions topic below.
- Utils button: Toggles between the main window and the tools window.
- About button: Displays about box.
- Change language drop down: Translates the interface in English, Spanish or Catalan.
- Quit: Closes the window.
Advanced usage through objects
You may want to set any text box value by your code, to do so just set the object’s value property for the object you want to display the results. If you press the How-to? button a self-explaining example will be loaded.
Advanced usage through internal functions
You may want to trace some variable in your code, just use the UItrace function and leave the second text box blank, for example:
for i = 0 to 4 UItrace fix(rnd()*10) next
Will output something like:
1 5 0 4
You could also use UItracevar which will output the variable type and you could also set the UItraceString variable which contains the output results. Press the Reference button to load an example using UItrace functions.
Tools window
String utilities
First text area is used to input text to be encoded. The encoded text will be outputted to the second text area.
In the following examples I’ll show the result of each function, the input text will be always:
Type "here" the text to convert.
URLStringEncoded
Just press the Escape and Unescape buttons to escape and unescape the text. Example of escaping the sample text:
Type%20%22here%22%0D%0Athe%20text%20to%20convert.
Custom pattern
Choose Custom pattern from the drop down list and write in the text box next to it the pairs you would like to replace, write as much as you need separated by the vertical bar | character. The pattern should look like the following:
"|""|e|3|t|7|i|1
Press the button Replace by defined pattern to process the text. Example of replacing the sample text with the sample pattern:
Typ3 ""h3r3"" 7h3 73x7 7o conv3r7.
You may use the buttons Down to up button to replace from the lower text area to the upper one and the Invert pattern button to exchange the replacement pattern pairs.
Text for Visual Basic
Select text – VB from the Custom pattern drop down, this will encode the text to be used within a Visual Basic message. Press the Replace by defined pattern button to process the text. This is handy for large text within message boxes or other messages. Example of using a Multi line text for VB:
"Type """here"""" & vbCrLf & _ "the text to convert."
HTML entities
This option will encode special characters into the apropriate HTML entities. You could replace only a few characters or the full Latin subset (ISO 8889-1), this is very important to display correctly non-english characters. For this example I’ll use another text:
€uro Español Català
Properly encoded as:
€uro Español Català
Binary files utilities
This tools let you work with small binary files, choose the input file and a file to output the results (if omitted, .txt will be appended to the original file). Select the encoding method and press the button to encode or decode using the encoding method chosen. The available encoding methods are the following and an output example is provided.
Hex
47494638396110001000B30000000000009CFF9CFF00FF00FF...
Base 64
R0lGODlhEAAQALMAAAAAAACc/5z/AP8A//////////////////...
Hex. editor
Offset Bits Data 00000000 GIF89a····³····· 47 49 46 38 39 61 10 00
Dec. editor
Offset Bits Data 00000000 GIF89a····³····· 71 73 70 56 57 97 16 00
Binary VBS
On Error Resume Next
function z(num)
z=string(num*2,"0")
end function
Set ts = CreateObject("Scripting.FileSystemObject").OpenTextFile("c:image.gif", 2, True)
For x = 1 To 511 Step 2 : ts.Write Chr(Clng("&H" & Mid("47494638396110001000B3"&z(6)&"9CFF9CFF00FF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF21F90401000003002C"&z(4)&"1000100000043070C849ABBD14E8CDBB0E600008A430965F7892AB09846269CA29D8DE5EBE613C37F83E1E06B80B0A2D44CD6F776CF222003B",x,2))) : Next
ts.Close
Note that if you copy and paste the previous sample into a blank file with .vbs extension and you run it (by double click) it will create c:\image.gif
Other utilities
Last but not least
Debugging button: This button toggles the Just-in-Time debugging by setting the HKEY_CURRENT_USER\Software\Microsoft\Windows Script\Settings\JITDebug registry key.
Reload interpreter button: I suppose that you know that you could edit directly the hta file with any plain text editor (let’s say notepad). Feel free to modify it to fit your needs but let me know in order to improve it. Any changes made to the hta should be reloaded, just click the button. Note that if there is any error in the syntax the interpreter will fail loading and the captions for buttons will be blank. If you need help or information about HTML Applications (hta files) let me know or check my sample project EscapeStrings in http://sourceforge.net/projects/EscapeStrings.


