TIP: Click on subject to list as thread! ANSI
echo: quik_bas
to: ALL
from: DAVID AUKERMAN
date: 1998-03-15 15:44:00
subject: Code FAQ 03/98 02/12

'>>> Page 2 of CODE0398.FAQ begins here.
   The phrase "STRING * 20" means that 20 characters are reserved
   for the sub-variable Text.  Anything more than that assigned
   to Text will just be thrown away.
   Now, just like QB's "integer" type doesn't mean anything until
   it is assigned to a variable, your TYPEs don't do anything
   unless you define a variable as that TYPE:
   DIM Scr AS ScreenType
   At this point, you can use each of the elements (or sub-
   variables as I have called them) as if they were individual
   elements:
   Scr.X = 13
   Scr.Y = 50
   Scr.Color = 1
   Scr.Text = "Hello, world!"
   LOCATE Scr.X, Scr.Y
   COLOR Scr.Color
   PRINT Scr.Text
   Of course, you can't assign anything but an integer to
   Scr.X, because the element X was defined as an integer.
   Similarly, you can only put strings of 20 or fewer characters
   into Scr.Text because Text was defined as a string with 20
   chars.
2) WHAT ARE SUBS AND FUNCTIONS, AND HOW DO I USE THEM?
   SUBs and FUNCTIONs are very useful features in QB; these are
   very versatile and have many purposes and uses.  They have
   developed as a method of "modular programming," in which
   programming statements that form a routine are kept separate
   from other routines in order to organize the source code and
   help you, the programmer, read your code more easily.
   SUBroutines:  A SUB is a separated section of code that can be
   run at any time in a QB program.  A SUB groups together state-
   ments that work together to perform a certain task, such as
   getting input or performing calculations.  Using a SUB allows
   you to read your code more easily, to perform the same task as
   many times as necessary (as opposed to typing the same code
   over and over), and to (easily) use the same subroutine in
   more than one program.
   You can create a SUB by typing the following statement anywhere
   in a QB program:
   SUB NewSub
   The SUB name must start with a letter, but then can use letters
   or numbers.  Once you press Enter, you will be moved by QB into
   a new section of code, labeled "Filename.BAS:NewSub" at the top
   of the screen.  (Note:  Press F2 at any time to switch between
   your main program and any SUBs or FUNCTIONs.)  In this new area,
   you can enter any normal statements like you would in the main
   part of the program.  Any time you want that SUBroutine to be
   run, enter one of the following commands:
   CALL NewSub
   NewSub
   Each of these does the same thing:  control of the program is
   transferred to SUB NewSub, and the statements in that SUB are
   run until the line END SUB is reached.  (By the way, QB auto-
   matically puts that line in there when you create a SUB.)  You
   can even call a SUB from inside another SUB, or create
   recursive algorithms..the possibilities are endless!
   Any variables you use in the SUB are "local" to that SUB.  In
   other words, the variable names (such as Name$) mean nothing
   outside of that SUB.  You can even have a variable called
   Name$ in the main part of the program, and the two will be
   kept separate.  But suppose you want your new SUB to use the
   variable Name$ as it exists in the main program.  How can you
   "pass" that variable to the SUB?  Simply add it to the calling
   statement:
   CALL NewSub(Name$)
   NewSub Name$
   Any number of variables can be passed to a SUB:
'>>> Page 2 of CODE0398.FAQ ends here. Continued on next page.
___
 * SLMR 2.0 * Basic:  c = c + 1.  c++:  c++.
--- Maximus/2 3.01
---------------
* Origin: The I.O. Board - 4GB -XX- V34+ (1:2255/10)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.