Results 1 to 4 of 4

Thread: Idea for multi-variable DIM declarations

  1. #1

    Idea for multi-variable DIM declarations

    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.

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    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

  3. #3
    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?

  4. #4
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,527
    Rep Power
    170
    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

Similar Threads

  1. multi dialog modeless
    By Lionheart008 in forum UI (User Interface)
    Replies: 6
    Last Post: 07-01-2010, 19:40
  2. Microsoft Windows 7 will be multi touch
    By ErosOlmi in forum Technology
    Replies: 2
    Last Post: 29-05-2008, 20:07

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •