Loading a .bas or .bas.txt file

Tutorials and help articles.

Articles will be approved by our staff before posting. This is to ensure that the community gets the highest quality possible content.
Post Reply
FuzzySilk
Posts: 15
Joined: Sat Jun 27, 2020 1:53 pm

Loading a .bas or .bas.txt file

Post by FuzzySilk »

Hi. I did a search so if this is listed somewhere forgive me, I could not find it. I’m trying to load a .bas.txt file and it goes through the motions and says ready but everything is locked up. I’ve tried on files that are on the sd card, files I’ve put on there. Nothing works. I have no problem loading the .prg files for the programs. There has to be a way to load .bas files so you can work on them on the machine.

LOAD “FILENAME.BAS.TXT”,8

I was able to write a Hello World program and Save it and the Load that but I can’t get any other basic text file to load, it just hangs. Any help is appreciated. Thanks.
TomXP411
Posts: 1720
Joined: Tue May 19, 2020 8:49 pm

Re: Loading a .bas or .bas.txt file

Post by TomXP411 »

You have to play some tricks to get ASCII text files to load in the emulator.

The simple way to do it is to open your text file in an editor, like Notepad++, and copy the whole document to the clipboard.

Then on the emulator, clear the screen and make sure the cursor is on the top line, then press Control+V. Release the Control key quickly, before the screen starts scrolling.

That's useful for loading small programs. For larger programs, you'll want to use the -bas command line option in the emulator.

Instead of starting the emulator by double-clicking it, open a command window and run the emulator with

x16emu -bas filename.bas

This will automatically "type in" the program to the emulator. Then you can just save the program normally with
SAVE "FILENAME"
FuzzySilk
Posts: 15
Joined: Sat Jun 27, 2020 1:53 pm

Re: Loading a .bas or .bas.txt file

Post by FuzzySilk »

Thanks for the info. I’ll give that a try on the emulator but what about the actual hard ware? How do I pull it up, I can’t do the x16emu -bas filename.bas there.
TomXP411
Posts: 1720
Joined: Tue May 19, 2020 8:49 pm

Re: Loading a .bas or .bas.txt file

Post by TomXP411 »

FuzzySilk wrote: Sun Feb 04, 2024 1:42 pm Thanks for the info. I’ll give that a try on the emulator but what about the actual hard ware? How do I pull it up, I can’t do the x16emu -bas filename.bas there.
The simple way is to use the emulator and save the PRG to your SD card.

However, there is a trick using BLOAD and the new EXEC command:
10 BLOAD "FILE.BAS", 8, 1, $A000 20 POKE PEEK(781) + 256 * PEEK(782), 0 30 EXEC $A000, 1 40 NEW
Change FILE.BAS to the name of your ASCII file, then run this command
EXEC executes a line of text as if it was BASIC code, making it straightforward to convert ASCII text to BASIC code.

Do not forget to save this program first, since NEW clears the program out before tokenizing the new file.
FuzzySilk
Posts: 15
Joined: Sat Jun 27, 2020 1:53 pm

Re: Loading a .bas or .bas.txt file

Post by FuzzySilk »

TomXP411 wrote: Sun Feb 04, 2024 10:46 pm
FuzzySilk wrote: Sun Feb 04, 2024 1:42 pm Thanks for the info. I’ll give that a try on the emulator but what about the actual hard ware? How do I pull it up, I can’t do the x16emu -bas filename.bas there.
The simple way is to use the emulator and save the PRG to your SD card.

However, there is a trick using BLOAD and the new EXEC command:
10 BLOAD "FILE.BAS", 8, 1, $A000 20 POKE PEEK(781) + 256 * PEEK(782), 0 30 EXEC $A000, 1 40 NEW
Change FILE.BAS to the name of your ASCII file, then run this command
EXEC executes a line of text as if it was BASIC code, making it straightforward to convert ASCII text to BASIC code.

Do not forget to save this program first, since NEW clears the program out before tokenizing the new file.
Thanks I’ll give this a try.
Post Reply