Page 1 of 1

asc, chr function, the less clumsy/messy version

Posted: 05 Apr 2011 01:09
by ghostmachine4
Recently, there have been posts reinventing the asc, chr functions using batch. There is no need to re-invent the wheel. If native solutions is desired, vbscript (or powershell) should be used since its already provided at first installation and comes with already tried and tested functions such as asc, chr etc.

Code: Select all

inString = WScript.Arguments(0)
WScript.Echo inString
For i=1 To Len(inString)
   WScript.Echo Asc(Mid(inString,i,1))
Next

Dim num(2)
num(0) = 65
num(1) = 97
For i=0 To UBound(num)
   WScript.Echo Chr( num(i) )
Next


Run

Code: Select all

C:\work>cscript //nologo test.vbs "string"
string
115
116
114
105
110
103
A
a