Example of using STDIN and STDOUT with VBScript

Written by James McDonald

May 22, 2012

Creating a filter for Formtrap Forms Server to modify a barcode passed in from the ERP system.

launch it with

cscript.exe //nologo scriptname.vbs

Here is the script

'takes print stream and strips batch suffix to leave YDDD

' don't muck around read the entire STDIN in one go
input_file = Wscript.StdIn.ReadAll

' get a reference to STDOUT
Set objStdOut = WScript.StdOut

' my input streams lines are Unix style so split at new lines \n vbLf
input_array = split(input_file, vbLf)

array_ubound = ubound (input_array) 

for i = 0 to array_ubound

        ' i'm looping through the lines in the input stream
        ' and chopping out characters 233 and 234 of each line
	left_input = left(input_array(i), 252)
	right_input = mid(input_array(i), 255)

        ' write it back out STDOUT
	objStdOut.write left_input & right_input

        ' on the last line don't append a line feed, \n, chr(10)
	if i <> array_ubound then objStdOut.write vbLf

next

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.

You May Also Like…

Network speed test host to host

On Ubuntu / Debian apt-get install iperf3 On Windows download it from https://iperf.fr/iperf-download.php#windows Make...

Clear HSTS Settings in CHrome

Open chrome://net-internals/#hsts enter the domain in the query field and click Query to confirm it has HSTS settings...