I would say it depends on what you want to do with ASC() to decide if it is desirable or undesirable. Otherwise, I would guess it probably doesn't matter. For
ASC("a"), not really passing a literal argument "a" to ASC() function; it's an alternative way of writing
97u. Therefore,
ASC("a") itself is also a literal, not a function call. For
ASC(variable), it is a function call, and ULONG is largest minimum size needed for all platforms & string types.
Does
ASC seem wrong? It's a UBYTE, USHORT, or ULONG value returned in a ULONG result, if runtime. The new information would be to add the value is returned in UINTEGER result, if literal.
I think this code shows the all the uses. Also some that are not supported, in the comments. Plus
string[index] types.
Code: Select all
const #print compile-time ASC literal (constant)
scope
#print - all UINTEGER
var n1 = 97u
#print typeof( 97u )
#print typeof( n1 )
var c1 = asc( "a" )
#print typeof( asc("a") )
#print typeof( c1 )
var n2 = &h3040u
#print typeof( &h3040u )
#print typeof( n2 )
var c2 = asc( !"\u3040" )
#print typeof( asc( !"\u3040" ) )
#print typeof( c2 )
const s as string = "a"
'' const zstring * 2 = "a" '' not supported
'' const wstring * 2 = !"\u3040" '' not supported
var c3 = asc( s )
#print typeof( asc(s) )
#print typeof( c1 )
end scope
#print
#print run-time ASC conversion (non-constant)
scope
#print - all ULONG
#print - same rtlib function return type on all targets
dim s as string = "a"
dim z as zstring * 2 = "a"
dim w as wstring * 2 = !"\u3040"
var c1 = asc( s )
#print typeof( asc(s) )
#print typeof( c1 )
var c2 = asc( z )
#print typeof( asc(z) )
#print typeof( c2 )
var c3 = asc( w )
#print typeof( asc(w) )
#print typeof( c3 )
end scope
#print
#print compile-time string[index] (constant)
scope
#print - not supported
const s as string = "a"
'' const zstring * 2 = "a" '' not supported
'' const wstring * 2 = !"\u3040" '' not supported
'' var c1 = s[0] '' not supported
'' #print typeof( s[0] ) '' not supported
'' #print typeof( c1 )
end scope
#print
#print run-time string[index] (non-constant)
scope
#print - UBYTE, USHORT, or ULONG
#print - depends on string type
dim s as string = "a"
dim z as zstring * 2 = "a"
dim w as wstring * 2 = !"\u3040"
var c1 = s[0]
#print typeof( s[0] )
#print typeof( c1 )
var c2 = z[0]
#print typeof( z[0] )
#print typeof( c2 )
var c3 = w[0]
#print typeof( w[0] )
#print typeof( c3 )
end scope
#print