asc, chr function, the less clumsy/messy version

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
ghostmachine4
Posts: 319
Joined: 12 May 2006 01:13

asc, chr function, the less clumsy/messy version

#1 Post by ghostmachine4 » 05 Apr 2011 01:09

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

Post Reply