• Please review our updated Terms and Rules here

Some help with mbasic

mepiscopo

New Member
Joined
Oct 19, 2025
Messages
3
I'm running mbasic on an Altair-duino 8800. It's been a looong time since I used basic, so I can't figure out how to save data to the mounted hard drive. Save saves the program, how do I save data I generate in the program? Can't seem to find the command/key word in the manual.
Thanks
Mark
 
Just guessing but it will go something like this:
10 OPEN "O", 1, "FILENAME.DAT"
20 PRINT #1, "Your data here"
30 PRINT #1, Variable1, Variable2
35 PRINT #1, Variable3, Variable4
40 CLOSE 1
 
Which specific version of MBASIC is being used? The OPEN for output for printing to disk was something that changed frequently.
 
It says ALTAIR HARD DISK BASIC VERSION 300-5F 16May79. I'll try the stuff recommended by CloudInMyHead.
Thanks all
 
At least in theory you could create a piece of assembler code that saves all variables as a binary dump. Not sure how they are stored in Microsoft 8080 basic.
As an example on the 6502 all variables except actual string contents are stored starting at the end of the basic code, while strings grow down from top of memory.
There is a caveat though that if you assign a constant to a string, the actual string content will be within the basic program and if you change the program then the pointer points to the wrong place.

Thus the only really safe way to save variables as-is would be to save a dump of all memory. The easiest would be to just save the state of the emulator.

Back in the days you usually did it the way CloundInMyHead described above, but you could for example save the content of a large array directly as binary data to save both storage space and save/load time. Again I don't know how you'd do that on the 8080 basic, but on the 6502 basic you'd poke the addresses that point to the start and end of the basic program to what you wanted to save, and then do a save. Then the save command would return to immediate mode and the pointers would be wrong, so say on a commodore you'd fill the screen with poke commands and a run command to restart the program, and fill the keyboard input buffer with a "go to the upper left corner of the screen" and then a return key press to have those commands actually execute after the save command. Or way better you'd use a short piece of assembler code that would set things up and call the API to save binary data.

It's possible to save data binary using pure basic too. You'd use CHR$ to "print" any byte value 0-255. A tricky thing is that ASC returns 0 both if you feed it a character with the binary code 0, or if you feed it an empty string. I.E both ASC(CHR$(0)) and ASC("") returns 0. In some BASICs there are ways to tell if you are at the end of file.
 
Well, the CloudInMyHead suggestion worked. I'll try some other things too, but for now I can get the data the the disk. And now to read the file.
Thanks
 
Back
Top