Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

General Discussions


You are currently viewing our General Discussions as a guest. Please register to participate.
Login



Closed Thread
Old 05-15-2005, 03:14 PM Qbasic
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
Welcome to the world of real programming! No longer are you stuck with using the internet for your games.
In addition QBASIC is the start of a whole series of languages. The 'Q' stands for Quick.
What the BASIC stands for is not so basic! It means: 'Beginners All Purpose Symbolic Instruction Code'. Basic is truly basic though!
I know you won't believe me after telling you what it stood for; but remember the 'Beginners' part! On to the lessons:

The Qbasic Shell:
This here's the QBASIC shell! (I'll explain it later)

CLS
SCREEN 2
PRINT "Hi!"
END

Now for the explanatory thing:
The CLS statement (A command that you tell the computer) clears the screen.
SCREEN 2 makes it look ultra-fancy.
The PRINT statement I'll tell you about later.
The END statement closes the program and takes you back to the QBASIC editor.

NOTE: There is another closing statement called SYSTEM; which closes the program and the editor.




Text
Remember the PRINT statement from before? That actually puts text on the screen; not the printer.
Print is incredibly basic. The attributes you used in HTML are similar.
You just type the command then what you want it to pop up with in quotes ("). (e.g. PRINT "Howdy!")




Input and Variables
First you'll learn about variables. If you've used Algebra you'll most likely know what a variable is. If not stick with HTML!
There are two main types of variables; String and Integer. An Integer is an in integer between... I forget, but it's large range! :-/
A string is a string of characters (or letters, numbers, and whatever) strung out in a row. (e.g. "The fat cat sat on the rat.")
All string variable names end with a $ sign. All integers a just plain old names.

Now for input:
The INPUT function puts a value from the user into a variable. To see a program with input and variables in action look below:


CLS
SCREEN 2
PRINT "What is your name?"
INPUT name$
PRINT "Hi," + name$ + "!"
END

To do math with integers use this type of code:

CLS
SCREEN 2
PRINT "Enter number one:"
INPUT numone
PRINT "Enter number two:"
INPUT numtwo
PRINT numone + numtwo
END


IF Statements
Ever thought; "If he does this I'll do that."? I'm sure you have at some point. Computers can do that to with special command from you.
Use the IF statement to do this with a computer. You'll need a basic knowledge of variables to use the IF statement.
The IF statement takes the following syntax (I'll explain it later):

CLS
SCREEN 2
PRINT "Do you want to play again? (Y/N)"
INPUT playagain$
IF playagain$ = "y" THEN
PRINT "Great!"
ELSE
PRINT "Bye!"
END
END IF
END


Now for the explanation:
First you'll notice I took in the variable playagain$. Then I used the IF statement to match it to a letter (in this case "y").
Whenever you're matching it to an integer or variable value; DON'T use quotes. Otherwise you MUST use quotes. You can compare variables
to other variables. Here's an example:

CLS
SCREEN 2
PRINT "What is the first persons last name?"
INPUT firstperson$
PRINT "What is the second persons last name?"
INPUT secondperson$
IF firstperson$ = secondperson$ THEN
PRINT "You're related!"
ELSE
PRINT "WOW! You're not related (most likely)."
END IF
END


This is a very simple example. DO NOT forget to close the IF statement with an END IF!

Sound
Sound, as always is the icing on the cake, and QBASIC is no exception. You can't play .wav files or any other file, but QBASIC has built in sounds.
The SOUND statement plays a sound (I think). SOUND takes an integer value between 0 and 30,000 and plays it through the internal speakers.
Sound takes the following format:


CLS
SCREEN 2
PRINT "Playing sound..."
SOUND 1000, 4
END


You can also do a plain old beep. Just use the BEEP statement. No other values are needed.

NOTE: sounds in the very low range can't be heard by the human ear. Please don't have a dog around if you're going to play sounds like that! The number after the large one is the length of the sound.

Printing
Printing to a printer is as easy as printing to a screen. Instead of PRINT use LPRINT.

Strategy
QBASIC games can be fun. Most the keys are, once again, in the Intro. Don't forget to make your games 'Interesting and Engaging'.
The best types of QBASIC games are text adventure games.
If you get awesome at QBASIC you can make other types. Just remember to have fun making the game!

Sample QBASIC Games

Barney Name-Calling
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE
rogem002 is offline
View Public Profile Visit rogem002's homepage!
 
 
Register now for full access!
Old 05-15-2005, 07:41 PM
Minaki's Avatar
Defies a Status

Posts: 1,626
Location: Guildford, UK
Trades: 0
....?
__________________
Minaki Serinde MCP
"Wow, Linux is nearly on-par with Windows ME!"

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Minaki is offline
View Public Profile Visit Minaki's homepage!
 
Old 05-15-2005, 09:44 PM
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
Yeah, was that a joke?
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
View Public Profile
 
Old 05-16-2005, 01:05 AM
OmuCuSucu's Avatar
Vi Veri Veniversum Vivus

Posts: 1,168
Name: Dragos-Valentin
Location: Cluj-Napoca, RO
Trades: 0
where'd that come from?

what exactly were you doing? joking / teaching / advertising ?
__________________
.
» Please remember to add to my Talkupation if you enjoyed my post. Thank you :)
.
OmuCuSucu is offline
View Public Profile
 
Old 05-16-2005, 06:40 AM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
He posted it in the coding - All the rest forum. There's nothing wrong with it, but it certainly didn't belong there so I moved it to the general board. I'm fairly certain I replied to it as well, but either I didn't hit the 'post' button or in moving the thread it got lost....

I'm as confused as you are why anyone would post this, but my original reply said that I remembered using Qbasic back in the days of windows 3. Anyone remember Nibbles and Gorillas? I hacked up a couple of text adventure games, then finally wrote a version of the game of life that would output dot patterns to a Roland XY pen plotter
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
View Public Profile Visit 0beron's homepage!
 
Old 05-16-2005, 06:52 AM
OmuCuSucu's Avatar
Vi Veri Veniversum Vivus

Posts: 1,168
Name: Dragos-Valentin
Location: Cluj-Napoca, RO
Trades: 0
0beron, when i replied you had no reply so it must've been your first guess

anyway, i'm still confused about the motive for posting it. to me it sounded like a comercial for Qbasic LOL

i think the best solution would not be moving it here, but moving it all the way on devboxforums.com LOL
__________________
.
» Please remember to add to my Talkupation if you enjoyed my post. Thank you :)
.
OmuCuSucu is offline
View Public Profile
 
Closed Thread     « Reply to Qbasic
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.60919 seconds with 12 queries