Results 1 to 7 of 7

Thread: ThinBasic Bug - Duplicate variable declaration

  1. #1
    Junior Member
    Join Date
    Apr 2023
    Posts
    7
    Rep Power
    3

    ThinBasic Bug - Duplicate variable declaration

    I wrote a ThinBasic program but declared a variable twice by mistake, such as the following:

    Dim Status As Integer
    Dim Status As Integer

    I ran the program and the program terminated immediately with no error message.

    Can duplicate declarations be detected at runtime and an error message displayed?

    Eric

  2. #2
    Junior Member finchley's Avatar
    Join Date
    May 2021
    Location
    FN20IP
    Age
    55
    Posts
    2
    Rep Power
    0
    Windows 7 64-bit using ThinBasic 1.13.0.0 and I cannot reproduce your issue.
    I get Error Code 146: "Variable name already defined (Duplicated generic)".

  3. #3
    Junior Member
    Join Date
    Apr 2023
    Posts
    7
    Rep Power
    3
    I am using Windows 11 x64.
    Here is a script that shows the issue (at least for me).
    No output will be printed. Momentary terminal window flashes, then closes.

    ' File DupVarBug.tbasicc
    ' OS: Windows 11 64 bit
    
    '---Load Console Module
    Uses "Console"
    
    Dim Status as Integer
    Dim Status As Integer
    
    Status = 1
    Printl Status
    
    '---Wait for a key press
    WaitKey
    
    created another simple console script, same problem.

    ' File: Hello.tbasicc
    
    '---Load Console Module
    Uses "Console"
    
    Dim Status as Integer
    Dim Status As Integer
    
    '---Print the magic words
    'PrintL "Hello World from ThinBASIC!"
    'PrintL
    'PrintL "Press a key to end program"
    Printl "Hello"
    
    '---Wait for a key press
    WaitKey
    
    Last edited by EricE; 07-10-2025 at 16:39.

  4. #4
    Junior Member
    Join Date
    Apr 2023
    Posts
    7
    Rep Power
    3
    More info:
    The problem, no error message being generated, arises if the script is saved with the "tbasicc" extension.

  5. #5
    Junior Member finchley's Avatar
    Join Date
    May 2021
    Location
    FN20IP
    Age
    55
    Posts
    2
    Rep Power
    0
    Running the code with the *.tbasicc extension in a console also gives an error. If you single step the code with the debugger it will stop after executing (or trying to) the duplicate variable definition.

  6. #6
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    58
    Posts
    8,876
    Rep Power
    10
    Thanks a lot for reporting.

    I will have a look in the week-end, currently out for work.

    I remember that some way long I decided not to give any error if the duplicated variables was exactly the same name and same type so just ignore it.
    And later I decided it was not a good idea.

    For sure no crash should happen.

    Script extension (.tbasic or tbasicc) should not made any change.
    Extension is used to understand if to execute in a Windows environment (including the possibility to have a side Console) or in a pure Console environment.
    Last edited by ErosOlmi; 08-10-2025 at 16:50.
    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

  7. #7
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    58
    Posts
    8,876
    Rep Power
    10
    Just a quick test under thinBasic 1.14 but should be the same with previous thinBasic versions.

    Confirm the the variable duplication error is trapped

    But file extension is preventing to show runtime error in console for .tbasicc script files.
    When using .tbasicc files, script is executed by thinBasicc.exe application and error reporting is sent to standard error output (that is the console itself) but without any stop to wait for user input and have time to see error

    .tbasicc is mainly for input/output pipelines.
    It was developed when we thought that thinBasic could be used as server side web scripting language like PHP. Now abandoned dream, there are so many good programming languages out there for that purpose.

    Attached an example on how executed the script from a command line and how you can see trapped error

    So, just use .tbasic extension even for Console script and use .tbasicc when no user interface at all is needed
    Attached Images Attached Images
    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

Similar Threads

  1. help please, variable definition
    By DirectuX in forum OOP
    Replies: 4
    Last Post: 10-02-2024, 08:24
  2. Variable Subscripts
    By Benjamin in forum thinBasic General
    Replies: 5
    Last Post: 25-12-2023, 23:52
  3. iDispatch variable cause thinBasic crash
    By DirectuX in forum thinBasic General
    Replies: 1
    Last Post: 25-01-2020, 12:49
  4. New in next thinBasic: FOR with on-the-fly variable definition
    By ErosOlmi in forum thinBasic vaporware
    Replies: 16
    Last Post: 09-07-2008, 09:39

Posting Permissions

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