• Print

Author Topic: QB and Turbo B  (Read 662 times)

woidzmerf

  • Guest
QB and Turbo B
« on: February 13, 2010, 05:34:43 AM »
Hi guys. I last did any BASIC programming (laborious stuff - It took me 100 lines of code to accomplish what the average programmer could do in just 20 or less) a good 20+ years ago - when a 20mB HDD was considered extravagant and  software was installed from floppies. What I'd like to know is whether QB64 is sufficiently close to Turbo BASIC for me to get by with my old Turbo BaASIC manual. Also, rather than going through a week-long process of writing a simple subroutine myself, is there perhaps some  kind of library I could tap into, or possibly help available from this or other forums in  constructing simple SR, taking for example a word and rearranging its constituent letters alphabetically?.

I hope no-one is too irritated by my signature, but I have this neighbour looking over my shoulder (thankfully he's emigrating next week) who insists it's bad luck not to have one

-- Greetings from The Woidzmerf, who sicks munts agow cuddint spel yurnalizt and now he am wun!

Pete

  • Moderator
  • Hero Member
  • *****
  • Posts: 6329
  • Cuz I sez so varmint!
Re: QB and Turbo B
« Reply #1 on: February 13, 2010, 08:38:27 AM »
Turbo Basic is the old name for Power Basic. Power Basic is wonderful project in my opinion. Power Basic for DOS was the closest QBasic compatible language until QB64 was invented. I didn't need to do much converting at all to get simple QB programs to run in Power Basic. BTW - I've been programming in BASIC for 30 years.

I would recommend this, if you have a copy of QBasic or QuickBasic, open your Turbo Basic program in it and it will check the syntax for you! REM out any lines it doesn't accept until the code that remains has no more QB syntax errors left. That code will most likely run in QB64, as QB64 is 90%+ QB compatible at the current level of development.

Just to make sure you understand what I mean by REM out, just place a ' mark or REM followed by a space in front of any line a syntax error occurs on. I think that is pretty standard for most BASIC languages.

If you need some help converting the syntax you remmed out, just post the code and ask for some help here or at the Network54 QBasic Forum. http://www.network54.com/Index/10167

And personally, I don't mind you being a yurnalizt, but I would recommend on this forum that you don't spend too much time hanging out at the water cooler, or you will have to take too many trips to the yurnainals.  ;D

Pete
It's only rocket science; it's not Linux!

stylin

  • Guest
Re: QB and Turbo B
« Reply #2 on: February 13, 2010, 09:25:25 AM »
woidzmerf, welcome to the forums. QB64 may resemble Turbo BASIC, but you should refer to the QB64 manual when using QB64:
http://www.qb64.net/wiki

It's still a work-in-progress, as is the compiler itself.

Regarding sorting algorithms, "bubble sort" is probably the easiest to understand, and the first one many people start with, as it has tons of QB implementations out there. Take a look at this page:
http://en.wikipedia.org/wiki/Bubble_sort

and try to get a feel for how it works, then look at this QB64 code:

Code: [Select]
sub SortCharacters( chars as string )
' implements bubble sort, adapted from
' http://en.wikipedia.org/wiki/Bubble_sort

    do
        ' nothing has been swapped in this pass yet
        swapped = 0
        
        ' check each adjacent pair of characters
        for i = 1 to Len( chars ) - 1
            ' are the characters at positions i and i+1 out of order ?
            if Mid$( chars, i, 1 ) > Mid$( chars, i+1, 1 ) then
                ' swap them..
                tmp$ = Mid$( chars, i, 1 )
                Mid$( chars, i, 1 ) = Mid$( chars, i+1, 1 )
                Mid$( chars, i+1, 1 ) = tmp$
                ' ..and indicate that so we can make another pass
                swapped = -1
            end if
        next i
    ' keep making passes until all characters are in order (no swapping occurred)
    loop while swapped

end sub

chars$ = "questionably"
SortCharacters chars$
Print chars$ ' abeilnoqstuy

Hope this helps, and good luck with QB64. :)

woidzmerf

  • Guest
Re: QB and Turbo B
« Reply #3 on: February 13, 2010, 10:06:37 AM »
Thanks fo r the pointers, Pete and Stylin. They ought to keep me out of mischf for a couple of days!

  • Print