3 x EXAMPLES OF QBASIC CODE WHICH USES 'INTERNAL' DATA STORAGE/WHERE THE DATA IS BEING STORED INSIDE OF THE ACTUAL PROGRAM ITSELF
====
QBASIC CODE: EXAMPLE/VERSION 3: PRINTING USING A MIXTURE OF ARRAY VARIABLES/DATA STATEMENTS LIST/LOOPS
EXPLANATION: This is a QBASIC programming technique which is used, regularly.
DATA statements need to be READ going all the way from 'top down to bottom' until when you can find whichever specific item that it is you want; this makes accessing such data 'slow'; especially, if the list of DATA statements tends to be very long to go READ through.
However, multi-compartment array variables...because each one has an index number: (n)...therefore, providing you already know which specific data item it is you want/together with it's related array name/index number...then, it's possible to access that data, immediately; without having to read through the entire array going all the way from 'top down to bottom'.
So, one way to resolve this problem of speeding up data access, is to use a FOR/NEXT loop to READ through the entire DATA statements list...whilst, at the same time, storing each data statement value inside of an array compartment, instead; and, then, we can can now get to access the data simply by calling it through the array. For example, if we already know that the 6th data item is "Agatha"; and, it's already been stored inside of the array called: names$...then, we can instantly access that particular data item by using the statement...
PRINT names$(6)
...output...
Agatha
=====
'*** set up a multi-compartment array variable to hold each of 10 names...
DIM names$(10)
'*** READ into each array compartment a name value using a FOR/NEXT loop...
RESTORE '...position the internal data pointer
'................to READ from 'start' of DATA statements list
FOR eachNameNo%=1 TO 10
READ names$(eachNameNo%) '...initialise array compartments with values
NEXT
'*** PRINT out each array compartment name value using a FOR/NEXT loop...
CLS '...(CL)ear the (S)creen
FOR eachNo%=1 TO 10
PRINT eachNo%;"> "; '...print out each FOR/NEXT loop number
PRINT names$(eachNo%) '...print out each array compartment name value
NEXT
END '...END of program/halt program code execution
'*** data statements list...
DATA "Jack","Jill","Tom","Dick","Harry","Arnold","Agatha","Joe","Jeremy","Jessica"
EXAMPLE 1 The QBASIC program will, automatically, *capitalize* any reserved 'keyword' which it finds once you've already gone and typed in a line of code; and, then, at the end of that code line, do finally press the [RETURN/ENTER] key...to confirm what you've just gone and typed in. A keyword might be say the PRINT command statement...so, if I were to type inside of the QBASIC editor the following line of code... print 1+1 ...then, the moment I press the [RETURN/ENTER] key when I get to the end of that line...the QBASIC interpreter program will, automatically, change the 'lower case' word: print...to become all UPPERCASE, instead; QBASIC Editor will display the previous line of code I typed in as being... PRINT 1+1 ...thus, I am able to tell immediately that PRINT is a special reserved 'keyword'/or, command statement which the QBASIC program, quite clearly, recognizes and understands. This also helps me the programmer to know if I actually typed in that 'keyword' either correctly/or, incorrectly; if wrong...and, the program did NOT automatically capitalize it...; then, I know I must have either accidentally 'misspelled' the keyword/or, must otherwise have done something to go get it wrong...?! EXAMPLE 2 If I were to type in to the QBASIC Editor program the following line of code using all 'lower case' letters... x=10: if x=10 then print "ten" else print "NOT ten" ...and, then, when I've reached the end of that line of code, press [RETURN/ENTER] key to confirm my code entry; the QBASIC interpreter program will, automatically, respond by capitalizing any reseved 'keywords' that it finds; then, QBASIC Editor displays the line of code I typed in as being... x=10 : IF x=10 THEN PRINT "ten" ELSE PRINT "NOT ten" Looking at this newly capitalized line...it tells me that... IF/THEN/ELSE/PRINT...are all QBASIC reserved 'keywords'. NOTE: Whatever is a string a text that is written in between double quote marks: ("") will be totally unaffected by such capitalizing; instead, text strings will be printed out, quite literally, 'as is'. FINAL NOTE There are far too many QBASIC 'keywords' for me to go and list here; possibly, a couple hundred...! QBASIC has many 'keywords' that it uses; if you wish to see what ALL of these keywords are; then, from inside of the QBASIC Editor program itself...do a combination key press of: [SHIFT] + [F1]...and, there you will see the Help file...that shows each 'keyword' you can use to write QBASIC programs with; as well as, offering a clear explanation/it shows 'example codes' demonstrating exactly how each of these 'keywords' should be used; just do 'copy & paste'/then, RUN the program to follow these examples along.
A histogram
There is no specific name. It is ten kilograms.There is no specific name. It is ten kilograms.There is no specific name. It is ten kilograms.There is no specific name. It is ten kilograms.
Aida Ten's birth name is Aida Ten Pastor.
Irina Ten's birth name is Irina Ten Pastor.
She doesn't have a last name.
Tenten is her real name
Arjan ten Broecke's birth name is Arjan Geert ten Broecke.
Joelle ten Damme's birth name is Joelle Nadine ten Damme.
-10
Decagon. A decagon is the name of a ten sided shape.
Corrie Ten Boom's birth name is Cornelia ten Boom.