• Please review our updated Terms and Rules here

BASIC list handling software

Floppies_only

Veteran Member
Joined
Feb 15, 2008
Messages
648
Location
Washington, United States of America
Hi everybody,

I am contemplating writing a program in BASIC for the IBM PC. I was thinking that I would use the version of BASIC that came with DOS version two or three, whichever is newest (I mean I can't remember if version three has it). I had some questions that I was hoping that you could answer.

1) Can I write the program with my favorite word processor, save it as a *.txt file, change the file's extension to bas and then run it?

2) Can I change it back again to debug it (with my lack of programming skills, you can assume that writing it will be ten percent, and making it actually work will be ninety percent)?

3) This program is meant to handle a _lot_ of string variables. How many are available with these versions of BASIC? I was hoping to be able to use A1$ to Z255$ for the names of the variables.

Thanks,
Sean
 
I'm not familiar with the IBM PC BASIC, but many BASIC dialects store the program in tokenized form: every keyword is converted to a binary number outside the ASCII range. It makes the program take less memory and execute faster, as the interpreter doesn't have to parse the text all the time. The tokenization happens when you type in each line. Programs are saved in tokenized form, and also expected to load back as such.

There may be routines or programs that let you load a text file and simulate typing in line by line, invoking the tokenizer. For e.g. the Commodore computers there are cross-tokenizers running on a modern PC that will convert a text file to a binary file so CBM BASIC will accept it. I don't know if there are similar tools for IBM PC, or if it needs them even.

As for editing programs, many BASIC environments have full screen editing, so it should not be a problem for you to debug your program once inside BASIC and also save it in tokenized form. Once you're finished, it should be possible to output the listing as pure text - often this is easier than importing it.

When it comes to variable names, it sounds like you need to meet Mr DIM. He lets you allocate arrays of variables, so you can use A$(1) to A$(2000) if you like. Usually only the amount of memory puts a limit on how many elements you can allocate. It also makes it easier to reference in a loop:

FOR I=1 TO 100:A$(I)="NUMBER ";I:NEXT I

Good luck!
 
Hi everybody,

I am contemplating writing a program in BASIC for the IBM PC. I was thinking that I would use the version of BASIC that came with DOS version two or three, whichever is newest (I mean I can't remember if version three has it). I had some questions that I was hoping that you could answer.

1) Can I write the program with my favorite word processor, save it as a *.txt file, change the file's extension to bas and then run it?

Yes. The word processor has to be able to save straight ASCII files. If there are no funny control characters, bolding, line spacing characters (except for the normal newline character) then the BASIC provided with PC DOS (or GWBASIC if you are on a clone) will be able to load the program.

I often used WordStar 3.3 for my long programming sessions.

2) Can I change it back again to debug it (with my lack of programming skills, you can assume that writing it will be ten percent, and making it actually work will be ninety percent)?

You will debug it from inside the BASIC interpreter. The BASIC interpreter has a fairly good debug environment. It will tell you exactly what line you made your syntax error on. There is also tracing support with the TRON and TROFF commands.

3) This program is meant to handle a _lot_ of string variables. How many are available with these versions of BASIC? I was hoping to be able to use A1$ to Z255$ for the names of the variables.

Thanks,
Sean

Have you looked into arrays? If not, do so .. An array is a variable name that holds multiple values. You access the value that you want by an index number. Perfect for list processing.
 
Hi everybody,

1) Can I write the program with my favorite word processor, save it as a *.txt file, change the file's extension to bas and then run it?

2) Can I change it back again to debug it (with my lack of programming skills, you can assume that writing it will be ten percent, and making it actually work will be ninety percent)?

If you save the program in BASC with the command:
Code:
SAVE"FLENAME",A
, you will get an ASCII file of the code, the same format as notepad *.txt files (at least if you save it in ANSI codng). You actually don't need to change the fle format, as of Notepad have the abillty to open all filetypes (select "all files" in the "open" diaglog box, and they'll show up).

BASIC has no problem opening ascii/ANSI files, just make sure the extension is ".bas"

3) This program is meant to handle a _lot_ of string variables. How many are available with these versions of BASIC? I was hoping to be able to use A1$ to Z255$ for the names of the variables.

Thanks,
Sean
You can have as many varables of every kind you like (until you run out of RAM :p). Just make sure no variable name is the name of a command or functon (Example: You can't write "LET RETURN = 1:pRINT RETURN").

BTW, Mbbrutman got a very good alternatve option if you know how to handle Array variables.
 
The file extensions are only defaults, so you could edit xyz.bas with notepad (for example) on the one hand or load "xyz.txt" in BASIC (or run GWBASIC XYZ.TXT); no need to rename.

One thing to keep in mind is that by default BASIC saves in token form, so if you use .BAS as the extension for your text format files you could easily forget the ",A":
i.e. assuming ABC.BAS is the ASCII file from your editor, then LOAD "ABC" and SAVE "ABC" will convert ABC.BAS from text to tokens. Not serious, you can reverse it, but I'd probably keep the source files with a different (e.g. .TXT) extension.

And yes, absolutely; an array is the answer for what you have in mind.

You might also consider a compiled BASIC for speed, especially after you've done most of your debugging.

m
 
1) Can I write the program with my favorite word processor, save it as a *.txt file, change the file's extension to bas and then run it?

Sure!

2) Can I change it back again to debug it (with my lack of programming skills, you can assume that writing it will be ten percent, and making it actually work will be ninety percent)?

Yes, if you save your program with the ,A command to save in ascii, like this:

Code:
SAVE "MYPROG.TXT",A

But a better solution is to write your program in quickbasic, which will run on 8088-class machines, let you edit and debug within the IDE, have access to procedures, and run slightly faster.

3) This program is meant to handle a _lot_ of string variables. How many are available with these versions of BASIC? I was hoping to be able to use A1$ to Z255$ for the names of the variables.

That is wrong on many levels :) Limits aside, you should look into DIMing an array and work with that instead of a bazillion variables.
 
word trixter. that's what i'm saying here.... screw all that. QuickBASIC 4.5... that's where it's at.

floppies_only: if you don't have QuickBASIC and need to know where to get it, let me know in a PM.
 
word trixter. that's what i'm saying here.... screw all that. QuickBASIC 4.5... that's where it's at.

But a better solution is to write your program in turbobasic, which will run on 8088-class machines, let you edit and debug within the IDE, have access to procedures, and run *much* faster.

;-)

m
 
But a better solution is to write your program in turbobasic, which will run on 8088-class machines, let you edit and debug within the IDE, have access to procedures, and run *much* faster.

;-)

m

never heard of that flavor, but QB45 lets you edit and debug within the IDE as well and runs on 8088-class machines... see my IRC server which is running on an 8088 written in QB45 as i type this. :)

QB rocks. i don't know if turbobasic is faster, it might very well be but if you know what you're doing QB is not that slow really.
 
Yes. The word processor has to be able to save straight ASCII files. If there are no funny control characters, bolding, line spacing characters (except for the normal newline character) then the BASIC provided with PC DOS (or GWBASIC if you are on a clone) will be able to load the program.

I often used WordStar 3.3 for my long programming sessions.

[snip]

Have you looked into arrays? If not, do so .. An array is a variable name that holds multiple values. You access the value that you want by an index number. Perfect for list processing.

I thought that the people who answered no to this might be interested in why I would want to edit program files with a word processor. Well, the title says "list-handling" which implies a list of items to be manipated by the program. It is my intention to obtain this list from the internet, save it to 3 1/2" floppy, copy that to 5 1/4" floppy, and open the file with a word processor and assign the items (all 850 of them) to string variables.

Now, my excuse...er, explination for why I didn't know about arrays in BASIC. Set the wayback machine to the Apple ][ era and witness Sean attending a computer math class at high school.

I had programmed in BASIC on the TRS-80 and Apple that my Dad had bought before that, so the class was a review of stuff I already knew. The teacher figured this out and allowed me to start learning PASCAL. And then, something sabotaged my career as a programmer. There was this game on the system disks that we used, a shoot 'em up that depicted a tank, a maze, and enemy tanks that fired at yours. And there was this girl, a semi-hot stoner chick, that I got to talking to during the time that I was not teaching myself PASCAL. We got to playing this game quite a bit. I had determined that we'd be unstoppable if one of us did the driving and the other pointed the turret and fired the shots. It was really a lovely time until the teacher got around to asking why I had made such little progress on creating PASCAL programs.

I admitted what had happened, added commentary on the addictive quality of computer games and threw myself on the mercy of the court. I don't really remember what happened in that class after that. I never did learn PASCAL. The teacher gave me a good grade in spite of my shortcommings :)

I wish I had known about psychology in high school. On the engineering track, I was wasting my time. But now I get to try to combine the two when I write stuff like this.

Sean
 
I learned BASIC first, then moved up to Pascal. Everybody knows that BASIC is kind of a limited environment because it is a 'first' language. Pascal was quite a step up:

  • User defined data structures: not every variable has to be a string or a number .. you can combine strings and numbers to make 'records' which are more logical to work with (depending on your application).
  • Functions and procedures: GOSUB in BASIC is close, but true functions and procedures help to prevent spaghetti code. The broader goal is 'structured programming', where program flow is well defined and modular. 'Object oriented' was all the rage the last 15 years, but it's really not that much different that structured programming, and Pascal can teach you.
  • Pointers: referencing data by a what is essentially a memory index is far more powerful than referencing it by name. This is essential for anything that handles a large amount of data.

Moving from Pascal to C wasn't so hard - Pascal gives you most of the tools you need to be a great hacker. C just gives you the rope you need on top of that to hang yourself in new and glorious ways. :)

I think the built-in versions of BASIC that you are asking about are fine. Save QuickBASIC for when you get tired of the speed of the built-in BASICs. When you get to string handling there are a lot of good programming tricks you can use to overcome the speed limitations. For example, there are lots of ways to do sorting and many of them are horrendous. I can write a string sorting program in interpreted BASIC that will blow the doors off of somebody doing it poorly in Pascal. The key to any good programming is picking the right way to attack the problem. After that, it's just a simple matter of coding.
 
Quote:
Originally Posted by MikeS
But a better solution is to write your program in turbobasic, which will run on 8088-class machines, let you edit and debug within the IDE, have access to procedures, and run *much* faster.
;-)
m
never heard of that flavor, but QB45 lets you edit and debug within the IDE as well and runs on 8088-class machines... see my IRC server which is running on an 8088 written in QB45 as i type this. :)
QB rocks. i don't know if turbobasic is faster, it might very well be but if you know what you're doing QB is not that slow really.
---
Well, I was just being a smart-ass, since I usually find these "my favourite language/OS/computer/car etc. is the best" discussions a little silly, so I took trixter's post and just changed quickbasic to turbobasic; you could presumably find others as well.

Turbo Basic is Borland's BASIC compiler (as in Turbo Pascal, Turbo C etc.); compatible with BASICA/GWBASIC with lots of enhancements if ya want 'em and don't mind becoming incompatible (functions, no line numbers, etc.)

m
 
Nevermind that programming crap, what happened to the semi-hot stoner chick? LOL

Well, I graduated early at the end of the semester. I came home on leave from the Air Force the next December and I saw her friend, a girl with long blonde hair. I asked her to ask the stoner chick (who's name escapes me) to call me, but she never did. Oh well.

Sean
 
Well, I graduated early at the end of the semester. I came home on leave from the Air Force the next December and I saw her friend, a girl with long blonde hair. I asked her to ask the stoner chick (who's name escapes me) to call me, but she never did. Oh well.

Sean
---
... and so you swore off women forever and devoted your life to Classic Computers; good choice!

m
 
---
... and so you swore off women forever and devoted your life to Classic Computers; good choice!

m

Hardly a good choice, and not the one I made. When I finished with my leave and reported to my station in Japan I pursued one of the women that I'd gone through tech school with. She ultimately wasn't interested but there were many conquests after that. I only got into classic computers when I hit thirty, but I've been into women since I was three, with no signs of stopping or slowing down.

Sean
 
Hi guys. We're off topic already, and touching on some topics that we don't need to be. Let's get back to the geek stuff.
 
Hardly a good choice, and not the one I made. When I finished with my leave and reported to my station in Japan I pursued one of the women that I'd gone through tech school with. She ultimately wasn't interested but there were many conquests after that. I only got into classic computers when I hit thirty, but I've been into women since I was three, with no signs of stopping or slowing down.

Sean

wait a minute... something doesn't add up here. you can't be a computer nerd and have conquests of women at the same time. especially a vintage computer nerd. computer nerds can definitely be into women, but they're too big of losers to actually have conquests.





Hi guys. We're off topic already, and touching on some topics that we don't need to be. Let's get back to the geek stuff.

aw.... no fun
 
computer nerds can definitely be into women, but they're too big of losers to actually have conquests.

Speak for yourself ... ;-0

Let's stay on topic.
 
Back
Top