Qbasic Programmers,I need some help.

Discuss popular GCS tools like ZZT, Megazeux and Adventure Game Studio, as well as programming and other topics related to game design.
Post Reply
tinman47
Lord of Gaming
Lord of Gaming
Posts: 230
Joined: Sat Feb 24, 2007 1:07 pm

Qbasic Programmers,I need some help.

Post by tinman47 »

After a few weeks of studying QB,I finally have a grasp on QB(IN JUST 2 WEEKS! :laugh: ).QB is awesome.It allows your dreams to come true with a few or alot of commands with no knowledge at all,just common sense.But anyway,I've been programming in QB today and I came across a problem;the SUB and GOSUB command.Without these two commands,I will have a much harder time making big games and apps.Reply your technique or even reply techniques for game design.Thank you. :sleep:
User avatar
dosraider
Admin
Admin
Posts: 9243
Joined: Tue Mar 15, 2005 2:06 pm
Location: ROTFLMAO in Belgium.

Re: Qbasic Programmers,I need some help.

Post by dosraider »

tinman47 wrote:After a few weeks of studying QB,.......with a few or alot of commands with no knowledge at all,...a problem;the SUB and GOSUB command.
Image
Sorry for that.

Get real will ya ? If you even don't understand the SUB nor GOSUB lines, you hardly can state "I finally have a grasp on QB".
Put your lazyness aside and study a bit more. If you ever want to be able to program something : LEARN.
User avatar
emmzee
Site Admin
Site Admin
Posts: 2476
Joined: Sat Sep 14, 2002 2:25 pm
Location: Ontario, Canada

Post by emmzee »

Here's what seems to be a decent tutorial:

http://tedfelix.com/qbasic/

(It includes some info about how subs and functions work)
Owner / Webmaster of DOSGames.com for over 20 years

Download my free ebook: The Historical Reliability of the New Testament
User avatar
Swiftcutter
Expert
Expert
Posts: 146
Joined: Thu Jun 23, 2005 7:49 am

Post by Swiftcutter »

A sub (subroutine) is like a mini-program that you can run from the main program. That way, instead of typing the same code over and over at different places in your program, you can just make it a sub and run that.

Here's an example. This program will generate three random numbers between 1 and 10 and print them to the screen.

Code: Select all

'This part defines the sub. It must come before anything else in the program

SUB roll10

PRINT (INT(RND*10)+1)

END SUB

'This part is the main program. It runs (or "calls") the "roll10" sub three times.

RANDOMIZE TIMER
CLS

roll10
roll10
roll10
To keep things organized, Qbasic stores your subs separate from the main program code. Press F2 to access them.

Hope that helps. I'm moderately well-versed in Qbasic, so LMK if you have any more questions. :)
tinman47
Lord of Gaming
Lord of Gaming
Posts: 230
Joined: Sat Feb 24, 2007 1:07 pm

Post by tinman47 »

Great,this completely solved my problem!

Thanks...

FOR DESTROYING THE EVIL IN MY SOUL... :devil:
Post Reply