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 *

You May Also Like…

How to Research a CPU Upgrade

How to Research a CPU Upgrade

Upgrade Time! Doing a lot of VMWare Workstation virtualization to create labs for self-study and training. Finding...