www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - VB functions conversion

reply jicman <jicman_member pathlink.com> writes:
Sorry for all the postings... :-)

I am translating a VB program to d and I can't find a function in d that does
the same as Asc in VB.  The Asc function returns an integer.  For example, this
vbscript program,

WScript.Echo(Asc("a"))
WScript.Echo(Asc("a"))
WScript.Echo(Asc("b"))
WScript.Echo(Asc("c"))
WScript.Echo(Asc("A"))
WScript.Echo(Asc("B"))
WScript.Echo(Asc("C"))

will return

19:18:16.92>cscript test.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

97
98
99
65
66
67

and I can{t find a function under std.conv to address this.  I guess I could
write a function on the d program itself to do this, but I want to use the d
functions, if possible.

any ideas?

thanks,

josé
Feb 18 2005
parent h3r3tic <foo bar.baz> writes:
jicman wrote:
 (...)
 any ideas?
 
 thanks,
 
 josé
how about cast(int) ? :) import std.stdio; void main() { writefln(cast(int)'a'); writefln(cast(int)'b'); writefln(cast(int)'c'); getchar(); } Tom
Feb 18 2005