Results 1 to 4 of 4

Thread: Several tBasic Files

  1. #1
    Junior Member
    Join Date
    Jun 2024
    Posts
    12
    Rep Power
    2

    Several tBasic Files

    Hi - I was wondering if I can create and later compile multi tBasic files into one executable? For example one.tBasic, two.tBasic into onetwo.exe. Thank You...

  2. #2
    Junior Member
    Join Date
    Feb 2021
    Posts
    8
    Rep Power
    11
    Quote Originally Posted by KF4GHG View Post
    Hi - I was wondering if I can create and later compile multi tBasic files into one executable? For example one.tBasic, two.tBasic into onetwo.exe. Thank You...
    Hi Ronnie.

    Yes you can create several files and run/bundle them in a single way.

    I use
    
    '---Load modules
    Uses "Console", "OS" ,"bundle" , "ui" , "file", "sapi"
    
    
    ' 1.12.0   Change name include files
    '     .1   correction ----
    '     .3   c-----
    '   13.0   - resolve_sym
    '   14.0   resolve_symbol   conditionnal
    '   15.0   test exist  sourcefile
    '     ..
    '     ..
    '     ..
    ' ......  
    '   34        add macros  "%%timehms%%"  "%%timehm%%"  "%%datejma%%" " %%dateamj%%"    (9/6/23)
    
    
    dim version_nbr as string = "V: 1.34.0     09-06-2023    " & $crlf
    dim dbg_indent as string = "Dbg--|"
    '
    ' 
    #BUNDLE Icon "D:\Users\Root\Desktop\ThinBasicStuff\00-exe-icon.ico"
    
    %insert_no  = 1 as byte  
    %insert_yes = 0 as byte
    
    #Include  "asm_1802_0_dbg_codes.tbasic"
    #Include  "asm_1802_0_dbg_get_options.tbasic"
    #Include  "asm_1802_2_functions.tbasic"
    #Include  "asm_1802_3_asm_main.tbasic"
    #Include  "asm_1802_3_define_org-equ.tbasic"
    #Include  "asm_1802_4_decode.tbasic"
    #Include  "asm_1802_4_look_symbol.tbasic"
    #Include  "asm_1802_5_ins_new_symbol.tbasic"
    #Include  "asm_1802_5_ins_unres_sym.tbasic"
    #Include  "asm_1802_6_extr_reg_num.tbasic"
    #Include  "asm_1802_7_evaluate_operand.tbasic"
    #INCLUDE  "asm_1802_8_analyse_operand.tbasic"
    #INCLUDE  "asm_1802_9_resolve_undef_symbols.tbasic"
    '
    'Start of main code
    '
    

    This the main file.


    Lines 1 ,2 : Declaration of modules used , included files may declare additional modules

    Lines 5 to 15 : Comments for keeping history of development

    Lines 22 and other not displayed : Bundle directives

    Lines 27 to 39 : Calls to different parts of code

    Lines 39 --->>> : Main code

    In my development, the main code starts with DIM of variables used thrugout the program.
    And other files are functional parts.
    So when working/debugging, I use ThinAir to open/edit the main file, and open only other modules I am working on.
    An when I hit the run button in the main file, all open modified files are saved on disk, and execution begins.
    The ThinBasic.exe does the work of openig all included files.

    You should be aware that Included files should not declare same variables leading to duplicate declare error.

    And something happened in earlier version of TB : The run button of ThinAir saves modified files opened, but the BUNDLE button did not.
    This leaded me to have some problems :
    1. - I modify included file , run in ThinAir with green arrow
    2. - The file is saved , and the programs run.
    3. - The code does correctly the work, but I see a typo in a message. I correct the typo, and start the Bundle phase.
    4. - I run the generated exe...... The typo is still present . In fact the bundle process worked with previous fie version, And on the ThinAir screen the typo appears to be corrected.
      so be careful to save all files before Bundle.



    In this work the main file is about 300 lines long, and the total of the project is about 10000 lines.

    Some of include files are used in another project, this leads to be rigourous in variables names/declarations.

    This is my way of working, I guess there are other way of work.


    Question to Eros/Petr : Does the pre process of execution could accept conditional pathes as does C preprocessor "IFdefined xxxx then .....



    Yann
    Last edited by Yann_F_29; 03-08-2024 at 00:08. Reason: typo

  3. #3
    Junior Member
    Join Date
    Jun 2024
    Posts
    12
    Rep Power
    2
    Thank You...

    Quote Originally Posted by Yann_F_29 View Post
    Hi Ronnie.
    Yes you can create several files and run/bundle them in a single way.
    Yann

  4. #4
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,153
    Rep Power
    736
    Hi,

    thank you for starting an interesting discussion!

    Code structure
    Looking at the script by Yann, I follow very similar structure in my project, with one modification:
    - main file, the application, uses .tbasic extension
    - secondary files with reusable code use .tbasicu (thinBasic Unit) extension

    It does not change anything regarding behaviour, but I try to design .tbasicu files so they are self contained (have complete spec of module dependencies, for example), so I can grab them and use in another project.

    Avoiding name clashes

    The mentioned collision of variable names is something which is in other languages solved via namespaces.

    ThinBASIC does not have this concept at the moment, but you could workaround it by having dedicated TYPE in each .tbasicu file.

    For example, if I would have file "myMatematicalFunctions.tbasicu", then I could create the following pattern in the file:
    TYPE tMyMathematicalFunctions
      ... add variables here
      myVar   AS LONG
      myText  AS STRING
    END TYPE
    
    DIM myMathematicalFunctions as tMyMathematicalFunctions
    
    ...then I can refer to the variables using myMathematicalFunctions.myVar, myMathematicalFunctions.myText.

    That means I can have myVar, myText in other files too, but thanks to unique "prefix", collision risk is reduced.

    Conditional paths
    I am not sure I fully understand, but you can use:

    #IF #DEF(someVariable)
      ' one branch of code
    #ELSE
      ' another branch of code
    #END IF
    
    Please note there is no "THEN" used in this case.


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

Similar Threads

  1. difference between .tbasic and .tbasicc
    By sandyrepope in forum Console
    Replies: 5
    Last Post: 30-08-2024, 16:49
  2. UDT_VarPtr.tbasic
    By DirectuX in forum Samples for help file
    Replies: 6
    Last Post: 04-01-2019, 09:09
  3. ListView_Basic.tBasic
    By DirectuX in forum Samples for help file
    Replies: 2
    Last Post: 04-11-2018, 11:47
  4. ML_ExpressionEvaluation.tbasic
    By DirectuX in forum Samples for help file
    Replies: 1
    Last Post: 01-11-2018, 14:00
  5. Invoking One .tbasic Program From Another .tbasic Program
    By gungadout in forum thinBasic General
    Replies: 46
    Last Post: 23-11-2009, 12:01

Members who have read this thread: 7

Posting Permissions

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