Include other .bbc files in the main file?
- zachnoland
- Posts: 11
- Joined: Sat 07 Dec 2024, 15:22
- Location: somewhere in Southeast Asia
Include other .bbc files in the main file?
I have a question. Can BBCSDL include other files inside the main file like MAIN.BBC and EXMATH.BBC, In EXMATH.BBC there are functions or procedures that can be called in MAIN.BBC.I don't know if this is possible on the original BBC Micro or not and i know this sounds like a modern programming language. But is this possible?
-
- Posts: 272
- Joined: Tue 18 Jun 2024, 09:32
Re: Include other .bbc files in the main file?
If I have understood your question correctly you can load such sub-modules using the INSTALL statement, in just the same way as you would the supplied libraries. The only difference is likely to be the file path from which the module is loaded:zachnoland wrote: ↑Thu 27 Feb 2025, 01:30 I have a question. Can BBCSDL include other files inside the main file like MAIN.BBC and EXMATH.BBC, In EXMATH.BBC there are functions or procedures that can be called in MAIN.BBC.I don't know if this is possible on the original BBC Micro or not and i know this sounds like a modern programming language. But is this possible?
Code: Select all
INSTALL @lib$ + "aagfxlib" : REM Load supplied system library
INSTALL @dir$ + "mymodule" : REM Load user-written sub-module
There are a number of restrictions governing an INSTALLed sub-module or library which do not apply to regular programs:
- It must be an internal-format (tokenised) program file, not a plain-text file.
- You cannot use GOTO or GOSUB (lines may be numbered, but only for the purposes of debugging).
- You can only use the 'relative' form of RESTORE.
As a rule, when you see references to libraries in the documentation they apply just the same to sub-modules.
- zachnoland
- Posts: 11
- Joined: Sat 07 Dec 2024, 15:22
- Location: somewhere in Southeast Asia
Re: Include other .bbc files in the main file?
I'm trying to understand how to load external files with:Richard Russell wrote: ↑Thu 27 Feb 2025, 03:15Code: Select all
INSTALL @lib$ + "aagfxlib" : REM Load supplied system library INSTALL @dir$ + "mymodule" : REM Load user-written sub-module
Code: Select all
INSTALL @dir$ + "MYMATH2"
Code: Select all
file or path not found in line 10
Code: Select all
10 REM MYMATH1.BBC
20 INSTALL @dir$ + "MYMATH2" : REM LOAD SUB-MODULE
30 A% = 5
40 B% = 5
50 PRINT FNMYADD(A%, B%)
60 END
Code: Select all
REM MYMATH2.BBC
DEF FNMYADD(NUM1%, NUM2%)
RESULTS% = NUM1% + NUM2%
=RESULTS%
-
- Posts: 272
- Joined: Tue 18 Jun 2024, 09:32
Re: Include other .bbc files in the main file?
My guess is that the issue here is that your files have a ".BBC" extension (capitals) but BBC BASIC is looking for a file with a ".bbc" extension (lowercase). If you omit the extension from the INSTALL statement, which you seem to be doing:zachnoland wrote: ↑Thu 27 Feb 2025, 10:53 I seem to have a problem with the file path issue in BBCSDL Android. The location of the MYMATH1.BBC and MYMATH2.BBC files are adjacent, meaning they were not changed before being saved in the same place or default.
Code: Select all
20 INSTALL @dir$ + "MYMATH2" : REM LOAD SUB-MODULE
Code: Select all
20 INSTALL @dir$ + "MYMATH2.BBC" : REM LOAD SUB-MODULE
- zachnoland
- Posts: 11
- Joined: Sat 07 Dec 2024, 15:22
- Location: somewhere in Southeast Asia
Re: Include other .bbc files in the main file?
I have tried changing the external file MYMATH2.BBC to mymathlib.bbc but it still produces the same error. Likewise, the main file MYMATH1.BBC becomes headertest.bbc and still gives error.Richard Russell wrote: ↑Thu 27 Feb 2025, 11:42 My guess is that the issue here is that your files have a ".BBC" extension (capitals) but BBC BASIC is looking for a file with a ".bbc" extension (lowercase). If you omit the extension from the INSTALL statement, which you seem to be doing:
BBC BASIC will automatically append the extension ".bbc", but since the Android file system is case-sensitive (as most are, apart from Windows and MacOS) that won't match your file. Either change the extension of your file to lowercase, or specify it explicitly in the INSTALL statement:Code: Select all
20 INSTALL @dir$ + "MYMATH2" : REM LOAD SUB-MODULE
Code: Select all
20 INSTALL @dir$ + "MYMATH2.BBC" : REM LOAD SUB-MODULE
The question:
One way I thought about but requires complete notes is, Maybe another solution is to add the complete file path structure of android but this will be very long and confusing.Could this be a bug?
If yes can you fix it?
Or maybe you have a solution for this.
Code: Select all
20 INSTALL @dir$ + "/storage/emulate/0/etc" : REM I don't remember all that path directory into the BBCSDL app lol
-
- Posts: 272
- Joined: Tue 18 Jun 2024, 09:32
Re: Include other .bbc files in the main file?
A bug in BBC BASIC? No, many of the supplied example programs would not work if it was, and a bug of that severity would have been found years ago (there are no known bugs in BBC BASIC for SDL 2.0).
It will almost certainly be something that you are doing wrong. Use the debugging capabilities of BBC BASIC (entering commands in Immediate Mode is probably the most useful in this case) to find out what.
For confirmation, I've just tested the INSTALL statement on my Android phone and it works perfectly:
You do not have the required permissions to view the files attached to this post.
- zachnoland
- Posts: 11
- Joined: Sat 07 Dec 2024, 15:22
- Location: somewhere in Southeast Asia
Re: Include other .bbc files in the main file?
I just realized something, the directory path is read depending on when opening the file directly or using interprenter immediate.bbc. This may be the reason why the code works if run directly. I just need to add double Dot like this.Richard Russell wrote: ↑Thu 27 Feb 2025, 15:56 It will almost certainly be something that you are doing wrong. Use the debugging capabilities of BBC BASIC (entering commands in Immediate Mode is probably the most useful in this case) to find out what.
For confirmation, I've just tested the INSTALL statement on my Android phone and it works perfectly:
Screenshot_2025-02-27-15-47-40-58_2f330f9510023cd121b7f55db302c4d3.jpg
Code: Select all
INSTALL @dir$ + "../mymathlib" : REM back to previous directory
Thank you the solution has been solved.

You do not have the required permissions to view the files attached to this post.
-
- Posts: 272
- Joined: Tue 18 Jun 2024, 09:32
Re: Include other .bbc files in the main file?
Yes, if you are entering immediate mode that way you will almost certainly find that @dir$ is pointing to where the immediate.bbc program itself is stored! It's usually better to enter immediate mode from the program that is in need of debugging, which is typically what will happen if an untrapped error occurs.zachnoland wrote: ↑Thu 27 Feb 2025, 16:22 I just realized something, the directory path is read depending on when opening the file directly or using immediate.bbc.
You could always put a copy of immediate.bbc in the same directory as the program you want to debug.

Hmm. 'Resource' files (that is, files that programs need in addition to the program itself, such as sub-modules, graphics images, sound effects etc.) should be stored either in the same directory as the program, or in a sub-directory thereof. So they would be loaded something like this:I just need to add double Dot like this.
Code: Select all
INSTALL @dir$ + "mymodule.bbc" : REM Same directory as program
INSTALL @dir$ + "myresources/modules/mymodule.bbc" : REM Sub-directory
So whilst it may be working for you at the moment, I would review how you are organising your project so that you would be able to build a standalone executable or application if you wanted to.