Thread: Converting MINI-BASIC in MASM over to C++?

  1. #136
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    I'm working, or was working, on it too.

    I'm almost positive I really do have the environment, size, and attribute issues fixed. (I wrote a simple driver to change the console to random sizes, and dump text with random colors which so far seems to "just work" and returns the console to the original state--minus the actual text.)

    I think I've patched a couple of other API bugs I noticed. (It is hard to be sure because I use a very thin US locale Windows XP environment.)

    I've separated the interpreter logic, the various "mini-basic" expansions and expectations, the editor logic, and the actual platform logic into separate chunks. (A few separate classes with simple abstractions. It certainly isn't my best work, but it is by far and away better than the original.)

    I've added the command "ALIAS" to the interpreter to support variable names. (Mechanically backed by a different approach to individual operations based on the simple fact that "simplify_expression"--replacing "EvalExpr" and various other bits--is always called before the line is otherwise parsed.)

    I've actually setup a few hooks so that it actually supports extensions without knowing how absolutely everything works. (I wanted to keep it reasonably simple; this too is by far from my best work, but you could actually add overloads and extensions without, more or less, having to rewrite everything.)

    I've also giving the source a general "spit and polish" dropping the crazy use of jumps, adding some targeted exceptions, and simplifying a few of the functions with extra support routines.

    What I've not done is added *all* of Sebastiani and matsp work back into the mix--just bits and pieces.

    Unfortunately, a friend of mine, a DBA monkey, is in a living nightmare of a recovery and I've lent him the time I had been spending on this.

    That said, you can stop finding reasons to bump this thread; what time I've spent on it was a game--I'm sure the others have similar reasons. If we want to stop working on it, we will; bumping the thread will not change that. If we don't want to stop working on it, we aren't going to forget about it. So... relax. You could, instead of pointlessly bumping the thread, actually help by rewriting the documentation--which according to you is simply wrong.

    Also, you two, I have something to discuss with you, but I've just run out of time... and in a truly bashworthy way. I'll try to get around to it later... with your permission of course.

    Soma

  2. #137
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Ok, I promise not to bump this post in the future. Thanks for the advice.

    Paul

  3. #138
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Quote Originally Posted by matsp View Post
    First of all, you may want to modify it so that it doesn't try to change the window to a size not supported, instead of giving "bad parameter".

    Whether it is valuable to change the size or not is a different matter. I kept it the way the original code was - the principle being "Make it work first - then change it around".

    I have made changes - e.g. the way that lines are kept in memory as a linked list instead of as a big chunk of text (with binary line numbers in it) is a change from the original format. In a proper C++ solution, I think a std::map<int, string> would be the right solution, but linked list was easy to implement at the spur of a moment.

    --
    Mats
    The window should be 80 x 25. That's the standard size window in Windows.

    Paul

  4. #139
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Paul Panks View Post
    The window should be 80 x 25. That's the standard size window in Windows.

    Paul
    Quote Originally Posted by Minibasic Source
    EditSizeX DW 100 ;Editor screen sizes
    EditSizeY DW 25
    The source code doesn't agree.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #140
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Maybe the best approach would be to automatically detect the current window size at startup. Programs wishing to change that setting could simply use the WINDOW command, of course...
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  6. #141
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    The window command? What's the format?

    Paul

  7. #142
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Window width_expression, height_expression
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  8. #143
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    NOTE: My machine has been behaving funny all afternoon. I'm going to run my magic disc on it tomorrow after I pull some stuff off the harddrive. With this in mind, please, please, don't download this if you don't have anti-virus/spyware running.

    Maybe the best approach [...] detect the current window size at startup.
    That's the approach I've taken.

    I think it was you Sebastiani that had the setup that refused the original resize source. Do you think you can try this? Actually, could a few people try it and let me know if it dumps an exception--to `std::clog'. (It doesn't on my machine, but that's a poor measure.)

    This should change the size several times and restore the console to the state it was in, minus the text, before the thing is executed.

    Soma

    [This is a UPX compressed executable. To be honest, I'm a little ashamed of the hackish approach I've used to glue some bits together and don't want it seen yet. ^_^;]

    [Yea, I forgot to include the bloody file.]

  9. #144
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    Question about the source code: is it C++ or C?

    Paul

  10. #145
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> NOTE: My machine has been behaving funny all afternoon. I'm going to run my magic disc on it tomorrow after I pull some stuff off the harddrive. With this in mind, please, please, don't download this if you don't have anti-virus/spyware running.

    Are you suggesting that I run a program built on a machine that may have a virus?

    >> To be honest, I'm a little ashamed of the hackish approach I've used to glue some bits together and don't want it seen yet.

    Nothing to be ashamed of. We can clean things up near then end. Go on and post what you have. Oh and by the way, I've been working some I/O issues myself. If you haven't resolved all of that yet (ie: handling special keys such as home, end, arrows, backspace, etc), let me know and I'll post that code as well. It's not incorporated into the main code yet, as I was testing all of that in a separate program...
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  11. #146
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Paul Panks View Post
    Question about the source code: is it C++ or C?

    Paul
    I haven't seen the latest code, but what I wrote was nearly all C, with a small amount of C++ style to it.

    If we can get a consolidated source code, I'd like to have a look at making it more C++-style.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  12. #147
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    That's fine with me. It would certainly be more streamlined, since we would have the STL at our disposal.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  13. #148
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    On the other hand, we should probably finish what we've already started before moving on to making it fully C++.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  14. #149
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Sebastiani View Post
    On the other hand, we should probably finish what we've already started before moving on to making it fully C++.
    Agreed.

    I haven't done anything lately.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  15. #150
    Registered User
    Join Date
    Jun 2004
    Posts
    76
    What's the difference between C and C++? I've always wondered.

    Paul

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Converting textBox1->Text into a basic string.
    By azjherben in forum C++ Programming
    Replies: 5
    Last Post: 06-07-2009, 08:27 PM
  2. [ANN] New script engine (Basic sintax)
    By MKTMK in forum C++ Programming
    Replies: 1
    Last Post: 11-01-2005, 10:28 AM
  3. what are your thoughts on visual basic?
    By orion- in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 09-22-2005, 04:28 AM
  4. VC++ 6 & MASM (eek)
    By cboard_member in forum C++ Programming
    Replies: 2
    Last Post: 07-16-2005, 10:00 AM