Jonathan E. Sisk's
Pick/BASIC: A Programmer's Guide
Answers to Review Quizzes
Review Quiz 1
1) A symbol that contains data whose value may be changed.
2) ED filename item-id
EDIT filename item-id
3) BASIC filename item-id (to compile the program)
RUN filename item-id
BASIC filename item-id
CATALOG filename item-id
item-id (at the TCL prompt)
4) Non-executable statements which allow text comments to be inserted into the source code. Why? to explain variable names and usage, tricky logic, etc.
5) "$" or "."
6) STOP, if executed before physical end of program. END, if no more code.
7) An expression which derives a true or false. True is represented as numeric non-zero and false is zero or null.
8) None. It's a hardware problem.
Review Quiz 2
1) The PROMPT statement.
2) PROMPT ">"
3) An optional number at the beginning of a source line to which execution may be transferred with the GOTO or GOSUB statement.
4) GOTO statement.label (also GO TO statement.label) or GOSUB statement.label
5) MATCHES or MATCH
6) (a) "2N'-'4N'-'2N"
(d) "2N'/'1N'/'2N" or "1N0N'/'1N0N'/'2N0N"
7) As a terminator for a multiline THEN or ELSE clause, or to terminate program execution (when the END compiler directive appears as the last statement in a program).
8) When they occur between quotes, and between keywords and variables in a statement.
9) In remarks, to provide visual spacing for making the programs more readable.
10) NUMBER.OF.EYES = COUNT("MISSISSIPPI","I")
Review Quiz 3
1) Precedence determines the answer in expressions which do not contain parentheses.
2) The REM statement is a remark, or comment. The REM function divides one number by a second number, and returns the remainder of the operation. The REM function is always followed by parentheses, like all other functions.
3) Generates a random number.
4) (a) The line should read:
IF ANSWER = "Y" THEN PRINT "YES" ELSE PRINT "NO"
The END statement is not allowed in this single-line IF statement.
(b) The fragment should read:
IF ANSWER > 0 THEN PRINT "ANSWER > 0" END ELSE PRINT "ANSWER < 0" END
The END statement is required on any multiple-line IF statement.
(c) The code should read:
IF ANSWER = "N" THEN PRINT "ENTER ALTERNATE VALUE " : INPUT ALTERNATE.VALUE IF ALTERNATE.VALUE = "" OR ALTERNATE.VALUE <= 0 THEN PRINT "MUST BE ANSWERED OR POSITIVE!" END END
The interior, or nested IF statement must be terminated with an END statement.
Review Quiz 4
1) The EQUATE evaluates at compile time and requires less overhead at run time. The assignment evaluates at run time and is less efficient.
2) Statement A
3) COUNT determines the number of occurrences of a string within another string. DCOUNT determines the number of data items delimited by a given string.
4) Puts a process to sleep for some period of time. Give yourself an extra point on this one.
5) SLEEP 600
6) SLEEP 17:30
7) Returns the DECIMAL value of any ASCII character.
8) Generates a string of characters.
9) PRINT STR("-",10)
Review Quiz 5
1) Internal format is the way the computer views and stores data. External format is the human-readable form.
2) The ICONV function and the "D" conversion code.
3) To determine the day of the week:
BILL.DATE=ICONV(BILL.DATE,"D") PRINT OCONV(BILL.DATE,"DWA")
or, if you really want some punishment:
To determine when the bill should be paid:
BILL.DATE=ICONV(BILL.DATE,"D") DUE.DATE = BILL.DATE + 30 PRINT OCONV(DUE.DATE,"D2/")
4) PRINT OCONV(TIME(),"MTHS") or PRINT OCONV(TIME(),"MTH")
5) Generates a string of spaces.
6) The process of formatting output through the mask expression which follows the expression that it is to affect.
(a) NAME ADDRESS (b) 123 456 (c) NAMEL#15ADDRESS
8) variable = TIMEDATE() or PRINT TIMEDATE()
9) When you go to a restaurant and your waiter says, If you need anything else, my name is Jim, and you wonder what his name is if you don't need anything else.
Review Quiz 6
1) (a) PRINT CHAR(12): or PRINT @(-1):
(b) PRINT @(3,15): "HELLO THERE":
(c) PRINT @(-4):
2) INPUT variable,6
3) variable =ICONV("123456.78","MR2")
4) PRINT OCONV(5667788,"MR2,$")
5) The process of linking strings together, meaning that the strings are joined end to end to form a new string.
Review Quiz 7
1) The "[" and "]" characters are used in the text extraction or substring function. For example:
IF RESPONSE[1,1] = "Y" THEN PRINT "THANK YOU"
2) Initiates the CASE construct.
CASE conditional.expression statement(s)
4) BREAK OFF and BREAK ON disable and enable the break key, respectively.
5) Disables the output of PRINT statements to the printer. All subsequent PRINT statements direct output to the screen.
6) PRINTER ON causes all subsequent PRINT statements to be routed to the spooler, and possibly from there to the printer. There is no effect on CRT statements.
7) RUN filename program.name (P
8) Completes the current spooler entry (print job), and releases it to the spooler.
9) ECHO OFF disables the terminal echo function. All characters from this point on are not displayed on the screen as they are entered. ECHO ON enables the echo function.
Review Quiz 8
1) Searches through a string of characters delimited by a known delimiter, and returns a group (or field) of characters. Usually, the delimiter is not one of the reserved system delimiters.
NUMBER.DESTINATIONS = DCOUNT(DESTINATIONS,",") LAST.STOP = FIELD(DESTINATIONS,",",5)
3) Searches for a string of characters within another string of characters, and returns the starting character position of the string, if it is found.
4) PRINT INDEX(ALPHABET,"S",1)
Review Quiz 9
1) The STEP factor changes the normal value by which the variable in the NEXT variable statement is incremented. The incremental value is normally 1.
FOR I = 1 TO 100 STEP 2 . . NEXT I
FOR I = 100 TO 1 STEP -3 . . NEXT I
Review Quiz 10
1) The OPEN statement locates and establishes a physical address to a file. It is used before referring to the file for input or output.
2) These are the special reserved delimiters used to separate attributes, values, and sub-values. They indicate the end of one location, and the beginning of another.
ARRAY="BARNEY RUBBLE" ARRAY<2,1>="PO BOX 77" ARRAY<2,2>="141 BEDROCK PLACE" ARRAY<3>="BEDROCK" ARRAY<4>="CA" ARRAY<5>="19104"
PRINT ARRAY<1> PRINT ARRAY<2,1> PRINT ARRAY<2,2> PRINT ARRAY<3> : ", " : ARRAY<4> : " " : ARRAY<5>
5) After the first ICONV statement (note that the value is preceded by five attribute marks):
The second ICONV statement produces:
6) READ, READU, MATREAD, MATREADU
OPEN "INVOICE-FILE" TO INVOICE.FILE ELSE PRINT "INVOICE-FILE IS NOT A FILE NAME" INPUT RESPONSE STOP END READ INVOICE.ITEM FROM INVOICE.FILE,"S1000" ELSE PRINT "INVOICE S10000 IS NOT ON FILE" INPUT RESPONSE STOP END
8) The THEN clause may be followed by a statement, or statements, to execute when the item is found on file.
9) The ELSE clause may be followed by a statement, or statements, to execute when the item is not found on file.
Review Quiz 11
Review Quiz 12
OK, so there were no quizzes for these two chapters.
Review Quiz 13
If your program works, and does everything that was asked for, you passed the quiz.
Review Quiz 14
1) The EXECUTE statement allows a PICK/BASIC program to issue any TCL command, and optionally return the results to the program.
2) The CAPTURING clause indicates where the output from the TCL process will be directed.
3) The HEADING defines the text to appear at the top of each page of output on an ACCESS or PICK/BASIC report.
4) HEADING "'LC'Aged Trial Balance Report Page 'PLC' as of 'DL'"
5) The READNEXT statement retrieves the next item-id from a selected list of item-ids.
6) The PAGE statement issues a form feed between pages of output on a PICK/BASIC report.