For example,
Code: Select all
#lang "fblite"
nxt:
input "hh ",s$
print CHR$(VAL("&H"+s$))
goto nxt
It's just a classification curiosity for me.
(This is NOT intended to drive fxm crazy)
Code: Select all
#lang "fblite"
nxt:
input "hh ",s$
print CHR$(VAL("&H"+s$))
goto nxt
That's what he's telling you: it's a prefix for literals, not for types. It tells the compiler 'interpret the following literal as hex/oct/whatever'. The association with a variable comes from the fact that val can also parse literal prefixes.
Code: Select all
dim as string helloVar
dim as Long six
"helloVar" = "Go away" '' no - error 119: Cannot modify a constant
hellovar = "Go away" '' yes
6 = 23.5 '' no
six = 23.5 '' yes
*cast(Long Ptr, 6) = 23.5 '' yes!? Oh bums
Code: Select all
Dim As String s = "FF"
Print Val("&h" + "FF")
Print Val("&h" + s)
Sleep
Code: Select all
Dim As String s = "FF"
Print Val("&hFF")
Scope
Dim As String _s_
_s_ = "&h" + s
Print Val(_s_)
End Scope
Sleep
Not quite sure why you're getting hung up here. Your initial example involved strings, which happened to contain the characters &h which, when interpreted by VAL() makes a number out of it. Is &h in the string "p&h" a literal? No of course not. But the entire token including the quotes is a string literal.