--------------- FIDO MESSAGE AREA==> TOPIC: 125 QUICK BASIC Ref: F3N00005 Date: 03/18/98 From: BILL WHITE Time: 06:22pm \/To: RICK PEDLEY (Read 2 times) Subj: Old Folks RP> The sheer size of such a flow chart would minimize its usefulness RP> as a simplified overview. And how do you represent event-driven Windows RP> apps with flow charts? But whatever works for the individual, there's RP> no hard and fast rule. Several studies have been done however, that showed RP> flow charting made little or no difference in the quality of programs RP> written by high school and college students. I can't quote you any RP> sources unfortunately, it's been ten years or more since I left teaching. IF one were into flowcharts, they could be done on a broad scale, rather than every single branch. Somewhat like documenting. I will sometimes head large sections with a REMark, but I have seen programs (way back) that would have: REM print the value of A, stay on line PRINT A; REM print the value of A$ PRINT A$ No, I mean it: I have actually seen things that stupid. I see nothing wrong with "self-documenting" code, using variable names that have a human meaning - I remember when a BASIC I was using allowed only 2-letter variables. Now I'm allowed to use: DayOfWeek$ = "Tuesday" and that has meaning. DA$ did not! I may, if I'm going to write an involved program, sketch out a chart or list. It won't have the squares and diamonds, but will be a broad outline. Of course, if I must tell the truth, I usually just sit down and start typing and see what happens! FIDO: Bill White @ 1:135/110 (Miami) InterNet: bill.white@110.sunshine.com * SLMR 2.1a * Put love notes in your child's lunch box! --- Maximus 2.01wb * Origin: Miami Amateur Computer Club BBS/USR Courier V.E (1:135/110) --------------- FIDO MESSAGE AREA==> TOPIC: 125 QUICK BASIC Ref: F3N00006 Date: 03/18/98 From: BILL WHITE Time: 06:26pm \/To: RICK PEDLEY (Read 2 times) Subj: Old Folks RP> I'll sometimes REM out lines of code that didn't work and leave them there RP> so I won't make the same stupid mistake next time - does that count? :) Ah, yes, I'll do that. FIDO: Bill White @ 1:135/110 (Miami) InterNet: bill.white@110.sunshine.com * SLMR 2.1a * Don't pick up after your children. That's their job! --- Maximus 2.01wb * Origin: Miami Amateur Computer Club BBS/USR Courier V.E (1:135/110) --------------- FIDO MESSAGE AREA==> TOPIC: 125 QUICK BASIC Ref: F3N00007 Date: 03/15/98 From: MARKUS TREINEN Time: 10:14pm \/To: OLE HEJLSKOV (Read 2 times) Subj: help! ---- *Ole Hejlskov* mute am 13.03.98 zum Thema ---- *"help!"* folgendes blubbern: ;) MT>> I am glad to hear it :) I think, using Interrupts is the better and MT>> cleaner way to find MANY things out, including Diskspace. OH> Yep. You are right. OH> But i am not so good to program whdt interrupts.. :-( I wasn't either... But if you want, you can learn everything. The only thing, you have to know is how are Interrupts accessed and what parameters do they use. I recommend you to download the ASM86FAQ (go to ASM86.GER) or take INTRLIST.EXE which is a part of Rebel Assault 1 (The game from Lucasarts), but only of the english version. So if you get Rebel Assault (perhaps from a friend or so) you can take a look in the TOOLS (or so) directory and copy the Interruptlist. Then you will understand everything. If you give me the permission, I can send it to you via eMail. it is about 1,2MB. OH> Can you learn me something? INTRLIST will learn you EVERYTHING ;) No, that's not true, but it covers the most interesting topics (and most useful). Thiz Mail Copyright (C)1998 by Markus Treinen All Rights Reserved. --- BASIC V2.0 - (C)1981 * Origin: I love your blue-eyed voice... (2:2452/455.8) --------------- FIDO MESSAGE AREA==> TOPIC: 125 QUICK BASIC Ref: F3N00008 Date: 03/18/98 From: BERT VAN DAM Time: 09:32pm \/To: DAVID WILLIAMS (Read 2 times) Subj: Old Folks > Eons ago - in about 1981, to be more precise - I wrote an "interpreter" > for flowcharts. The user could draw a flowchart of a program on the > computer screen, and the machine would later execute the charted program > directly, without any need for re-writing the code in any other way. What an interesting idea! I don't suppose you still have this program? CU Bert --- GEcho 1.00 * Origin: Hotel Zeezicht (2:285/750.16) --------------- FIDO MESSAGE AREA==> TOPIC: 125 QUICK BASIC Ref: F3N00009 Date: 03/15/98 From: DAVID AUKERMAN Time: 03:41pm \/To: RICK PEDLEY (Read 2 times) Subj: Old Folks RP>It can really streamline your code at times. I love to use it when RP>testing for even or odd numbers, for example: RP>IF Number% AND 1 THEN 'odd RP>is much nicer than RP>IF Number% \ 2 <> Number% / 2 THEN Or even my old trick: IF Number% / 2 <> INT(Number% / 2) (before I found the \ operator) :) --David ___ * SLMR 2.0 * Death has been proven 100% fatal to all stupid people. --- Maximus/2 3.01 * Origin: The I.O. Board - 4GB -X< Anderson, IN >X- V34+ (1:2255/10) --------------- FIDO MESSAGE AREA==> TOPIC: 125 QUICK BASIC Ref: F3N00010 Date: 03/15/98 From: DAVID AUKERMAN Time: 03:44pm \/To: ALL (Read 2 times) Subj: Code FAQ 03/98 01/12 '>>> Page 1 of CODE0398.FAQ begins here. TYPE:BAS +-----------------------------------------------------------------+ | The Official FidoNet Quick Basic Echo's | | (F)requently (A)sked (Q)uestions | | CODE VERSION | +-----------------------------------------------------------------+ Code Version 2.32 Release Date: 3/15/98 Edited by David Aukerman of 1:2255/10 (knight1179@juno.com) Suggestions, questions, and answers from everyone in QUIK_BAS, too many to list. If you use code or ideas from here, make sure you give credit where credit is due. Topics covered in this FAQ: 0) Introduction 1) What are TYPEs, and how do I use them? 2) What are SUBs and FUNCTIONs, and how do I use them? 3) How can I produce a delay in my program independent of the CPU speed? 4) What are INTERRUPTs, and how do I use them? 5) Can I use INTERRUPTs with QBasic? 6) How do I use the mouse in QB? 7) How can I check for the existance of a certain file? 8) How do I perform a cold/warm boot through QB? 9) How can I print text in a graphics mode without destroying the background? 10) How can I animate sprites in QB? 11) Can I use VESA screen modes in QB? 12) Can I create a TSR in QB? 13) How can I make QB exit with an error level? 0) Introduction This is the Code FAQ! Hopefully your most common questions will be answered by this document. If not, go ahead and ask us at the FidoNet QUIK_BAS echo, or e-mail me (David Aukerman) and I'll get an answer from them (or, less occasionally, from myself). All full program pieces of code in this FAQ are designated by the [begin] and [end] markers. Just copy the code in between these two lines into your QB program, and it's ready to go! Note: Any time you see code with an underscore ("_") at the end of a line of code, you may need to connect the two lines surrounding it if QB doesn't do it for you automatically. For instance: PRINT "hello wo_ rld!" Should be: PRINT "hello world!" One more thing: any time you see the use of INTERRUPTs in a piece of code, be sure to load QB with the /L switch. ...Enjoy! 1) WHAT ARE TYPES, AND HOW DO I USE THEM? The TYPE statement lets you create your own data type, in addition to QB's integer, double precision, and string types, to name a few. You create a name for this new data type, and you can then make a list of normal variables that will become sub-variables in your TYPE. Think of a TYPE as a variable itself, and then the sub-variables as answering the question, "which part of that TYPE?" TYPEs are very good at organizing many different variables into one recognizable area. Here's an example of a TYPE: TYPE ScreenType X AS INTEGER Y AS INTEGER Color AS INTEGER Text AS STRING * 20 END TYPE '>>> Page 1 of CODE0398.FAQ ends here. Continued on next page. ___ * SLMR 2.0 * What time is it at the North Pole? --- Maximus/2 3.01 * Origin: The I.O. Board - 4GB -X< Anderson, IN >X- V34+ (1:2255/10) --------------- FIDO MESSAGE AREA==> TOPIC: 125 QUICK BASIC Ref: F3N00011 Date: 03/15/98 From: DAVID AUKERMAN Time: 03:44pm \/To: ALL (Read 2 times) Subj: 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 -X< Anderson, IN >X- V34+ (1:2255/10) --------------- FIDO MESSAGE AREA==> TOPIC: 125 QUICK BASIC Ref: F3N00012 Date: 03/15/98 From: DAVID AUKERMAN Time: 03:44pm \/To: ALL (Read 2 times) Subj: Code FAQ 03/98 03/12 '>>> Page 3 of CODE0398.FAQ begins here. CALL NewSub(Name$, Text$, File$) NewSub Name$, Text$, File$ However, the SUB statement you made at the very beginning must match *exactly* the TYPEs and number of variables in the calling statement: SUB NewSub(Name$, Text$, File$) PRINT Name$ PRINT Text$ PRINT File$ END SUB Notice that if you had SUB NewSub(Name$, Text$, File%), QB would not be able to run your program, since the TYPE of the third variable wouldn't be the same in both places. The SUB would be expecting an integer, but it would get a string. That isn't good. Those are the basics of SUBroutines. FUNCTIONs are *exactly* the same as SUBs, with one major difference. A FUNCTION returns a value to the calling procedure, and therefore must be used differently. For instance: a! = GetANumber! PRINT GetANumber! * 4 FUNCTION GetANumber! INPUT "Enter any number"; GetANumber! END FUNCTION This will ask for a number, ask for another number, and print the value of four times the second number. Parameters (the variables which are passed to a SUB or FUNCTION inside the parentheses) work the same way here, too: PRINT NewName$("David") FUNCTION NewName$(OldName$) PRINT "The old name was "; OldName$; "." INPUT "Enter the new name: ", NewName$ END FUNCTION Notice that there is only one legal way to call a FUNCTION, and to use parameters when calling a FUNCTION. One more note: once you save a file after creating one of the above examples, QB will put a DELCARE statement at the beginning of the program. For instance: DECLARE SUB NewSub (Name$, Text$, File$) If you change the parameter list after this statement is created, you will have to edit this statement manually to match the new parameter list. 3) HOW CAN I PRODUCE A DELAY IN MY PROGRAM INDEPENDENT OF THE CPU SPEED? Bill White answers this question very well (edited for format): [quote] In the past there has been extensive discussion in this echo of this subject, which brought out some problems. A summary of this discussion follows: The old BASIC statement we used for years: FOR i=1 to 1000: NEXT i is not independent of the CPU speed. You could use SLEEP 2. This, however, has problems: integer numbers only, user can hit _ANY_ key to jump out of it, and that key will be held in the buffer waiting to bite the next INPUT command unless dumped with DO: LOOP UNTIL INKEY$ = "" TIMER can be used - it ticks off 1/18.2 of a second: delay = 2 finish = TIMER + delay DO LOOP UNTIL TIMER => finish '>>> Page 3 of CODE0398.FAQ ends here. Continued on next page. ___ * SLMR 2.0 * Windows Error #6523: Not Enough Windows Errors --- Maximus/2 3.01 * Origin: The I.O. Board - 4GB -X< Anderson, IN >X- V34+ (1:2255/10)