DIM a, b, c AS LONG
Declaration produces 3 LONG
The DIM statement allows for multiple declarations of variables, such as
DIM a, b, c AS LONG
However, in this example, a and b are not of type LONG but are variants. Thus, the AS LONG clause is not applied to the entire list of variable, but only to the last name (c).
This syntax can mislead the reader. It is desirable to have some way to declare all three variables with the same type, without having to respecify the AS clause each time. A few possible syntax options come to mind:
First, instead of a comma, some other punctuation would be used to connect a list of variables:
DIM a & b & c AS LONG
DIM a; b; c AS LONG
Second, the list could be put into parens, or maybe braces:
DIM (a, b, c) AS LONG
DIM {a, b, c} AS LONG
My personal vote, all things being equal, I'd would choose the parenthesized list.
DIM a, b, c AS LONG
Declaration produces 3 LONG
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
But I am certain I tried a test with DIM a, b, c AS STRING, and c ended up being a string and a and b were variants.
Am I missing something?
Maybe I am confusing apples and oranges.
If I have a subroutine header like
SUB mySub (a, b, c AS STRING)
then a and b will be variants, correct?
yes- if you omit type in sub/function the type becomes variant.
but if you
Sub anysub() Local X, Y as Long ' these are for sure two longs Local A(), B() as String ' and these are both string arrays - unsized Double q, r, s ' and these are all local doubles to the sub (short declaration syntax) Dword C, D Value 12345 ' make two dwords with initial value of 12345 End Sub
Last edited by ReneMiner; 17-06-2013 at 16:43.
I think there are missing some Forum-sections as beta-testing and support
Bookmarks