Menu

Nested #Insert

Flotul
2024-08-01
2024-08-04
  • Flotul

    Flotul - 2024-08-01

    Hi All,

    I have a program made of three files: A, B and C.

    The A files inserts B file. The B files does insert C file. In other words, A "calls" B and B "calls" C so thats two levels of inserting code.

    My program will work as long as I only use one one level of inserting code.

    Is this okay with GCB or am I missing something please?

    BTW, I'm completely new to GCB since two hours and comming from PICBASIC.

     
  • Anobium

    Anobium - 2024-08-01

    Welcome.

    As a new user I recommend that you use #include not #insert. They are very different things.

    You should have in your mind.

    • GCB main source program file
    • include A
    • include B

    #include does not have the concept of levels.

    Any subs/functions defined in any included file is available from the main source program file.
    --‐--
    There are 1000s of demos that show this in action. Have a look at this huge resource.

    Evan

     

    Last edit: Anobium 2024-08-01
  • Flotul

    Flotul - 2024-08-01

    Thank you Evan.

    I first tried with #Include but nothing worked until I did it with the #Insert command.

    This is what I found in the Wiki and it does indeed not act as in other programming languages, that's why I went for #Insert.

    "Those who are familiar with #include in assembly or C should bear in mind that #include in GCBASIC works differently to #include in most other languages - code is not inserted at the location of the #include, but rather at the end of the current program."

    I get your point about using #Include on a first place and I have to change my way of thinking while programming.

    Nevertheless, is it correct to say that #insert will accept only one child level?

     
  • Anobium

    Anobium - 2024-08-01

    You are correct re #insert. There are many constraints with #insert.

    Post you test code so I can review your approach. #include is the way forward.

     
  • Flotul

    Flotul - 2024-08-03

    The project is about a wall clock made of four NeoPiexel (WS2812B) strings representing four seven segments digits, each string having 28 pixels to address. One segment is made of four Pixels.

    Since timing is extremely important and the PIC either slow, making calls using GOTOs or GOSUBs make the program to not work. For this reason, I simply write (=> #Insert) many reiteration of already existing code to avoid these losses fo time.

    Hope it helps to understand what I'm doing 😐

     
    • Anobium

      Anobium - 2024-08-03

      I am sorry but I do not agree regarding WS2812B. There are demos and programs without #insert. Just use a macro if you need to.

      There established demos - have you reviewed them?

       
  • Flotul

    Flotul - 2024-08-04

    Yes, I found some but none addressing several strings like I do.

    BTW, I could have written my code without #Include/#Insert but during the debugging process, I would have had to go through a ton of repeated lines which is a huge nonsense and waste of time.

    In other words, the use of #Include/#Insert saved me hours of code tweaking 😉

     

Log in to post a comment.