Global variables are necessary, I think. I know they are hard to keep track of, but that is how programming can be sometimes. I don't know much C, so someone else would have to translate it to C.
Paul
Printable View
Global variables are necessary, I think. I know they are hard to keep track of, but that is how programming can be sometimes. I don't know much C, so someone else would have to translate it to C.
Paul
Because I think it would run better, with fewer Windows API errors. In C or C++, there would be a standard library which could use the Windows API for handling the keyboard, display and file I/O.
As it is now, MINI-BASIC is a fragile piece of software. It crashes on occasion with Windows API errors. It is a mystery to me why this occurs.
Paul
It probably comes down to shoddy programming -- that is usually the case with so-called fragile software. Fragile = badly written. Being written in ASM only compounds these problems when somebody is using the language without a complete and thorough understanding of internal machine code.
If you were to convert or 'port' it, I would suggest that you just rewrite it from scratch. ASM - C++ is, if you ask me, a waste of time.
Note, though, that C++ is only based on C... it is not C. (I know that's going to start an argument but I'm quoting Bjorn Stroustrup himself). You would need to choose one or the other. C++ is a lot easier when it comes to dealing with errors and the STL names it almost trivial to write an interpretter.
I would say, however, that if you're not familiar with C/C++ you should probably start with a project a little smaller than that.
So is it possible to convert to C++?
Paul
It is possible to implement it from scratch (write a program that does the same thing functionally). I don't think there is any direct way to convert asm to C++ or C, since it is lacking all the higher level constructs. Assembly just contains less human readable information than the equivalent C or C++ code.
Writing it from scratch in C would require examining how the program works first.. I believe anyway.
Paul
And converting Assembly to C would require you to study how the program works (what is input, what is output) as well as the implementation details of the assembly version. The latter you wouldn't have to do, since you'd just design that yourself any way you like.
Right, I've done some work, and I can probably say that I wouldn't be surprised if the API errors you get are caused by global variables being changed when some other bit of code expects it to remain the same.
As to wheter C or C++ or Assembler is "more safe", I'd say all three languages are capable of doing the wrong thing, and badly written code in either of them will not work reliably.
--
Mats
Yeah. That's true. I don't know how badly written MINI-BASIC is, but it does crash occasionally with Windows API errors. Which is unfortunate. Translating it to C or C++ shouldn't be impossible. It has a very limited subset of the traditional BASIC language. It has 26 scalar variables and 1 array -- denoted by @(I).
Paul
Sure. But it's not the easiest way to "translate" it.
I'm still working my way through it, and I'm just about to implement the begginnings of the parser.
Most of the code so far is following very closely the original code, but I will use C style strings in the parser, to make life a bit more C-friendly.
--
Mats
Ok, thanks for the update. :) Sounds good so far.
Paul
True... or you could take a BASIC standard approach and write a new interpretter using BASIC syntax.
I think you're best bet is to just write a new basic interpretter or use an existing open-source interpretter.
It looks like you're getting a bit of help with it though so good luck!
Yeah, I think it would work that way. Hopefully it can work.
Paul
Well, I'm just about ready to try the "list" command. Currently it doesn't quite work (says Syntax error), but I should have that fixed in minutes.
I completely changed the way the actual program is stored - I'm using a linked list rather than a fixed area of memory for the program store.
It's still a LONG way off working, but it's getting in the right direction.
Next, I think will be save and load, so that I can start using some saved code to try things out, rather than having to type it all in.
Edit: changed wording and added a bit of what I'm doing next.
--
Mats