Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type x
- x as long
- end type
- 'variable named "x", having "x" as type
- 'this is fine since despite having the same names they are not used in the same contexts
- dim shared as x x
- dim shared as long y
- sub MySub( x as long )
- dim as integer y = 5
- print "y=";y,".y=";.y
- print "parm x=";x,"old x.x=";.x.x
- .x.x = x
- print "parm x=";x,"new x.x=";.x.x
- end sub
- scope 'main
- 'setting global x heres...
- y = 10
- x.x = 12
- 'declared a "x" as string which is fine since this is a different scope
- dim as string x = "hello world"
- 'freebasic kinda screwed up in this case... because sizeof() should refer to type X as priority
- 'and len(x) should refer to variable x.. as priority.... but they don't
- print "sizeof(x)=";sizeof(x) 'this will cause a warn due to ambiguity (and will show the size of the struct)
- print "len(x)=";len(x) 'this will cause a warn due to ambiguity (and will show the size of the struct)
- print sizeof(.x) 'this will NOT WARN and show the size of the struct
- print sizeof(..x) 'this will NOT WARN and show the size of the struct
- print sizeof(*@x) 'this will NOT WARN and show the size of the variable (12 since that's the size of the string descriptor)
- print len(*@x) 'this will NOT WARN and show the LENGTH of the string variable
- MySub(15)
- sleep
- end scope
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement