|
|
Predeveloped Routines for BASICIf you have routines like these on a diskette when you come into the competition, and you know how to call them, then you'll be 15 minutes ahead of the next team who is trying to type them in and get them to work! AND IT IS ALL ALLOWED IN THE COMPETITION RULES
The sample codes for the Title subroutinePurpose
Usage
Code SectionSUB Title (progname AS STRING) 'Use the function CLS to clear the Screen CLS 'Print out all the information PRINT "Predeveloped routine in use!" 'Boast to the judges that you are good PRINT progname$ 'Print the Program name -- Change this for each program PRINT "by Grace Yau" 'Print the Programmer's name -- Change this before the competition PRINT "Team #1" 'Print the Team Number-- Change this before the competition END SUB The sample codes for the INPUT subroutinePurpose
Usage
Code SectionFUNCTION MyInput% (prompt AS STRING, min AS INTEGER, max AS INTEGER) 'Keep asking the user to enter a valid value which is between the upper 'and lower bound PRINT "Predeveloped routine in use!" 'Boast to the judges that you are good inputok$ = "NO" 'This controls when the DO-WHILE STOPS DO 'Print out the prompt, the upper limit and lower limit PRINT prompt$; "("; min%; "-"; max%; ")"; 'Get the input from the user INPUT "to use? ", ans% 'Check if the input value is out of range IF (ans% > max%) THEN PRINT "That's too large" ELSEIF (ans% < min%) THEN PRINT "That's too small" ; ELSE 'Set the flag to if there is no error in the input value flag$ = "YES" ENDIF 'Loop if input value is invalid out of range) LOOP WHILE inputok$ = "NO" MyInput%="ans%" END FUNCTION The sample code for the subroutine AnOtherTryPurpose
Usage
IF (AnOtherTry$( ) = "n") THEN STOP Code SectionFUNCTION AnOtherTry$ 'Keep prompting for answer until we get "y","Y","yes","Yes","YES" or '"n","N","no","No","NO". PRINT "Predeveloped routine in use!" 'Boast to the judges that you are good DO 'Prompt for the user see if he/she want to continue INPUT "Would you like to try again? (Y/N)", ans$ 'Check to see if the input is either y or n, if not reprompt 'result is the value pass back to the main program to tell whether 'the user want to continue or not IF (ans$ = "y" OR ans$ = "Y" OR ans$ = "yes" OR ans$ = "Yes" or ans$ = "YES") THEN result$ = "y" ELSEIF (ans$ = "n" OR ans$ = "N" OR ans$ ="no" OR ans$ = "No" OR ans$ = "NO") THEN result$ = "n" ELSE result$ = "unknown" END IF LOOP WHILE result$ = "unknown" 'Set the return value be the result (y or n) AnOtherTry$ = result$ END FUNCTION Last modified: February 11, 1999 07:51 PM by G. Yau (smith@enel.ucalgary.ca). |