LIST OF SHARK COMMANDS:
* (comment)
= (equal)
?
@ (at)
ACCEPT
APPEND
APRI
APPEND BLANK
APPEND FROM
APPEND TO
ARRAY or MATRIX
AVERAGE
BINLOAD
BINSPACE=
BINUNLOAD
BOX
BREAK
BROWSE
BROWSE FIELDS
BROWSE OFF
CALL
CANCEL
CASE
CHAIN
CLEAR
CLOSE
CLS
COLOR
Command & Field Redirection
COMMENT (*)
COMPILE
CONTINUE
COPY
COPY FILE
COPY STRUCTURE
COUNT
CREATE
CURSOR
DEBUG
DELAY
DELETE
DELETE FILE
DIM (Matrix or Array)
DIR
DIRF
DISPLAY
DO
DO CASE
DO WHILE
EDIT
EJECT
EDIT
ELSE
END commands
ERASE
FIELD
FIELDS=
FILES
FILES ... ENDFILES
FILES LIST
FILES=
FIND
FLUSH
GLOBAL
GO
HELP
IF
INDEX
INDEX ON
INDEX FROM
INPUT
KEY
LAST
LIMIT
LIST
LIST FILES
LIST MEMORY
LIST STRUCTURE
List SYSTEM variables
LOCATE
LOCK INDEXES
LOCK
LOOP
MATRIX or ARRAY
MAX
MIN
MODIFY
NEAREST
NOEFFECTS
NOTE
NOUPDATE
ON ERROR
ON ESCAPE
ON FIELD
ON KEY
OTHERWISE
OVERWRITE TO
PACK
PERFORM
POST
PROCEDURE
PRINT: See "SET PRINT"
PSTRING
QUIT
READ
RECALL
REINDEX
RELEASE
REMARK
RENAME
RENAME FIELD
REPEAT
REPLACE
REPORT GENERATOR
RESTORE
RESTORE GETS
RESTORE SCREEN
RETURN
RING
ROLL
RUN
SAVE
SAVE GETS
SAVE SCREEN
SCOPE
SCREEN
SCROLL
SEEK
SELECT
SET [environment controls]
SET ALTERNATE
SET COLOR
SET DATE
SET DEFAULT
SET DIR
SET FILTER
SET FORMAT
SET INDEX
SET LENGTH
SET LIBRARY
SET LINK
SET MARGIN
SET MENU [ON][OFF]
SET NETWORK [ON][OFF]
SET PRINT [ON][OFF]
SET RELATION [ON][OFF]
SET VIDEO
SET WIDTH
SKIP
SORT
SOUND
SPOOL
STATUS
STORE
STUFF
SUM
TABLES
TEXT
TOTAL
UNLOCK INDEXES
UNLOCK
UPDATE
USE
VARIABLES
WAIT
WINDOW
WRITE (WRITE command and the WRITE editor)
ZAP
COMMENT (*)
Place comments (or notes) in programs.
* <string>
Option:
<string> is any text line added after the asterisk (*)
The command * (or NOTE) is used for placing comments in a program. Shark ignores any line that starts with * (or NOTE). Since the compilation removes all the comment lines, the number of comments has no effect on the speed of the compiled program.
Notes can also be added with semicolon(;) at the END of any Shark command line. Be careful with the semicolon since placing a semicolon(;) at the BEGINNING of a line can disrupt any following Shark commands!
Example:
In a program: the three comment types are: * , ; , and NOTE as shown in the following examples:
* open employee data file: USE employee INDEX employee ;opening EMPLOYEE data file ordered by name NOTE these are examples of how to include comments in a program
= (equals)
Assign value to a memory variable, or to a field when a record is referenced as a vector of fields.
<memvar>=<exp> <file><num exp>=<exp>
Assigning values to memory variables. The first form of this command assigns a value to a memory variable; if the variable does not exist, it will be created. This command is equivalent to the STORE command (see STORE).
Treating a data file as a vector. The second form assigns a value to a field of a data file. In this form, [ and ] do not indicate an option, [ and ] have to be typed in. For instance, EMPLOYEE[3] is the third field, ADDR, of the EMPLOYEE data file. This is the only way to assign a value to a field with the = command. Normally, field values are assigned with the REPLACE command.
Special care must be taken when using this second form when the data file is opened with a macro (see USE). Opening a file with a macro allows a standard program to work with a wide variety of files, provided the compiler is told the data file structure.
Suppose a data file is opened with the following commands:
USE inven COMPILE ACCEPT 'Enter name of data file to use: ' to fil_nam USE &fil_nam
In this case, the compiled program assumes INVEN.DBF is in use, even though some other file with the same structure is actually opened. Therefore, if fil_nam='INVEN88', the proper way to reference the 3rd field of the open data file is inven[3], not inven88[3].
Examples:
1>cost=23.89 1>qty=45 1>? cost*qty 1075.05 1>employee[1]='Steiner' 1>n=6 1>order[n+1]='Short-sleeve golf shirts'
Note that the equals sign, or the REPLACE command, (=) is the only Shark command verb that does not appear at the start of a command line. All of the following are identical in effect:
1>employee[1]='Steiner' (i.e. replace EMPLOYEE[1] with 'Steiner') 1>REPLACE employee[1] WITH 'Steiner' 1>REPLACE name WITH 'Steiner'
?
Display expression or expression list.
? <exp list> ?? <exp list>
Option:
<exp list> the expression or expressions to be displayed
The ? command evaluates the expression or expressions in the list (remember the commas to separate the expressions in the list!) and displays the results on a new line. In particular, this command is often used to display the contents of memory variables and fields.
The displayed items are separated by blanks if SET RAW OFF (see the SET command; on is the default). When SET RAW ON, they appear side by side.
? with no expression displays a blank line; it is used for spacing on the screen and printer.
While the ? command moves the cursor to the beginning of the next line before the items are displayed, the ?? command displays the items at the current cursor position. The ?? command is used in programs to build lines of text on the screen or on the printer from several pieces.
For displaying matrixes, see Section 2.5.
Examples:
1. Displaying fields:
1>USE employee 1>GO 5 1>? fname Poyner 1>? fname,tel:no Poyner 403-1193
2. Using the ? command as a calculator:
1>b=7 1>? 25/5+b,b*2,b*b 12.00 14.00 49.00
3. A composite print line in a program segment (CUSTN and DEBIT are fields in the selected file):
amount=0 mcust=custn ? 'The amount of the invoice is: ' DO WHILE custn=mcust.AND..NOT.EOF amount=amount+debit SKIP ENDDO ?? amount
Note how the ?? at the start of the eighth command line continues print output from the third line without a newline.
@
Display data and data input request at specific line and column position on screen or printer, or erase the screen line starting at the specified coordinates.
@ <line,col> [SAY <exp> ][USING <format>] [GET <var>] [PICTURE <format>]
Example:
EXpreSSION=" " @ 5,10 say EXpreSSION get VARIABLE PICTURE '999' READ line the line number for the display, a numeric expression; the fractional part (if any) will be discarded col the column number for the display, numeric expression; the fractional part (if any) will be discarded
Options:
none erase the screen line starting at the specified row and column position; when printing, move print head to specified position SAY <exp> [USING <format>] SAY displays the expression, <exp>; if there is a USING clause, <exp> is displayed using the format specification <format> GET <var> [PICTURE <format>] GET asks for an input into the variable <var>; the present contents of the <var> is displayed; if there is a PICTURE clause, <var> is displayed using <format>. The input request is activated by the READ command
Example - To manage printouts:
YESNO='N' @ 23,18 SAY "Do you want to Print a copy?" get YESNO READ IF YESNO ='Y' SET PRINT ON LIST SET PRINT OFF ENDIF
The @ command is used in Shark programs, first, to display formatted data at specific locations on the screen or printer, and second, to prompt the user to type in data (in conjunction with the READ command). Example:
EXpreSSION=" " @ 5,10 say EXpreSSION get VARIABLE PICTURE '999' READ
If the SET FORMAT option is TO PRINT (see the SET FORMAT command), then the (formatted) data is sent to the printer and there can be no GET clause; otherwise the SET FORMAT TO SCREEN is in effect, and the data is sent to (and can be obtained from) the screen.
The keywords of the @ command: SAY, USING, GET, PICTURE cannot be in macros.
This command is often used for making input screens and reports in Shark. See the command TEXT that contains many elements of the @ command, and is usually used in preference to @ for full-screen input and output, and printed output.
If GET <var> is used, the variable, <var> must exist; it is not created by this command. The present value of <var> is shown on the screen; the new value typed in by the user becomes the contents of <var>; if <var> is a field, the field in the selected file is changed (i.e. a REPLACE is performed).
If no option is used in screen output, for instance @ 10,0, the line is cleared on the screen starting at the indicated column. When using a DOS printer, the print head is moved to the new position.
If there is no <format> clause, the variable is displayed as follows: fields are displayed with the width specified in the data file structure; string memory variables are displayed as stored; numeric variables are displayed as specified by the :PICTURE system variable (see Section 2.6).
The GET clauses are activated by the READ command. There can be no more than 64 GET clauses for a READ command. The GET clauses with their pictures are stored in a Get Table, which remains in effect after a READ until another GET clause is encountered or a CLEAR GETS command is encountered.
NOTES for users of DOS-type printers:
Line numbers go from 0 to 24, column numbers from 0 to 79. For the printer, the line number counter begins at 0 (line 1); it is reset to 0 by the EJECT command (see the commands: EJECT, SET EJECT, SET LENGTH TO). If there are several @ commands for the printer, each @ command must display past the display of the previous @ command (that is, if the first @ command displays at line1, col1, and the next at line2, col2, then either line1<line2, or line1=line2 and col1<col2). If the new print position is less than the current print position, the printer head is not moved by the @ command.
NOTES for users of Windows-type printers:
Printed output mimics the screen display, and is easily adjusted by "trial-and-error".
ACCEPT
Input request for strings.
ACCEPT ['<string>'] TO <str var> Option: '<string>' the prompt message
This command is used in Shark programs to request character information to be placed into a memory variable. The text in <string> will be displayed as a prompt message. Note that <string> has to be delimited by ' or by ", and may not be either a macro or a string expression. ACCEPT cannot be used to input data into a field or element of a matrix.
If the <memvar> does not exist, it will be created.
The optional character string is used as a prompt. A character expression cannot be used, but a macro is permitted, provided the macro expression includes quotation marks.
To input numeric or logical data, use the INPUT command. Example In a program:
ACCEPT 'Your name: ' TO name Your name: David Simco
The following illustrates use of a variable instead of a string as the prompt:
1>prompt='"This is a prompt: "' 1>ACCEPT &prompt TO hello This is a prompt: George 1>LIST MEMORY Name Type Width Contents PROMPT C 20 "This is a prompt: " HELLO C 6 George ** Total ** 2 variables... 26 bytes
APPEND
Append record to data file.
APPEND [FIELDS <field list> / TEXT <textfile> / OFF ]
Option:
FIELDS <field list> the fields to be edited during APPEND
Option:
OFF rather than generate an APPEND input screen, uses an exiting screen and its Get Table
The APPEND command without either the OFF or TEXT option allows the user to add records to the selected file. Once the command is given, the screen shows the new record in full-screen editing mode. For instance, if the selected file has 201 records, the screen will show record 202 with all fields filled with blanks; once record 202 is filled in, a blank record 203 is shown.
To exit from APPEND, use <End> (or Ctrl-W) once you have filled in the fields of the last record desired. If all the fields of the last record are blank, it will not be appended. To switch from APPEND to EDIT mode, press <PgUp>.
Note that APPEND is actually a special mode of EDIT; the only difference is that EDIT begins by displaying the current record, while APPEND adds a new blank record to the data file and displays that. All the editing fields are the same as in EDIT. See the EDIT command for the complete list of editing keys.
APPEND updates all index files in use.
Example:
1>USE employee 1>APPEND
Shark goes into screen editing mode and displays record 7 with all fields blank (the box showing editing keys is displayed when SET MENU is ON):
#1 EMPLOYEE.DBF APPEND Record 7 Page 1 REC: prev <PgUp> next <PgDn> delete ^U PAGE: prev ^K next ^L FILE: top ^<Home> bottom ^<End> DELETE: char <Del> to end of field ^Y APPEND MODE: begin ^<PgDn> exit <PgUp> EXIT: with save <End> no save ^Q NAME........... FNAME.......... ADDR........... CITY........... STATE.......... ZIP............ TEL_NO......... MARRIED........ SALARY......... YEAR_EMP....... DEPT........... ADD_1..........
Shark offers two options that allow users to format their APPEND and EDIT screens to their specific requirements.
APPEND OFF suppresses the standard APPEND/EDIT screen and uses an existing screen and its associated Get Table to accept the input. It is available only in a program.
Example in a program:
1>USE employee 1>CLS 1>TEXT add_empl 1>APPEND OFF
APPEND TEXT can be used in both conversational mode and programs. The following combines all the steps in the above example:
Example:
1>USE employee 1>APPEND TEXT add_empl
The input screen can be constructed with either @ GET or TEXT command. See @ and TEXT commands.
APPEND BLANK
Append a blank record to data file.
APPEND BLANK
Option:
BLANK [append blank record, no full-screen editing]
APPEND BLANK adds a blank record to the selected file, and sets the current record number to this record. The new record is not shown. The fields of such a record are usually filled by the user with the REPLACE, @ GET, or EDIT commands (or variants such as READ, =, TEXT, BROWSE).
APPEND BLANK updates all index files in use. When network is on, the file header is updated and the file is flushed to disk.
APPEND FROM
Append data to the selected file from another file.
APPEND FROM <file> [FOR <cond>] [SDF/SDF DELIMITED] [WITH <char>] <file> the name of the source file
Options:
FOR <cond> select by condition (not with sequential source files) SDF sequential source file SDF DELIMITED sequential source file with delimited fields SDF DELIMITED WITH <char> sequential source file with fields delimited with a specific character <char>
This command appends records from the source file <file> to the selected file. Fields are copied from the source file to the selected file into fields with the same name. Deleted records are not appended.
If a field in the source file has no matching field in the selected file, then the field is ignored. If a field in the selected file has no matching field in the source file, then the field is set to blank.
For character fields, if the field width gets smaller, then the field is truncated on the right; if the field width gets larger, then the field is padded with blanks on the right.
For number fields, if a number will not fit in the new field, digits are lost on the left side of the number. Be careful when moving numbers with different field widths. If the source field has more decimals than the target field, decimals on the right will be dropped. If the target field has too few positions to the left of the decimal point, the value will be lost and the field filled with a zero followed by asterisks.
The FOR clause is used to append a subset of the file specified. The condition <cond> is made up of memory variables and the fields of the source file; permitted only when the source is a data file.
If the structure of two data files is identical in all respects, the records are appended very quickly; otherwise the APPEND is done one field at a time. If a field name occurs only in the source file, its values will not be copied into the target data file. (To change the name of a field, use the
RENAME FIELD command) APPEND FROM updates all index files in use.
With any of the SDF options, Shark reads the sequential file, and each line is turned into a new record of the data file appended to the end. Each line must end with a carriage return (character 13) or a carriage return-line feed pair (characters 13 and 10). The characters of the line are placed in the new record one after another from the left. See the related command: COPY TO ... SDF.
APPEND FROM ... SDF assumes that fields are not trimmed or delimited.
With the SDF DELIMITED option, the line of the sequential file is regarded as a number of trimmed fields, separated by commas. Strings can, in addition, be delimited by quotation marks. These fields are placed in the fields of the data file from the left. The remaining fields of the data file (if any) are left blank; the remainder of the line (after all the fields are filled), if any, is ignored.
With the SDF DELIMITED WITH <char> option, the line of the sequential file is regarded as a number of fields, separated by commas with all character and logical values surrounded by <char>. Otherwise, this option is identical to SDF DELIMITED.
The functions to read and write sequential files give much better control over sequential files.
Important programming note: The APPEND FROM command automatically opens the FROM file in its internal work area; if the FROM file is already open in another work area, the compiler will assume it is closed when the APPEND FROM command is passed during execution, even if that command is in an IF, CASE or other structure module that is not executed!
Therefore, if there is any reference to the FROM file later in the program, open the file in the proper work area again immediately after the APPEND FROM command. If it is not actually needed after the APPEND FROM is executed (e.g., the program exits after the APPEND FROM), open it with the COMPILE keyword.
Example: USE#4 invoices COMPILE
Examples:
Example 1. Appending from a file with the same structure:
1>USE employee 1>COPY STRUCTURE TO empl1 1>USE empl1 1>APPEND FROM employee FOR name < 'Q' 3 APPEND(S) 1>LIST name 1 Marek 2 Balzer 3 Poyner 1>ZAP 1>APPEND FROM employee FOR tel_no < '5' 1 APPEND(S)
Example 2. Appending from a file with a different structure.
Append from EMPLOYEE.DBF:
The selected file is:
Datafile name : EMPL2.DBF Number of records: 0 Database selected is #1 Field Name Type Width Dec 1 NAME C 15 2 NAME1 C 10 3 ADDR C 5 4 CITY C 25 5 STATE C 2 6 ZIP C 5 7 TEL_NO C 8 8 MARRIED L 1 9 SALARY N 2 0 10 YEAR_EMP N 6 2 11 DEPT C 15 ** Record Length ** 95
EMPL2 has a field NAME1 that does not occur in EMPLOYEE; the field FNAME in EMPLOYEE does not occur in EMPL2. The ADDR field in EMPLOYEE has width 20, in EMPL2 it has width 5. The CITY field in EMPLOYEE has width 20, in EMPL2 it has width 25. The SALARY field in EMPLOYEE has width 9, in EMPL2 it has width 2. The YEAR_EMP field in EMPLOYEE has width 4, in EMPL2 it has width 6; but only 3 characters are available for the number to the left of the decimal point.
1>USE empl2 1>APPEND FROM employee 6 APPEND(S) 1>EDIT 1 #1 EMPL2.DBF EDIT Record 1 Page 1 REC: prev <PgUp> next <PgDn> delete ^U PAGE: prev ^K next ^L FILE: top ^<Home> bottom ^<End> DELETE: char <Del> to end of field ^Y APPEND MODE: begin ^<PgDn> exit <PgUp> EXIT: with save <End> no save ^Q NAME........... Marek NAME1.......... ADDR........... 231 R CITY........... Broomsdale STATE.......... MD ZIP............ 02110 TEL_NO......... 566-7012 MARRIED........ y SALARY......... 0* YEAR_EMP....... 0***** DEPT........... Maintenance
Note that ADDR was cut down to 5 characters; CITY was padded by 5 blanks; SALARY and YEAR_EMP indicate that there was not enough room for the numbers.
Example 3. Appending with the SDF option:
Use the EMPLOYEE file, and append from a sequential file: DATA.TXT. Give the commands:
1>USE employee 1>APPEND FROM DATA SDF
Let the first line of DATA.TXT be: Smith Robert 412 River Street
then the first three fields will be correctly placed. Note that the APPEND with SDF does not check for data correctness (numbers into numeric fields), for field width, etc. This option can be used if some other program already formatted the sequential file in absolute conformity with the structure of the data file.
Example 4. APPEND with the SDF DELIMITED option is easier to use:
Continuing the previous example,
Smith,Robert,412 River Street [or] 'Smith','Robert','412 River Street'
would do. It is important to have the fields delimited with quotation marks if any field contains a comma. Fields for which no data is supplied should be represented by commas as "place holders". For instance,
,,'412 River Street'
Example 5. APPEND with the SDF DELIMITED WITH <char> option works the same way:
Continuing the previous example, the command:
APPEND FROM <source> SDF DELIMITED WITH |
working on the following line
|Smith|,|Robert|,|412 River Street|
would append the record correctly. The use of a specified character other than single quote reduces or eliminates the concern about having commas, apostrophes and quotation marks in field contents. Fields for which no data is supplied should be represented by the specified character as "place holders". For instance,
||,||,412 River Street|
APPEND TO
Append current record to another file.
APPEND TO <num const> <num const> append record to file in select area <num const>
This command appends the current record from the selected file to the file numbered <num const>. The same rules apply as in APPEND FROM.
You can also append to the same file by giving its file number.
Examples:
1. Interactive use. There is a Backorder File; you are looking through it with EDIT or BROWSE to find which orders should be filled. Store "^Q;APPEND TO 4;BROWSE;^X;" into a function key, and whenever an order to ship is found, you press the function key. File 4 contains orders to be shipped.
2. There is a Name-and-Address file, and a label printing program that prints a whole file, the Label file. The Name-and-Address file is searched by the above method, and APPEND TO is used to put the addresses to be printed in the Label file.
3. A program segment. File 2 is a backorder file; each record contains 25 fields including Q1 to Q8, the quantities for the eight sizes. This program segment asks how much of each size should be shipped; the end result is that the items to be shipped are appended to the end of File 2, while the original record is changed to reflect the shipped quantities.
SELECT 2 STORE # TO gback APPEND TO 5 @ y,35 GET q1 @ y,39 GET q2 @ y,43 GET q3 @ y,47 GET q4 @ y,51 GET q5 @ y,55 GET q6 @ y,59 GET q7 @ y,63 GET q8 READ REPLACE quant WITH q1+q2+q3+q4+q5+q6+q7+q8 SELECT 5 REPLACE q1 WITH q1-q1#2,q2 WITH q2-q2#2,q3 WITH q3-q3#2 REPLACE q4 WITH q4-q4#2,q5 WITH q5-q5#2,q6 WITH q6-q6#2 REPLACE q7 WITH q7-q7#2,q8 WITH q8-q8#2 REPLACE quant WITH q1+q2+q3+q4+q5+q6+q7+q8 REPLACE type WITH 'O' APPEND TO 2 SELECT 2 GOTO gback
AVERAGE
Average numeric expressions for selected records.
AVERAGE <num exp list> [TO <memvar list> <scope>] [FOR <cond>] <num exp list> the numeric expressions to average Options: <memvar list> store the results in these memory variables <scope> select by scope (default scope: ALL) FOR <cond> select by condition
The command AVERAGE adds up numeric expressions for selected records of the selected data file and divides the result with the number of records summed. Up to 10 expressions can be averaged with one command. Optionally, the results can be stored in numeric memory variables; the expression list and the numeric memory variable list should have the same number of entries. <memvar list> cannot contain numeric mat
Records flagged as DELETED are not averaged.
Memory variables in <memvar list> need not exist; if any variable in the <memvar list> does not exist, this command creates it.
Example:
The average earning of the employees (in the data file EMPLOYEE), and the average year employment began:
1>USE employee
1>AVERAGE salary, year_emp
6 AVERAGE(S)
32502.16 1980.50
BINLOAD
Load a binary (assembly-language) program into memory.
BINLOAD <programname> <programname> a binary file to be executed under Shark; default extension BIN
Assembly-language programs may be copied from disk into a special area of memory called BINSPACE, which must be set aside with the BINSPACE= command in your SHARK.SET or SHARKNET.SET file.
When no longer needed, the program can be removed from the BINSPACE with the BINUNLOAD command, allowing room for another binary program to take its place. A maximum of eight binary files, with default extension BIN, may be loaded into memory at one time.
Once loaded into the BINSPACE, the program may be executed with the CALL command (see the CALL and BINUNLOAD commands).
Examples:
1>BINLOAD test
BINSPACE=
Reserve space in memory to BINLOAD binary files to be run with the CALL command.
BINSPACE=(SHARK.SET file only) <blocks> the number of 1K blocks of RAM to be reserved for loading BIN files with the BINLOAD command
Assembly-language programs may be copied from disk into a special area of memory called BINSPACE, which must be set aside with the BINSPACE= command in your SHARK.SET or SHARKNET.SET file.
The number of 1K blocks, to a maximum of 32, must be specified.
The BINSPACE is allocated above Shark's 64K data space and high memory, and reduces the amount of DOS memory available to execute commands with the RUN command.
Once loaded into the BINSPACE with BINLOAD, the program may be executed with the CALL command (see the CALL, BINLOAD, and BINUNLOAD commands).
Examples:
1>BINSPACE=16
BINUNLOAD
Remove a binary (assembly-language) program from memory.
BINUNLOAD <programname> <programname> a binary file to removed from memory by Shark; default extension BIN
Assembly-language programs, which are loaded into a special area of memory called BINSPACE by the BINLOAD command, may be removed from memory by the BINUNLOAD command when no longer needed.
This allows room for another binary program to take its place. A maximum of eight binary files, with default extension BIN, may be loaded into memory at one time.
Care should be taken not to create "holes in memory" by loading and unloading BIN files indiscriminately. For best performance, users are urged to load frequently called binary files first and not unload them; then transient or occasional binary programs can be loaded, called and immediately unloaded with the BINUNLOAD command.
(See BINLOAD and CALL commands.)
Examples:
1>BINUNLOAD test
BOX
Draw a box on the screen.
BOX <line1>,<col1>,<line2>,<col2> [DOUBLE] <line1>,<col1> the position of the upper-left corner of the box <line2>,<col2> the position of the lower-right corner of the box
Option:
DOUBLE use double line graphics, the default is single-line
The command BOX draws a box on the screen using the character graphics of the IBM non-graphics screen. If line1=line2, a horizontal line is drawn. If <col1>=<col2>, a vertical line is drawn.
<line1>, <line2>, <col1>, <col2> can all be numbers or numeric expressions; any fractional part will be disregarded.
This command is useful for making fancy menus, boxing messages, and for partitioning the screen into different viewing areas.
Note that commas are required between the numeric expressions used for the corner specifications, but a comma is NOT permitted before the DOUBLE.
The WINDOW command can also draw a box, but in addition limits relative screen output to the boundary of the window and can optionally set window and box colors. See the WINDOW command.
Examples:
1>ERASE 1>BOX 2,10,12,40 1>ERASE 1>BOX 3,0,8,20 DOUBLE 1>ERASE 1>BOX 10,0,10,70
BREAK
Exit to the bottom of a DO WHILE or REPEAT loop.
BREAK
The BREAK command is used only in programs, in a DO WHILE or a REPEAT loop to exit at the bottom of the loop. If there are nested loops, the exit is at the bottom of the innermost loop.
Contrast the command BREAK with the command LOOP which executes the condition at the top of the DO WHILE loop (see the LOOP command).
Caution: BREAK can be used only within a DO WHILE or REPEAT loop; used anywhere else will give an error with unpredictable results.
Example:
DO WHILE T <program segment> IF custn<>mcust BREAK ENDIF <program segment2> ENDDO
This program carries out <program segment> and <program segment2> until CUSTN becomes different from MCUST; then it jumps over <program segment2> and leaves the loop.
BROWSE
The BROWSE command displays the records (from the current record onward) horizontally, one record per line; it displays as many fields as will fit on a line. A column represents a field.
All fields are available to edit using the BROWSE command. If they don't all fit on your screen, they're visible by simply scrolling the screen left (^K) or right (^L). The scrolling commands are displayed at the top of your screen when you precede the BROWSE command with SET MENU ON.
If you want to see only a few fields, you can use BROWSE FIELDS which will display only the specified fields.
Options (all versions):
FIELDS <field list> specify the fields to be displayed APPEND add a blank record and start BROWSE in that record OFF rather than generate a BROWSE input screen, uses an editing screen and its Get Table TEXT <textfile> erases the screen, displays the text file, and then does BROWSE OFF
If the selected file is indexed, the records are displayed in the indexed order.
When the APPEND keyword is used, a blank record is appended to the data file and BROWSE begins in that record. The user may alternate between normal BROWSE and APPEND modes with the Ctrl-<PgDn> and <PgUp> editing keys.
All the full-screen editing keys can be used. Note that they have the same meaning as in EDIT, but sometimes they look different. For instance, the next record command (<PgDn> or Ctrl-C) gives a new screen in EDIT; in BROWSE, it simply moves the cursor down one line.
Editing keys:
<left arrow> or Ctrl-S moves the cursor back one character <right arrow> or Ctrl-D moves the cursor forward one character Ctrl-<left arrow> moves to the beginning of the field Ctrl-<right arrow> moves to the end of the field <Ins> or Ctrl-V puts you in insert mode: what you type gets inserted (normally, you are in overtype mode: what you type overtypes the existing text); pressing <Ins> or Ctrl-V again, puts you back into overtype mode <Backspace> deletes the character to the left of the cursor <Del> or Ctrl-G deletes the character on the cursor Ctrl-Y deletes the rest of the field <up arrow> or Ctrl-E moves the cursor to the previous field <dn arrow> or Ctrl-X moves the cursor to the next field Ctrl-<PgDn> enters APPEND mode; adds a blank record and places the cursor in that new record. Deactivated by SET SAVE OFF and SET APPEND OFF; in network mode, deactivated when data file opened in READ mode Ctrl-Q quits and does not update the current record <End> or Ctrl-W quits and updates the current record <PgUp> or Ctrl-R moves to the previous record; when in APPEND mode, exist to normal BROWSE mode <PgDn> or Ctrl-C moves to the next record Ctrl-L (i.e. ^L) redraws the BROWSE screen with the next screenful of fields, referred to as the next "page"; if the file has no more fields, this key is ignored Ctrl-K (i.e. ^K) redraws the BROWSE screen with the previous screenful of fields, referred to as the prior "page"; if the screen is already at the first field, this key is ignored Alt-E skips one screenful of record data toward the beginning of the file and redisplays the BROWSE screen Alt-X skips one screenful of record data toward the end of the file and displays the BROWSE screen Alt-W when cursor is in a memo field, saves the current screen and opens current memo in read-write mode in the WRITE editor; on exit from WRITE, the screen is restored Alt-R when cursor is in a memo field, saves the current screen and opens current memo in read-only mode in the WRITE editor; on exit from WRITE, the screen is restored BROWSE should be used to edit columns of data in a data file; that is, to edit a few fields of a number of records. Use the command EDIT to edit many fields of a single records at the same time.
The option FIELDS <field list> selects the fields to be displayed on the screen.
SET MENU ON causes a small display at the top of the BROWSE screen, giving the use of major editing keys.
Examples:
1>USE customer 1>BROWSE
Displays the following:
#1 CUSTOMER.DBF SharkBase BROWSE Page 1 REC: prev/PgUp Next PgDn SCROLL: Left/^K Right/^L SCREEN: Up/@E Down/@X FILE: Top/^Home Bottom ^End MEMO EDIT: @W DELETE: To EOL/^Y Record/^U APPEND MODE: Begin/^PgDn Exit/PgUp EXIT: With save/End No save/^Q CUSTNU FIRSTNAME LASTNAME ADDRESS 1 BROS50 Stan Brown 786 Alexander Rd. 2 BURS50 Sid Bursten 876 Main St. 3 GRAG50 George Gratzer 876 Arlington Avenue 4 MELB50 Bernie Melman 9876 Ocean View Parkway
To edit the home and work telephone numbers of the customers, issue the command:
1>USE customer 1>BROWSE FIELDS name,hphone,wphone
The display:
#1 CUSTOMER.DBF SharkBase BROWSE Page 1 REC: prev/PgUp Next PgDn SCROLL: Left/^K Right/^L SCREEN: Up/@E Down/@X FILE: Top/^Home Bottom ^End MEMO EDIT: @W DELETE: To EOL/^Y Record/^U APPEND MODE: Begin/^PgDn Exit/PgUp EXIT: With save/End No save/^Q LASTNAME HPHONE WPHONE 1 Brown 9238423472 3984747238 2 Bursten 7658956 6575777 3 Gratzer 7866457 7657655 4 Melman 8765678 6765777
BROWSE FIELDS
This is a simpler variation of the BROWSE command that is different enough to be listed as a separate command. Although one can BROWSE fields directly as in "BROWSE NAME, ADDRESS, ETC", the result will be different in look & feel from using the BROWSE OFF command. It can be used in both programs or conversational mode:
Example in conversational mode:
BROWSE [FIELDS <field list>/[OFF]/[TEXT] <textfile> [APPEND]
BROWSE OFF
SharkBase offers another option that allows the user to format a BROWSE screens to one's specific requirements.
BROWSE OFF suppresses the standard BROWSE screen and uses a much more descriptive formatted display. It is available only in a program.
Example in a program:
*test.prg USE#1 PRODUCT SELE 1 CLS TEXT Use ↑ or ↓ to scan items - Esc to Quit: CUST KGS NET COST CHRGE CUST ($Ca) ($US) @CUST @KGS @COST @US_INVOICE ENDTEXT BROWSE OFF CLOSE ALL
CALL
Execute a binary (assembly-language) program
CALL <programname> <argument> <programname> a binary file to be executed under Shark; default extension BIN
Option:
<argument> a character memory variable used to transfer data to and from a BIN program; maximum 254 characters
Assembly-language programs, which have been copied from disk into a special area of memory called BINSPACE, can be executed internally by Shark.
Running a binary file requires three steps:
1. Allocate memory in the SHARK.SET or SHARKNET.SET file using the BINSPACE=n
where
2. BINLOAD the program. A program need only be loaded once (unless it is removed with the BINUNLOAD command). Additional requests to BINLOAD the program will reload it in the same memory space. Up to eight binary programs may be loaded at once. Example: BINLOAD test. (BIN program may be removed from memory with the BINUNLOAD command.)
3. CALL the binary program, with an optional argument of up to 254 bytes in a memory variable. The binary program may modify or replace the contents of this variable, but may not create or lengthen the contents; when execution is completed, the variable will have a new value.
See BINLOAD and BINUNLOAD commands.
Example:
The binary program, listed below, merely overwrites the first three characters of a passed string with the string "SHARK".
dummy='1234567890' CALL test dummy ? dummy
The current value of dummy would then be printed: "SHARK67890".
Rules for BIN programs:
1. BIN programs are created in assembly language and assembled into an OBJ file with Microsoft's MASM program or equivalent, linked into a EXE file with LINK or equivalent, and converted into a BIN file with the DOS utility EXE2BIN.
2. The following is an example of an assembly-language module that accepts an input string in a memory-variable passed to the module on the CALL command line, modifies it, and passes it back in the same memory variable.
;TESTBIN.ASM -- A sample program to illustrate the Shark BINLOAD and CALL facilities ; ;By Bernie Melman ; ;This routine replaces the first five characters in a passed string with the characters SHARK ; ; Assemble with Microsoft Macro Assembler (MASM) version 5.0 ; LINK to produce an EXE file (ignore the "No stack" warning) ; EXE2BIN to generate BIN file ; _prog segment byte assume cs:_prog dtest proc far mov [bx+0], byte ptr 'S' mov [bx+1], byte ptr 'H' mov [bx+2], byte ptr 'A' mov [bx+3], byte ptr 'R' mov [bx+4], byte ptr 'K' mov ax,0 ;try changing bp to see if Shark ; can recover regs ok mov bp,ax ;do it ret dtest endp _prog ends end
3. No argument is required, but if one is used, it must contain a string which the program can evaluate in location BX. Shark places a NUL (zero byte) after the string as a terminator; if the program processes characters until a zero is encountered in a byte, the entire string has been processed. Any part of the string following the NUL is ignored by Shark.
4. The maximum length of a Shark string is 254 bytes; therefore, no more than 254 characters can be communicated to or from a binary program.
5. The BIN program cannot change the memory allocation of the argument variable. Therefore, it cannot successfully enlarge the argument string. It can shorten the result by terminating the result with a NUL (zero byte).
6. Sufficient space to load binary files must be provided with the BINSPACE= command in the SHARK.SET or SHARKNET.SET file; and no more than eight binary files may be loaded at any one time. BIN files can be removed from memory with the BINUNLOAD command.
CANCEL
Leave Shark program.
CANCEL
The command CANCEL aborts the Shark program and enters the interactive mode; the Shark prompt appears. See also QUIT.
Example: A Shark program segment:
CASE ans='8' QUIT CASE ans='9' CANCEL
If the user chooses Option 9, the result will display the interactive Shark prompt. Option 8 exits to the operating system.
CASE
The switch in the DO CASE program structure.
CASE <cond>
<cond> if the condition is satisfied, the program segment which follows should be executed
CASE is the keyword in the DO CASE program structure. Shark evaluates the condition; if the condition is true, the following program segment is executed. The program segment is terminated by the next CASE, by OTHERWISE, or by ENDCASE. After the execution of the program segment, the program execution continues with the program line after the ENDCASE command. If the condition is false, Shark looks for the next CASE command. If no condition is true, Shark executes the program segment following the OTHERWISE command (if any).
Note that when more than one <cond> is true in a DO CASE structure, only the program segment for the first is executed.
See the command DO CASE
CHAIN
Leave the current Shark program and start running a new Shark program.
CHAIN <program>
<program> = the name of the Shark program to be run
The command CHAIN is used for executing an Shark program from within another Shark program or in the interactive mode from the Shark prompt. The program name <program> should not have an extension. If there is a compiled program by this name (normal extension CPL; runtime extension RPL), it will be run. If there is none, Shark will run the uncompiled program (extension PRG).
CHAIN does a CLEAR first, except that all global memory variables are preserved and passed to the <program>; to use them, the <program> must have a GLOBAL command declaring the variables. (See the commands CLEAR and GLOBAL.)
The CHAIN command does not return to the calling program; the program in memory is replaced by the program it chains to.
CHAIN is the most efficient way for one program to call another. The DO command calls a subroutine from the disk. DO can often be replaced by PERFORM or by CHAIN. (See the commands DO and PERFORM).
When you chain from one program to another, Shark executes a CLEAR command before the start of the program, closing all the data files, index files, sequential files, and releasing all (but the global) variables. When you DO one program from another, the subroutine you do inherits the existing environment -- memory variables, data files, index files, etc. -- and returns to the DOing program when completed or when a RETURN command is executed.
CHAIN allows the program name to be a macro.
Example:
TEXT [1] CUSTOMERS [2] INVENTORY [3] ORDERS ENDTEXT DO menu; calls a menu program which returns a menu choice as "ans" DO CASE CASE ans='1' CHAIN prog1 CASE ans='2' CHAIN prog2 CASE ans='3' CHAIN prog3 ENDCASE
This program segment chains to three different programs, depending on the value of ANS.
Close all data files and index files, and clear memory variables. Optionally clear current Get Table or keyboard buffer.
CLEAR [GETS/KEYBOARD]
Options:
GETS clear the Get Table from memory KEYBOARD delete all characters from the keyboard buffer
The CLEAR command with no options closes all open data files and index files, and releases all memory variables, including the matrix variables. (Sequential files, DOS files, system variables, and in particular, function keys, are not effected).
Example:
1>a=2 1>name='David Barberr' 1>avco='clear' 1>LIST MEMORY Name Type Width Contents A N 8 2 NAME C 13 David Barberr AVCO C 5 clear ** Total ** 3 Variables used 26 Bytes used 1>CLEAR 1>LIST MEMORY Name Type Width Contents ** Total ** 0 Variables used 0 Bytes used
CLEAR GETS removes the current Get Table from memory. (See READ and ON FIELD commands.)
CLEAR KEYBOARD eliminates any characters held in the keyboard buffer. Normally, characters typed at the keyboard are stored in a special buffer until Shark is ready to process them, but occasionally the programmer will want to be sure nothing is in the buffer before executing certain commands. For example, CLEAR KEYBOARD before executing the MENU( function to ensure that a key pressed earlier in the program, or even in a previous program, does not inadvertently trigger a menu selection.
Caution to dBASE programmers: The CLEAR command in dBASE III and later versions erases the screen, but its function on Shark relates to clearing memory and is quite different. To clear the screen, use the CLS command (or the ERASE command)
CLOSE
Close the selected file.
CLOSE [ALL]
Option:
ALL close all data files in use
The CLOSE command closes the selected data file, updates all information to the disk, and releases the data record buffer space (see Appendix A.1) used by this file. Any index files attached to the data file are also closed, and any limits, relations and filters associated with the data file are cleared.
With the option ALL, all data files in use are closed.
Examples:
1>CLOSE 1>CLOSE#3 1>CLOSE ALL
CLS (or ERASE)
Use CLS (or ERASE) to erase entire screen:
CLS
This command erases the screen, and is a synonym for ERASE.
Option:
CLS <line1>,<line2> erase from line1 to line2
If, optionally, two numeric expressions, line1 and line2, are given, it erases line1 and line2, and all lines between, if any. On a typical emulator display (80 characters x 24 lines), these expressions should have values from 0 to 24.
CLS is the same as the following three commands:
ERASE CLS 0,24 ERASE 0,24
Examples of CLS:
1>CLS 1>CLS 2,4
To erase line 12 only:
1>CLS 12,12
To erase a portion of a line:
@22,42 say " "
COLOR
Set the color attributes of a box on the screen.
COLOR <attrib>,<line1>,<col1>,<line2>,<col2>[,<fillchar>] <attrib> numeric expression between 0 and 255, the attribute <line1>,<col1> the position of the upper-left corner of the box <line2>,<col2> the position of the lower-right corner of the box
Option:
<fillchar> the ASCII number of the character used to fill the colored area;
Every character position enclosed in the area described by the row and column values is changed to the fill character
For color monitors, both the background and the character are color, identified separately. These attribute bytes are set for a rectangular area by this command.
The area is given by four numeric expressions -- line1, col1, line2, col2 -- as in the BOX and WINDOW commands. The values must be separated by commas.
Compute ATTRIB by adding up (up to) four numbers (background+ foreground+blink+brightness) from the following tables:
Color Examples:
COLOR 7 (default) | grey on black (7+0+0=7) |
COLOR 15 | white on black (15+0=15) |
COLOR 23 | grey on blue (7+16=23) |
COLOR 30 | yellow on blue (14+16) |
COLOR 31 | white on blue (15+16=31) |
COLOR 36 | red on green (4+32=36) |
SET COLOR TO 18 | Sets DEFAULT to green on blue (2+16=18) |
SET COLOR TO 31 | Sets DEFAULT to white on blue (15+16=31) |
SET COLOR TO 208 | Sets DEFAULT to black on pink (0+208=208) |
COLOR 112 | black on white (0+112=112) |
NOTE: The correct syntax within a program is:
COLOR <attrib>,<line1>,<col1>,<line2>,<col2>[,<fillchar>]
When filling an area with a fill character, as is often done in designing sign-on screens for example, the pattern characters 176 to 178 and the solid reverse character 219 are especially useful.
See also SET COLOR TO <num exp> and :COLOR=<num exp>, which set the attribute bytes of the characters displayed. SET COLOR TO 0 turns the command off: the attribute bytes remain unchanged at the displaced locations. If a part of the screen already has attributes set by the COLOR command and SET COLOR TO 0, the newly displayed characters will keep the attributes set by the COLOR command.
Examples:
1. This snippet
1>COLOR 18,2,0,12,79
sets background blue and foreground green in lines 2 to 12, as in the above table.
2.The various settings can be saved as memvars and recalled:
1>back=80 1>foregrnd=1 1>bright=8 1>line=2 1>col=0 1>x=18 1>y=50 1>COLOR back+foregrnd+bright,line,col,line+x,col+y
3. The following Shark program illustrates the use of the COLOR command:
DIM NUM matrix[10] REPEAT 10 TIMES VARYING i matrix[i]=MOD(i,7)*16+7 ENDREPEAT ERASE REPEAT 10 TIMES VARYING i COLOR matrix[i], 12-i, i*5, 12+i, 10+i*5 DELAY .5 ENDREPEAT ERASE COLOR 23, 0, 0, 24, 79 REPEAT 10 TIMES VARYING i BOX 1+i, 7+i*3, 23-i, 73-i*3 DELAY .15 ENDREPEAT REPEAT 10 TIMES VARYING i COLOR matrix[i], 1+i, 7+i*3, 23-i, 73-i*3 DELAY .5 ENDREPEAT
4. All output to an area of the screen may be made invisible by making the background and the foreground color the same. For example,
SET COLOR TO 0 COLOR 0,10,0,13,79
turns rows 10 to 13 to black on black. Editing fields for entering passwords may be so protected.
5. A set of overlapping frames can be created with pattern characters used as fill:
COLOR 7,10,10,16,70,176 ;a shadow pattern COLOR 7,09,09,15,69,219 ;a solid pattern COLOR 7,10,10,14,69,32 ;fill with blanks to create area for text
For more information on setting colors system-wide for all programs at the same time, see the SET COLOR section below.
COMPILE
Compile a Shark program.
COMPILE <file> <file> the name of the program file
The COMPILE command may be given in interactive mode, or in a program:
1>COMPILE prog
where PROG is a file with PRG extension, the source program to be compiled. <file> cannot be a macro, and should not have any extension specified.
If your main program calls a series of sub-programs (subroutines), the COMPILE instruction will compile the entire set into one completed executable CPL program. If "main.prg" calls "sub1.prg", "sub2.prg", "sub3.prg", for example, calling "COMPILE MAIN" will verify and assemble and save all the "sub" programs into a final "MAIN.CPL". Then, to run the series of programs, all you need to do is enter "DO MAIN" at any time afterward.
Similarly, if you wish to compile many previously compiled separate programs in one step, create a program (call it, say, PROJECT.PRG) as follows:
COMPILE prog1 COMPILE prog2 COMPILE prog3
This will compile all the "progs" (PROG1.prg, PROG2.prg, PROG3.prg) as separate programs which can be called individually at any time any one of them is needed.
1>DO PROJECT
will compile PROG1.prg, PROG2.prg, PROG3.prg. The "DO" source program (PROJECT.PRG) should not use any memory variables, since a CLEAR is executed before every COMPILE command. You can also specify "SET ECHO ON" to have all program lines displayed as they are compiled.
The COMPILE command has another very useful purpose! Because of its speed, it can be used as a pseudo "MAKE" tool since it will test and verify every part of a batch of PRG files being compiled. Older DBF programs such as dBase and Clipper must be tested by running and debugging each PRG manually which is an extremely slow and tedious process!
Continue to LOCATE from the current record.
CONTINUE
CONTINUE will carry on locating from the current record using the condition of the last LOCATE command. (See the LOCATE command.)
Note that the standard strings stored in function key F8 combines a CONTINUE and an EDIT command. Once a LOCATE has been executed (function key F8), each additional matching record can be edited by pressing F8.
Example:
1>LOCATE FOR name<'S' 1>EDIT 1>CONTINUE
COPY
Copy selected records of the selected file into a new file.
COPY <scope> TO <file> [FIELDS <field list>] [FOR <cond>] [SDF/] SDF DELIMITED [WITH <char>]
<file> is the name of the file the records are copied to.
Options:
<scope> select records by scope (default scope: ALL) FIELDS <field list> copy only selected fields FOR <cond> select records by condition SDF copy into sequential file SDF DELIMITED separate fields by commas SDF DELIMITED [WITH <char> separate fields by specified character
The command COPY is used for moving records from the selected file to a new file, <file>; if a file by the name <file> already exists, it will be overwritten.
If the SDF option is not used, the result will be a data file with the default extension DBF and the same structure as the source file, unless the FIELDS keyword is used with a fields list.
When the SDF option is used, the result is a text file, with the default extension TXT. When the DELIMITED keyword is not used, each record (or its selected fields) becomes one line in a sequential file; the fields are all merged.
With the SDF DELIMITED option, the fields are separated by commas, and strings are enclosed in single quotes ('). A different string delimiter can be specified with the WITH clause: example WITH |. The specified delimiter character is not enclosed in quotes.
For a discussion of the SDF option, see the command APPEND FROM.
Examples:
1>USE employee 1>COPY TO empl1 6 COPY(S) 1>USE empl1 1>DELETE 5 1 DELETE(S) 1>COPY TO empl3 5 COPY(S) note: deleted records are not copied 1>RECALL ALL 1>COPY TO empl4 FOR salary <25000 .AND. year_emp>1980 1 COPY(S) 1>COPY TO empl4 FOR salary <25000 SDF DELIMITED WITH | 1 COPY(S)
The result of the last command is a sequential file EMPL4.TXT with one line as follows:
|Marek|,|Mark|,|231R|,|Broomsdale|,|MD|,|02110|,|566-7012|,|y|, |11500|,|1984|,|Maintenance| 1>COPY TO empl5 FOR salary <25000 FIELDS name,fname SDF DELIMITED WITH | 1 COPY(S)
The result of the last command is a sequential file EMPL5.TXT with one line as follows:
|Marek|,|Mark|
COPY FILE
Copy disk files.
COPY FILE
<source> = the name of the file to be copied <dest> = the name of the file after the copy
The COPY FILE command copies a file from the disk to another name and/or location. As in DOS, a file cannot be copied to itself.
If no extension is given, the extension DBF is assumed. Wildcards are not permitted.
Important: Do not use COPY FILE on open files, either as source or destination.
On a network with SET NETWORK ON in SharkBase Network Edition, attempting to overwrite a file while another user is accessing it will cause a LOCK error.
Examples:
1>COPY FILE cust a:cust ;data file to floppy 1>COPY FILE cust cust2 ;data file to new name, also DBF 1>COPY FILE cust TO cust.dbk ;file to data backup DBK file 1>COPY FILE edit.prg TO a:edit.prg ;program file to floppy
COPY STRUCTURE
Create a new file with the structure of the selected file.
COPY STRUCTURE TO <file> [FIELDS <field list>]
Note: <file> = the name of the new file
Option:
FIELDS <field list> copy only these fields
The command COPY STRUCTURE creates a new data file with the same fields as the selected file, but with no records. The default extension is DBF.
If the FIELDS option is used, the new structure will contain only the fields listed.
Example:
1>USE employee 1>COPY STRUCTURE TO emp1 1>COPY STRUCTURE TO emp2 FIELDS name,fname,salary,married 1>USE empl2 1>LIST STRUCTURE Data file: EMPL2.DBF Number of records: 0 File number: 1 Field Name Type Width Dec 1 NAME C 15 2 FNAME C 10 3 SALARY N 9 2 4 MARRIED L 1 ** Record Length ** 36
COUNT
Count selected records.
COUNT <scope> [TO <memvar>] [FOR <cond>]
Options:
<scope> select by scope (default scope: ALL) TO <memvar> store result in memory variable FOR <cond> select by condition
This command counts the number of records that meet the selection criteria. Selection is by scope and/or by condition. The result may be stored in a numeric memory variable; if the variable does not exist, this command creates it.
Note: <memvar> cannot be a numeric matrix variable.
The result of the command COUNT is displayed if SET TALK ON, as in the examples below.
Examples:
1>USE employee 1>COUNT 6 COUNT(S) 1>GO TOP 1>COUNT NEXT 3 FOR name <'O' 2 COUNT(S) 1>GO TOP 1>COUNT FOR salary < 50000 TO raise 1>? raise 5.00
CREATE
Create a new data file.
CREATE <file>
Note:lt;file>= the data file to create
The command CREATE is used to make a new data file, <file>; <file> cannot be a macro. (Do not use COMP for the first four letters of a data or index file; Shark is unable to open such a file.)
File creation is a special form of full-screen editing. Each field is represented by four editing fields.
Editing keys: <Left> or Ctrl-S moves the cursor back one character <Right> or Ctrl-D moves the cursor forward one character Ctrl-<Left> moves to the beginning of the editing field Ctrl-<Right> moves to the end of the editing field <Ins> or Ctrl-V puts you in insert mode: what you type gets inserted (normally, you are in overtype mode: what you type overtypes the existing text); pressing <Ins> or Ctrl-V again, puts you back into overtype mode <BACKSPACE> deletes the character to the left of the cursor <Del> or Ctrl-G deletes the character on the cursor Ctrl-Y deletes the rest of the editing field <Up> or Ctrl-E moves the cursor to the previous editing field <Dn> or Ctrl-X moves the cursor to the next editing field Ctrl-Q quits and does not create the file <End> or Ctrl-W quits and creates the file Ctrl-K moves back to the top of the previous page Ctrl-L moves to the top of the next page Ctrl-N inserts a line for a new field Ctrl-T deletes the line describing a field
Shark supports four separate type of data files as follows:
Type 0 - The default type; can have up to 256 fields in VP-Info and up to 500 fields in Shark. Allows up to 4 billion records in Shark. In essence, this is an unlimited number of records. The Type 0 file is not compatible with dBASE or early VP-Info versions, whereas the Type 3 variant (see below) is.
Type 1 - Compatible with VP-Info Type 1 files. Type 1 files can have up to 256 fields in VP-Info, and up to 500 fields in Shark.
Type 2 - Compatible with dBASE II data files, and are limited to 32 fields.
Type 3 - Compatible with dBASE III, dBASE III+ and dBASE IV data files.
Type 3 files can have up to 256 fields in VP-Info and up to 500 fields in Shark (NOTE: dBASE III and dBASE III+ cannot read a data file with more than 128 fields, and dBASE IV cannot read a data file with more than 255 fields). Unlike Type 0 files, Type 3 files are also compatible with all other dBase file types, and also can have up to 4 billion records. Type 3 files are easily the most capable of all existing dBase file types.
Shark includes the earlier Types 1 & 2 file types mostly for compatibility when importing data from older dBase/Clipper files. Data can be read in from older files, and saved in the newer Type 3 file format.
When all the fields are specified using the full-screen input display of the CREATE command, the user is asked to specify which type of file to create; the default is Type 3.
If the data file already exists, you will be given the opportunity to delete it when saving to the new file type. On a network with SET NETWORK ON in Shark Network Edition, attempting to delete a data file while another user is accessing a file with the same name will cause a LOCK error. Wait until the other user exits the file, then continue the save operation.
Example:
1>CREATE custfile
shows the following screen after all the fields have been entered:
Sunday, August 12, 2019 Shark CUSTFILE.DBF Name Type Width Dec Name Type Width Dec CUSTNUM C 6 0 BIRTHDAY C 6 0 FIRSTNAME C 15 0 SS_NUM C 9 0 LASTNAME C 20 0 EMPL_NUM C 6 0 ADDRESS C 25 0 CITY C 15 0 STATE C 2 0 ZIP C 9 0 HPHONE C 10 0 WPHONE C 10 0 SPOUSEFNAM C 15 0 SPOUSENAME C 20 0 DEPENDENTS N 2 0 UP/DOWN COLUMN MOVE ROW SAVE STRUCTURE C..Strings previous. <PgUp> left... ^K insert... ^N update... <End> N..Numbers next..... <PgDn> right.. ^L delete... ^T nochange. ^Q L..Yes/No
There are up to 12 fields described in each column, with four editing windows per field. All the standard full-screen editing keys are available in CREATE, including Ctrl-K and Ctrl-L to move from column to column.
As in BROWSE, <Pg Up> and <Pg Dn> are used to move from line to line, while <Up> and <Dn> are used to move between editing windows on the same line.
Error checking is done by Shark as you enter the specifications for the new fields when you leave a line. Here are some of the messages you may see:
<The first character of a field name must be a letter. Invalid character in the Name field. Name fields must be unique. Types: C-character N-numeric L-logical D-date F-float M-memo. Field Length must be greater than 0. Length of character field can not exceed 254. Length of numeric field can not exceed 20. Decimals cannot exceed 6. Decimals too large for length.>
Caution: Be sure you have set FIELDS= in the SHARK.SET or SHARKNET.SET file to a number large enough to accommodate all the fields in all the data files you will ever have open at one time, plus the largest number of fields in any of these files. Default is 320 fields. See FIELDS=.
CURSOR
Move the cursor to a given screen position.
CURSOR <row>,<col>
CURSOR moves the current cursor position to a given point on the screen. Combined with the ?? command, it gives the user all the absolute positioning control of the @ SAY command without its restrictions.
CURSOR is usually employed when the "MENU(" function is used, to place the selection bar correctly.
DEBUG
Print expression or expression list for debugging purposes.
DEBUG <exp list> <exp list> the expressions to be displayed
This command displays the expressions exactly as does the ? command. However, if SET DEBUG OFF, the expressions are not displayed. This may save the programmer the trouble of having to place the DEBUG commands in the program when debugging, and having to take them out for the regular running of the program.
See SET DEBUG and Appendix A for more in debugging.
Examples (in a program):
DEBUG number DEBUG 'current amount: ', amount, ' current balance: ', balance,INKEY()
Note that the INKEY( function causes a pause until any key is pressed.
DELAY
Suspend execution for a specified number of seconds.
DELAY <num exp>
<num exp> the number of seconds execution is to be delayed
This command suspends program execution for a specified number of seconds. In some cases, Shark is slow to proceed while clearing its internal memory, and to proceed immediately will cause an error. In this case, you can insert:
DELAY 3
into the application code, and the application will wait 3 seconds before continuing.
The delay can be any length from .06 seconds upward. For programmers, this command can replace complex loops which often have the deficiency of varying in length depending on what type of computer the program is run on.
Examples:
1>DELAY .5 1>number=3 1>DELAY number
DELETE
Delete selected records from the selected data file.
DELETE <scope> [FOR <cond>]
Options:
<scope> select by scope (default scope: current record) FOR <cond> select by condition
The DELETE command is used to set the DELETED flag for records in the selected data file.
These records can be recovered by the RECALL command or with Ctrl-U in the BROWSE and EDIT commands, provided SET DELETE is OFF.
Deleted records are not "seen" by certain Shark commands irrespective of SET DELETE status, including: COPY, POST, UPDATE, SUM, AVERAGE, COUNT.
To remove all the records with the deleted flag set, use the PACK command. (See the commands: SET DELETE, RECALL, PACK.)
Examples:
1>USE employee 1>COPY TO empl1 6 COPY(S) 1>USE#3 empl1 1>DELETE RECORD 2 1 DELETE(S) 1>DELETE#3 RECORD 5 1 DELETE(S) 1>SKIP 1>DELETE NEXT 3 FOR salary <25000 1 DELETE(S) 1>PACK#3 5 TOTAL PACKED 1>PACK 4 TOTAL PACKED
DELETE FILE
Remove files from disk.
DELETE FILE <file>
Note: <file> = the name of the file to be deleted
The DELETE FILE command deletes a file from the disk. This command should be used with care because, once deleted, the file cannot be recovered. If no extension is given, the extension DBF is assumed. Wildcards are not permitted.
On a network with SET NETWORK ON in Shark Network Edition, attempting to delete a file while another user is accessing it will cause a LOCK error.
Examples:
1>DIR c*.dbf CCUST.DBF 522 10-13-88 5:42p COMMS.DBF 6546 1-06-90 5:11p COMMS2.DBF 6342 1-07-90 1:00p CUSTJUNK.DBF 7062 9-17-89 3:57p CUSTOMER.DBF 734 11-29-89 10:43p CUST2.DBF 734 3-19-90 7:03p 21940 bytes in 6 files. 5246976 bytes remaining. 1>DELETE FILE cust2 1>DIR c*.dbf CCUST.DBF 522 10-13-88 5:42p COMMS.DBF 6546 1-06-90 5:11p COMMS2.DBF 6342 1-07-90 1:00p CUSTJUNK.DBF 7062 9-17-89 3:57p CUSTOMER.DBF 734 11-29-89 10:43p 21206 bytes in 5 files. 5251072 bytes remaining. 734 characters were copied.
DIM (ARRAY or MATRIX)
Use DIM to dimension, or define, an array as a matrix or table. Many variables can be stored under one variable name <memvar> in the form of a matrix of cells. The number of rows [x1] and columns [x2] are specified, and the width <width> of the space in each cell is specified. The <width> of the entries of CHAR arrays defaults to 10 if not specified by the user.
Additional <pages> of tables can be specified by a third input [x3]. SharkBase is limited to 128 variables in a single program, and arrays are useful for holding large amounts of data under a single variable name.
Matrixes are economical since they're not stored in program memory. Examples would be tables of shipping rates:
DIM CHAR <width> <memvar>[x1,x2,x3],<memvar2>[y1,y2,y3],... DIM NUM <memvar>[x1,x2,x3],<memvar2>[y1,y2,y3],... DIM LOG <memvar>[x1,x2,x3],<memvar2>[y1,y2,y3],... <memvar>, <memvar2> the names of the memory variables that are defined as an array
Option:
<width> the width of the character variables
Arrays of up to 3 dimensions can be defined for each of the three data types (CHARACTER, NUMERIC, LOGICAL). The width of the entries of CHAR arrays is fixed; it is 10 if not specified by the user.
The three dimensions are:
1. Length 2. Width 3. Page number
Note that in the syntax description of DIM, [x1,x2,x3] does not indicate three 'options'. The 'dimensions' are enclosed in square brackets thus, [ ], and must be present in a DIM command. x1, x2, x3 are integer numbers greater than zero, not variables, up to three in number; at least one (length) must be specified.
Examples:
One dimensional arrays (also called vectors):
DIM CHAR a[11] (a vector array eleven rows long of CHAR elements, each defaulting to 10 characters in size) DIM CHAR 20 a[12] (a vector array of twelve rows of CHAR elements, each 20 characters in size) DIM CHAR a[12],b[12] DIM NUM a[21] DIM LOG a[20]
To fetch customer details from a dbf record:
USE CUSTOMER READ or when using severzl data files at one time: USE#1 CUSTOMER READ SELECT 1
Set up a one-dimension array named "CUSTDAT" with 9 rows of 50 characters:
DIM CHAR 50 CUSTDAT[9]
Store data in each row of the array:
CUSTDAT[1]=CUSTCODE CUSTDAT[2]=NAME CUSTDAT[3]=POBOX CUSTDAT[4]=CITY CUSTDAT[5]=REGION CUSTDAT[6]=POSTCODE CUSTDAT[7]=STREETADDR CUSTDAT[8]=STREETCITY CUSTDAT[9]=COUNTRY
Display data:
N=1 DO WHILE N<10 ? "CUSTDAT["+STR(N,2,0)+"]="+CUSTDAT[N] N=N+1 ENDDO
TABLES:
Two dimensional matrixes (also called tables):
DIM CHAR 25 first[10,20]
(a table array ten rows long, 20 CHAR variables wide, each defaulting to 10 characters in size)
DIM NUM second[5,20]
(The above creates a table array five rows long, 20 NUM variables wide, each defaulting to 8 digits in size)
Three dimensional arrays:
DIM CHAR 10 a[8,10,12]
(The above is a paged table array of 12 pages of 8 rows of 10 CHAR elements)
DIM NUM b[5,5,50]
A mixed definition:
DIM CHAR 12 a[50],b[2,2,11]
Note that the width of both A and B is 12.
Arrays can be used just like all other memory variables except that only = and STORE can assign values to them. Commands and functions that create memory variables (such as the command COUNT) or store values in existing memory variables (such as the command READ or the function READ() cannot directly use arrays. Arrays cannot be used in a TEXT structure or TEXT file.
Arrays are stored in high memory (see Appendix A: Shark Compiler). The size of an array is at most 64K. Use the STATUS command to find out how much high memory is available. Numeric variables take 8 bytes and logical variables take 2 bytes of memory for each entry.
Notes: The numbering is from 1. Arrays can be redimensioned in a program. No part of a DIM command can be a macro.
Examples:
Memory use (in bytes) 1>DIM CHAR 25 name[40] 1,000 1>DIM CHAR fill[10,7] 700 1>DIM NUM b[2,3],total[10,20,5] 48 and 8000 1>DIM LOG abc[5000] 10,000
Applied Example:
1>DIM CHAR 12 PRODUCTS[2,3] 1>PRODUCT[1,1]='CHICKEN' 1>PRODUCT[1,2]='DUCK' 1>PRODUCT[1,3]='GOOSE' 1>PRODUCT[2,1]='BEEF' 1>PRODUCT[2,2]='GOAT' 1>PRODUCT[2,3]='PORK'
The contents of the array can be listed by querying the name of the array:
1>? PRODUCT CHICKEN DUCK GOOSE <-- ROW '1' BEEF GOAT PORK <-- ROW '2'
or you can query individual elements:
1>? PRODUCT[2,1] BEEF
When using STATUS (or STAT) to inspect the contents of memory, your MATRIX information will appear as in this example. "Width" shows the WIDTH of each row in characters, and DIMENSION shows how many rows of data are in this particular matrix:
Matrix Name Type Width Dimension CUSTDATA C 40 [43]
DIR
Directory listing.
DIR<file specification> Options: <pathname> DOS directory name, with optional drive letter and colon <file specification> a file name, with optional DOS windcards; extension is required if present
This command is similar to the DIR command of the DOS operating system: it displays the list of files on the current disk, together with file size and date and time created or last modified. Total size of all matching files is also given along with the bytes remaining on the disk.
If a file name is given in full, the directory will show only that one file.
A partial listing of the directory can be specified by giving a The wild card character ? may be replaced by any single character; the
wild card character * allows any string. Examples: Note on post-Y2K file dates in a Shark file listing: The first epoch (the 20th century to the end of 1999) is numbered as "O" followed by the year, e.g. "099". The zero is dropped, leaving a file date as above of "10-13-99" (Oct 13,1999). The second epoch (the 21st century) is numbered as "1" followed by the year, displaying a file date as above of "11-29-112" (Nov 29,2012). Dates in programs can be easily formatted into your favorite notation using the DATE() function. Example:
Directory listing, following redirection commands of the current FILES
structure. Options: Shark provides for a FILES structure which lets you specify default drive
letters and/or directories for the various files used by the programs.
Usually file types are grouped into individual directories according to
"skeletons" constructed with wildcards. For example: The DIRF command is similar to the DIR command, except that the file
specification is compared to the existing FILES structure and, if a match is
made, the redirection in the structure is applied to the file specification,
so that the directory displayed is of the redirected directory, not the
current directory. It displays a list of all matching files in that directory, together with
file size and date and time created or last modified. Total size of all
matching files is also given along with the bytes remaining on the current
disk. Example:
Note on post-Y2K file dates in a Shark file listing: The first epoch (the 20th century to the end of 1999) is numbered as "O" followed by the year, e.g. "099". The zero is dropped, leaving a file date as above of "10-13-99" (Oct 13,1999). The second epoch (the 21st century) is numbered as "1" followed by the year, displaying a file date as above of "11-29-112" (Nov 29,2012). Dates in programs can be easily formatted into your favorite notation using the DATE() function. Example:
If a file name is given in full, the directory will show only that one
file. The wild card character ? may be replaced by any single character; the
wild card character * allows any string. Display information, memory variables, system variables, file structure. Options (for displaying data file records): Options (for listing directories): These commands are exactly the same as the LIST commands except for the
following differences: the default scope of the DISPLAY command is the current
record rather than the whole file; the listing is stopped at the bottom of the
screen or current window (about every 20 lines when displaying data file
contents). See the commands: LIST, LIST FILES, LIST MEMORY, LIST STRUCTURE, and LIST SYSTEM.
In a program, execute a subroutine and, on completion, return to the next
command in the calling program; in Conversational Shark, equivalent to CHAIN. In Conversational Shark, DO is the same as CHAIN: it begins the
execution of the compiled program with the name <file> with extension CPL;
otherwise, the uncompiled Shark program <file> will be compiled "on
the fly" and executed, and the compiled file immediately deleted from the disk. Note that an uncompiled program with a GLOBAL statement cannot be
compiled on the fly if it needs to import variable values, since the COMPILE step includes a CLEAR command. In a program, the command DO <file> causes the program <file> to be
compiled as a subroutine of the current program. No matter how many subroutines are called, all will be compiled into the same CPL file as the calling program. The subroutines become overlays; they are called into memory when needed. When the called program executes a RETURN command, the execution resumes
in the current program with the line following the DO command. The called program can itself DO other subroutines. There can be
subroutines up to 10 levels. When a subroutine is compiled, all information about data files and
memory variables is coded in the compiled form: the environment is compiled with the subroutine. Contrast this with the CHAIN command that starts with a clean slate. Any time a subroutine is invoked with a DO, the called program becomes an overlay. If a subroutine is called 5 times, it is compiled 5 times. This, of course, would make for very bulky programs. The solution of this problem is very simple. If the subroutine TEST is
not sensitive to the environment (it does not use any fields or memory
variables, or all data files and memory variable names are the same throughout
the calling program), DO it as follows: This way, TEST becomes a single overlay; it is invoked with PERFORM STEST. Note: If the same subroutine is called from two places in the same
program, but the two places have different environments, the subroutine cannot
be called from a single procedure, and has to be compiled twice. For example, assume that TEST carries out some computation on some fields
of the data file HISTORY1 and some memory variables, and then carries out the
same computations on some fields of the data file HISTORY2 and some memory
variables; HISTORY1 is file 2, while HISTORY2 is file 3. Create two procedures: Now if you need to invoke TEST with the first environment (HISTORY1),
then PERFORM TEST1; otherwise, PERFORM TEST2. All procedures called by a subroutine must be contained in the PRG file
of the subroutine. A procedure of the calling program cannot have the same
name as a procedure of the subroutine. It is good programming practice not
to have the same name for procedures and subroutines. Procedures are internally compiled, while subroutines become overlays.
Therefore, procedures are faster in execution. However, there is a limit of
32 procedures in total for one CPL file. The name of the PRG file used with the DO command cannot be a macro. Example in Conversational Shark: This will execute INVOICE.CPL if present; otherwise it will compile and
execute INVOICE.PRG, and then delete the CPL file. Switch the program flow to a number of cases. The command DO CASE provides for the processing of a number of options
without the use of nested IF commands. It is used in conjunction with the
CASE, OTHERWISE, and ENDCASE commands. The DO CASE program structure is as follows: where <cond1>, <cond2>, <cond3>,..., <condn> are conditions, <program
segment1>, <program segment2>,..., <program segmentN> and <program segment>
are program segments, that is, any number of Shark program lines. Execution is as follows: After the DO CASE is encountered, Shark looks for the first CASE
command and evaluates the condition; if the condition is true, the following
program segment is executed, terminated by the next CASE, by OTHERWISE, or by
ENDCASE. After the execution of the program segment, the program execution
continues with the program line after the ENDCASE command. If the condition is false, Shark looks for the next CASE
command. If no condition is true, Shark executes the program segment
following the OTHERWISE command (if any). The OTHERWISE command is optional. Note that if more than one condition
holds, only the segment after the first true condition is executed. DO case commands can be nested up to 10 levels. Example: When editing with the internal Shark programming editor, Alt-F reformats
the file with all structures properly indented, making it easy to see unbalanced structures. This is a useful tool for programmers since an unbalanced "if-endif" element can totally disrupt a surrounding "do case" construct. The standard program loop command. The command DO WHILE starts the program loop. The structure of the loop
is as follows: Execution is as follows: After the DO WHILE is encountered, <cond> is evaluated. If <cond> is
true, the Shark program segment (terminated by the ENDDO) is
executed; then <cond> is evaluated again. If <cond> is false, execution
continues with the command following ENDDO. There can be a DO WHILE command within a DO WHILE command; this is called
nesting. Many levels of nesting are permitted; however, too many levels of
nesting will give a compile-time error message: There are two commands that facilitate moving to the top and the bottom
of the loop: LOOP moves the execution to the top of the loop, and BREAK exits
the loop. There is one more looping command in Shark: REPEAT. When editing with the internal Shark programming editor, Alt-F reformats
the file with all structures properly indented, making it easy to see unbalanced structures.
Edit records in a data file.
Options
The EDIT command without either the OFF or TEXT option allows the user to
view and modify records in the selected file. Once the command is given, the
screen shows the current record (or the record optionally specified with
<recnum>) in full-screen editing mode.
If the FIELDS keyword and a fields list is specified, only those fields
will be available during EDIT:
otherwise, Shark builds an input screen using all fields in the current data file.
To exit from EDIT, use <End> (or Ctrl-W) once you have filled in the
fields of the last record desired. To switch from EDIT to APPEND mode, press
Ctrl-<PgDn>, while <PgUp> switches back from APPEND into EDIT mode.
Note that APPEND is actually a special mode of EDIT; the only difference is that EDIT begins by displaying the current record, while APPEND adds a new blank record to the data file and displays that record. All the editing fields are the same for both EDIT and APPEND.
EDIT updates all index files in use.
The command SET MENU ON displays the most important editing keys at the
top of the screen, except if OFF or TEXT keyword is used, or if the current
window is less than 80 characters wide or 10 rows deep.
Editing keys:
See also:
EXAMPLES
You then see:
To edit only a few fields: The following examples show EDIT using the TEXT and OFF keywords combined
with an external text file (output from both is identical; OFF allows the
added flexibility of using an internal TEXT structure and/or an ON FIELD
structure): These both display: See TEXT for a full discussion of the TEXT command. The TEXT used
for the above input screen: The following demonstration program illustrates use of EDIT OFF. This command is used on a MS-DOS system when the printer is controlled directly by the program. A Windows-based DOS emulator like vDOS or DOSbox will direct print output first to a file (not to a printer), and Windows then processes the file, handing it to the printer or saving the output as a text file. Thus, in MS-DOS, to start a new page on the printer. This also resets the line and column counters to 0 for the @ commands. EJECT will attempt to advance the printer whether printing is on or off.
If your printer is on but off-line, your program may appear to hang; either
put the printer on-line, or turn off the printer to release Shark to
continue processing. When spooling directly to a printer within an MS-DOS system (see SPOOL), the form-feed is placed into the spool file,
and has no effect on the printer until the file is spooled or copied to the DOS printer. (See the commands @, SET FORMAT TO PRINT, SET PRINT ON, SET EJECT ON/OFF,
SET LENGTH TO, and the functions ROW( and COL(. Examples: In a program, EJECT and SPOOL may be used together to reset the line
counter to zero before printing begins: The optional part of an IF program structure. This command introduces the optional part of the program structure
IF/ENDIF. See the command IF. Example: Terminate a command structure. All Shark structures are terminated with a matching END command
as shown above. When editing with the internal Shark programming
editor (see WRITE command), Alt-F reformats the file with all structures
properly indented, making it easy to see unbalanced structures. See DO CASE, DO WHILE, IF, FILES, ON ERROR, ON ESCAPE, ON FIELD, PROCEDURE, REPEAT, and TEXT. Erase screen. Option: This command erases the screen, and is a synonym for CLS. If, optionally, two numeric expressions, line1 and line2, are given, it
erases line1 and line2, and all lines between, if any. These expressions
should have values between 0 and 24. ERASE is the same as the following three commands: Examples: Initiates a program segment module in an ON FIELD structure Each field in a Get Table may have a program segment in a program's ON
FIELD structure which will be executed when the cursor leaves that field, or
optionally when READ or the current record is exited. All fields in a Get Table are numbered from 1 to 64 in the order in which
they are placed on the screen. When they are painted by @ GET commands, the
order is the same as the order of the @ GET commands in the program; if painted
by TEXT, the order is left-to-right on each line, and then top-to-bottom. When editing with the internal Shark programming editor (see
WRITE command), Alt-F reformats the file with all structures properly indented,
making it easy to see unbalanced structures. (See command ON FIELD.) Examples: Set the maximum number of fields available at any one time. This setting is used in the SHARK.SET file only This command sets the maximum number of fields that can be open at any
one time in all open files, taking the place of SET FIELDS TO in earlier
versions of the language (now ignored if encountered by the Shark compiler). Reserving memory space for a single field requires 16 bytes. Therefore,
increasing the number of fields requested reduces the memory space available
for your program. The limits for FIELDS= are 128 and 1000, with a default of 320. Caution: be sure you have set FIELDS to a number large enough to
accommodate all the fields in all the data files you will ever have open at
one time, plus the largest number of fields in any of these files. Example: Lets you specify drive letters, directories, and/or default file modes for
various files used by Shark.
specification = any file name or "skeleton" (using the * and ? wildcards
Options:
Option: (Network Edition only):
There is always a FILES Table in memory, set up by the active
FILES ... ENDFILES structure. (This table is empty if there is no active FILES ... ENDFILES structure.) The FILES command allows on-the-fly additions and changes to the FILES Table from either Conversational Shark or programs.
Examples of Form 1 (Only in programs):
Initiates a FILES ... ENDFILES structure. (See FILES ... ENDFILES.)
(Only in Conversational Shark)
Empties the current FILES Table in memory. (Caution: Do not confuse this
interactive command with the FILES command as used in programs, which always
initiates a FILES ... ENDFILES structure.)
Examples of Form 2 (In either programs or Conversational Shark):
FILES *.dbf,c:\data
Given this command, either in a program or in Conversational Shark,
Shark searches the FILES Table in memory for a matching file
specification. If the file specification *.DBF is found, the new path will
replace the existing path; otherwise, this specification and redirection is
added to the top of the FILES Table.
If no <file> direction is specified, file redirection is turned off for files
matching this entry.
Macros are allowed with the FILES command itself, either in programs or
in Conversational Shark. Macros are not permitted in the FILES
... ENDFILES structure.
THE FOLLOWING REFERS TO NETWORK EDITIONS ONLY:
There is a special form of the FILES command which has significance only
in network editions with SET NETWORK ON.
This form adds a <mode> which sets the default file mode for all matching
files. For example,
sets a file mode of READ for all files with an NDX extension, all of which are
found in the NDX subdirectory of the current directory.
If only <specification> and <mode> are given, the file mode is given to
all files matching that specification wherever they are on the disk. (Note: two commas are required:
Lets you specify drive letters, directories, and/or default file modes for
various files used by Shark.
Options:
file direction any legal DOS path, consisting of drive letter and colon and/or directory path
Option: (Network Edition only):
(Programs and CNF file only) There is always a FILES Table in memory,
set up by the active FILES ... ENDFILES structure. (This table is empty if
there is no active FILES ... ENDFILES structure.)
A FILES ... ENDFILES structure
may be created in a program at any time, and may have any number of specification
lines between the FILES and ENDFILES lines. All existing entries are immediately
cleared and a new FILES Table constructed.
Examples:
Causes Shark to add C:\DATA\ to the front of all file names Given this command,
either in an Shark program or in Conversational Shark, Shark searches the FILES
Table in memory for a matching file specification. If the file specification
*.DBF is found, the new path will replace the existing path; otherwise, this
specification and redirection is added to the top of the FILES Table.
FILES *.frm
If no <file direction> is specified, file redirection is turned off for files
matching this entry.
A FILES ... ENDFILES structure is cleared by an empty structure as follows:
No macros are permitted in the FILES ... ENDFILES structure, although
macros are allowed with the FILES command itself, either in programs or in
Conversational Shark.
Caution: There is no way to add a comment inside a FILES ... ENDFILES
structure, and no line should be indented. The contents of FILES ... ENDFILES
structures are not affected by the reformatting facility Alt-F of the WRITE
command.
THE FOLLOWING REFERS TO NETWORK EDITIONS ONLY:
There is a special form of FILES...ENDFILES entry which has significance only in network editions with SET NETWORK ON.
This form adds a <mode> which sets the default file mode for all matching files.
For example,
sets a file mode of READ for all files with an NDX extension, all of which are
found in the NDX subdirectory of the current directory.
If only <specification> and <mode> are given, the file mode is given to
all files matching that specification wherever they are on the disk. (Note: two
commas are required: *.dbf,,WRITE.)
Set the maximum number of files which can be open at one time (requires DOS 3.3 and above)
SHARK.SET file only
Shark has a default maximum of 20 files, unless the operating system
allows more than 20 open files (DOS 3.3 and above) and that a FILES=
statement is present in the CONFIG.SYS file specifying at least <n> files.
As a practical matter,
This command may be placed only in the SHARK.SET file, which is executed
by Shark only when first loaded.
Example:
Display the current contents of the FILES ... ENDFILES structure
The current FILES ... ENDFILES structure may be displayed with this
command. See FILES and FILES ... ENDFILES. Example: Find a record by its index in the selected data file. FIND is one of a family of commands that finds a record in an indexed
data file by matching a given string with key values in the index file: FIND positions the file on the first record in the index matching the FIND
string (no-find positions the file at the top of file) LAST positions the file on the last record in the index matching the FIND
string (no-find positions the file at the top of file) NEAREST positions the file on the first record in the index equal to or
greater than the FIND string SEEK is identical to FIND, except that it searches for the match to the value
of a character expression instead of a string constant (no-find positions
the file at the top of file) All forms allow a search to be made on a character expression when the
expression is preceded by the macro symbol "&". When the variable var='TAYLOR', all of the following command lines are equivalent: In Conversational Shark, just type FIND and the key. Examples: If <string> evaluates the same for two records, the second record will
never be found with FIND. If SET DELETE ON, deleted records will not be found. (See the command SET.) Numbers must always be treated as strings, even if the key expression is
a numeric field. If NUM is a numeric field of width 2, FIND 1 will not find
1, but FIND &STR(1,2) or FIND &' 1' will work. For the users' convenience, Conversational Shark converts all
command lines to upper case before execution. So, to find the inventory
numbers that start with AB, type either of the following two commands: It follows that is understood by Shark as FIND TAYLOR. If you have to find Taylor,
use one of the following forms: If FIND is successful, the value of the current record pointer (as shown
by the # and RECNO( functions) is set to the current record number, and the
system variable :NEAR is set to the same number. If the record is not found, the current record pointer will be set to 0
and the value of :NEAR will be set to the number of the first record in the
index with a key greater than the FIND string; if the index contains no key
greater than the FIND string, :NEAR is set to the bottom of file, and EOF is
set to T (true). The command for "if not found" is: In Conversational Shark or in programs with SET TALK ON,
Shark sends the message "NO FIND" when a search is unsuccessful. Notes: FIND only works on the active index of the selected data file. If that index
was created with a selection condition, some records may be excluded from the
index. (See INDEX.) * With SET EXACT ON (see the SET command) only exact matches are found. The
FIND string must be the same length as the index key, and match exactly; if
SET EXACT OFF, the find string may be shorter. * An index may be made insensitive to capitalization by using the uppercase
functions !( or UPPER( in index creation. This makes use of the FIND command
much easier in Conversational Shark. (See INDEX command.) * The macro symbol (&) has a wider definition when used with FIND, LAST,
NEAREST and SEEK than with other Shark command. With this group of
commands only, it alerts Shark that the string expression following
is to be evaluated and used as the FIND string. (Macros in all other commands
are limited to fields and variables; dimensioned variables, functions and
concatenation are not allowed.) Update the selected data file on the disk. The current record of the selected data file is updated on the disk.
This may prevent accidental loss of data due to power failure. This command updates only the selected data file; it does not update
other data files in use, nor does it safeguard index files, text files, or DOS files. After a power failure it may be necessary to reindex the selected file. Example: Declare global variables. <memvar list> the list of memory variables to be declared global When a program is chained to another program, all the variables that were
defined as global by the GLOBAL command will be passed to the new program. The GLOBAL command should be the first command of any program. It should
definitely precede any command that involves a memory variable. There can be only one GLOBAL command in a program. No part of the GLOBAL
command can be a macro. A matrix variable cannot occur in a GLOBAL command. This is how the command works. In PROG1, you find at the beginning This places in the memory variable table (in the internal Shark data
space, see Appendix A) the variable names: A, B, C, D, in that order. The
variables at this stage have no type or data. When in PROG1, A is
encountered, that will attach type and a pointer to a value to A. Now PROG1 is chained to PROG2. For PROG2 to receive the values
associated in PROG1 with A, B, C, and D, start with the command: Note, however, that the variable names do not have to match (although type
must). will create the variable X with the contents of A, Y with the contents of B, C
and D retain their names and types. If you start PROG2 with then A, B, and C are inherited. If you specify in PROG2 more global
variables, for instance: then A, B, C, and D inherit their values and types from PROG1; E becomes the
fifth entry in the memory variable table, with no type or value. Example: PROG1 is chained to PROG2 with the command: PROG1 wants to pass to PROG2 the values of the following variables:
TRANSACT, PROCESS, CUSTRANGE, TYPE. To accomplish this, start both PROG1 and
PROG2 with the command: Note that when the execution of PROG2 starts, only these four memory
variables exist. Now suppose that PROG2 is chained to PROG3, and wants to pass to PROG3
the variables TRANSACT, PROCESS, CUSTRANGE, TYPE, and TRDATE. Then the first command of PROG1 should be: the first command of PROG2 should be: the first command of PROG3 should be: Now if PROG3 chains to PROG1, the variables TRANSACT, PROCESS,
CUSTRANGE, TYPE are still passed on, but not TRDATE. Set current record pointer to new value. <num exp>/<num const> the number to be assigned to #
The commands GO and GOTO are identical. They assign a new value to #,
the current record pointer (see Section 3.4). The data file is repositioned
to the record with the new record number. The forms:
evaluate the numeric expression <num exp>, throw away any fractional part, and assign the value to the current record pointer, #. So, any one of the following
commands: accomplishes the same: the record pointer (#) is set to 2. Note that is not allowed. If the selected file is indexed, the index is adjusted accordingly.
GO TOP, GOTO TOP and GO BOTTOM, GOTO BOTTOM are used to position the
current record pointer to the top and bottom of the current data file. If there is no
index in use, the TOP is Record 1, and BOTTOM is the last record. If an index is
in use, then the TOP and BOTTOM are the first and last records according to the index. Examples:
Set current record pointer to new value. <num exp>/<num const> the number to be assigned to #
The commands GO and GOTO are identical. They assign a new value to #,
the current record pointer (see Section 3.4). The data file is repositioned
to the record with the new record number. The forms: evaluate the numeric expression <num exp>, throw away any fractional part, and
assign the value to the current record pointer, #. So, any one of the
following commands: accomplishes the same: the record pointer (#) is set to 2. Note that is not allowed. If the selected file is indexed, the index is adjusted accordingly. GO TOP, GOTO TOP and GO BOTTOM, GOTO BOTTOM are used to position the
current record pointer to the top and bottom of the current data file. If
there is no index in use, the TOP is Record 1, and BOTTOM is the last record.
If an index is in use, then the TOP and BOTTOM are the first and last records
according to the index. Examples: Request for information on Shark commands and related topics. Option: The HELP command provides information on the syntax (format rules) and
use of the commands of Shark, and some related topics; it is available
only in Conversational Shark. The command displays all the topics for which HELP is available. Type HELP and the topic
description. The text is contained in the file SHARK.HLP or SHARKNET.HLP, which
must be in the same directory as your version's MSG file, either in the
current directory or on the DOS path. If the file is not found, Shark will
so advise the user. Examples: displays the HELP menu screen. displays help on the REPLACE command
Conditional execution of Shark program segment. The IF command allows conditional execution of a program segment. The
general form of this command is: This works as follows: When the IF command is found, the condition <cond>
is evaluated. If <cond> is true, the <program segment> (a number of program
lines) is executed. The end of the <program segment> is at the ELSE or at the
ENDIF (whichever comes first). If <cond> is false, Shark looks for ELSE. If ELSE is found, the <ELSE program
segment> is executed. The execution continues with the program line following the ENDIF. Note that ELSE is optional. There can be an IF command within an IF command; this is called nesting.
Many level of nesting is permitted; however, too many levels of nesting will
give a compile-time error message: Stack overflow. Care should be taken to nest the IF commands properly in a DO WHILE, DO
CASE, or REPEAT program structure. When editing with the internal
Shark programming editor (see WRITE command), Alt-F reformats the
file with all structures properly indented, making it easy to see unbalanced
structures. IF may not take a macro. Since a line with a macro is not compiled until
runtime, Shark will be unable to handle nesting properly if a macro
is used, resulting in the error message "ENDIF implies IF" or "ELSE implies
IF". For an alternative, see example 4 below. Examples: Indenting the program lines helps to show the level of nesting of the
structures. In WRITE, Alt-F indents the lines and capitalizes the command
verbs. Rewrite: Consider the following simple program: This series of nested IF commands (often called "cascading IFs") is
equivalent to the following DO CASE structure: The DO CASE form is much easier to understand. If <cond> must be a macro, use the following technique instead: Create an index file. Option: The INDEX ON command creates an index file. Index files are used 1. To organize records into an apparent order according to some key for listing, reporting, browsing, editing, etc. 2. To locate records quickly using the FIND, NEAREST, LAST, SEEK, POST and UPDATE commands. Each key must have a separate index file. 3. To make the file act as though it has only records matching a given selection condition and an apparent order according to some key. The expression <str exp> must evaluate to a string of length at most 60; otherwise, an error message is sent. In addition, the condition itself must be no more than 100 characters long. (Do not use COMP for the first four letters of an index file; Shark is unable to open such a file.) Once an index file exists, the data file can be opened for use with the index file; see the USE <data file> INDEX <index file> command. The commands: APPEND, BROWSE, CHANGE, EDIT, REPLACE, READ automatically update the index files in use. There can be many index files in use, all are updated by these commands, but only one index file works with FIND. If SET TALK ON, INDEX will output progress reports showing the completion of each 100 records, and the total number of records indexed. Large files create temporary files which are then merged to create the ultimate index. Index expressions should be of type string, but a numeric field (not a numeric expression) can also be used. If you wish to index on a numeric expression, use the key STR(<num exp>) or PIC(<num exp>, <format)) to convert the values to strings. See the functions STR( and PIC(. It is often helpful to use the upper-case functions, !( or UPPER(, for string expression that mix upper-case letters and lower-case letters, such as names, addresses, and so on. This way, the data is arranged in alphabetical order instead of the ASCII code order which is often confusing. See the functions CHR( and RANK(. On a network with SET NETWORK ON in Shark Network Edition, attempting to create an index while another user is accessing a file with the same name will cause a LOCK error. To index on part of a field: To index on two fields: To freshen an index, see the REINDEX command, as in this example: Note that once the data file is indexed, you can use FIND: For example, a data file has a numeric field AMOUNT containing numbers from 1 to
5,000; to index the file in decreasing order use the key: Or, a mailing list has 50,000 records, including about 250 from Utah. An
efficient way to select and print a listing of all those in Utah is: Create an index file, using the index key of an existing SharkBase, VP-Info,
dBASE, or Clipper index file. Options: The INDEX FROM command creates an index file using the index expression
of an existing index, even if the existing index is corrupt and even if it's
from any version of VP-Info, dBASE (II, III, or IV), FoxPro or Clipper. If
the same name is given with the TO clause, the original file is overwritten. Note: All SharkBase and Clipper indexes use the extension NTX, while
all VP-Info, dBase and FoxPro indexes use the extension NDX for their
mutually incompatible indexes. If the FROM file in this command is
specified as an NDX, the TO file may have the same name with an NTX
extension. When making an index from one created in Clipper, dBASE or FoxPro, be
aware that some expressions from these languages may not be valid in
SharkBase; if an invalid expression is encountered, an error message is
sent. In addition, the <cond> used with the optional FOR clause must be no
more than 100 characters long. Among the programs shipped with SharkBase is CONV_INV.PRG, which users
with existing applications may use to automate the conversion of indexes.
Whenever SharkBase cannot understand the index expression in the existing
index file, the program prompts for an alternate index expression using
SharkBase functions and operations. When the FROM file is a Clipper NTX
which requires a different expression for its use under SharkBase, both
expressions are retained so Clipper will handle it properly as well. For users with existing applications which must be retained in dBASE or
FoxPro, you may use the FILES ... ENDFILES structure to point to data and
index files in your dBASE or Clipper directory. (Note: You may not use COMP for the first four letters of a data or
index file; SharkBase is unable to open such a file with the USE command.) Once an NTX index file exists, the data file can be opened for use with
it; see the USE <data file> INDEX <index file> command. The commands:
APPEND, BROWSE, CHANGE, EDIT, REPLACE, READ automatically update the index
files in use. There can be many index files in use, all are updated by
these commands, but FIND and its variants works with only one index file at
a time. If SET TALK ON and in Conversational SharkBase, INDEX FROM will output
reports showing progress and the total number of records indexed. Large
files create temporary files which are then merged to create the ultimate
index. On a network with SET NETWORK ON in SharkBase Network Edition,
attempting to create an index while another user is accessing a file with
the same name will cause a LOCK error. Index files are discussed more fully in the Index TO command below.
See also the REINDEX command. Examples: 1. 2.
An application written in dBASE keeps its data and index files in
C:\DATA. The following FILES ... ENDFILES structure is in the CNF files
executed when SharkBase was started: This allows the DBASENDX.PRG program in the Reference Guide to work
properly, assuming that C:\DATA has no more than a screenful of data files,
and all index files share the first four letters with the data file on
which they are created (an excellent practice).
Input request for data of any type. Option: The command INPUT is used to enter string, numeric, or logical data into
a memory variable, <memvar>. It works the same way as the command ACCEPT
(see ACCEPT), except that string input needs quotation marks. The type of the <memvar> is determined as follows: If the data typed in is in quotation marks, it is a string; <memvar> is
of character type. If the data is a number, <memvar> is of numeric type. If the data is Y, y, N, n, T, t, F, or f, <memvar> is of logical type. The optional character string is used as a prompt. A character
expression cannot be used, but a macro is permitted, provided the macro
expression includes quotation marks. ACCEPT is the preferred way to enter strings, since ACCEPT does not
require quotation marks as delimiters. Examples: The following illustrates use of a variable instead of a string as the prompt: Initiates a program segment (a KEY procedure) in an ON KEY structure Option: This command has two forms, allowing you to specify the key to be
affected either by its number (any character number greater than 255) or by
its name if it is a function key in the range of F1 to F10 inclusive. (F11
and F12 are not supported by SharkBase.) In either case, all commands that follow until another KEY command or
the ENDON command constitute a procedure that will be executed whenever the
specified key is pressed by the user. Captions are automatically displayed on line 24 of the screen, and
saved whenever a KEY procedure is executed. When the procedure is complete,
line 24 is redisplayed. If keys are specified by a function key name (F1
through F10), the key name is automatically shown (along with caption). The
spacing between captions is controlled by the number of trailing blanks in
the caption on the KEY command line. A KEY command with no procedure in an ON KEY structure merely turns off
the named key. This can be extremely useful in deactivating such keys as Note: KEY commands in the ON KEY structures cannot be accessed while
SharkBase waits for a keystroke in the MENU( function or the WAIT command. Examples: Find the last record matching a given FIND string by its index in the selected
data file. LAST is one of a family of commands that finds a record in an indexed
data file by matching a given string with key values in the index file: LAST positions the file on the last record in the index matching the FIND
string (no-find positions the file at the top of file) FIND positions the file on the first record in the index matching the FIND
string (no-find positions the file at the top of file) NEAREST positions the file on the first record in the index equal to or
greater than the FIND string SEEK is identical to FIND, except that it searches for the match to the value
of a character expression instead of a string constant (no-find positions
the file at the top of file) All forms allow a search to be made on a character expression when the
expression if preceded by the macro symbol "&". When the variable
var='TAYLOR', both of the following command lines are equivalent: In Conversational Shark, just type LAST and the key. Examples: If SET DELETE ON, deleted records will not be found. (See the command
SET.) Numbers must always be treated as strings, even if the key expression is a
numeric field. If NUM is a numeric field of width 2, LAST 1 will not find 1,
but LAST &STR(1,2) or LAST &' 1' will be successful. For the users' convenience, Conversational Shark converts all
command lines to upper case before execution. So, to find the inventory
numbers that start with AB, type either of the following two commands: It follows that is understood by Shark as LAST TAYLOR. If you have to find Taylor,
either use the string directly with the macro symbol: or if name='Taylor' use the following: When LAST is successful, the value of the current record pointer (as
shown by the # and RECNO( functions) is set to the current record number, and
the system variable :NEAR is set to the same number. If the record is not found, the current record pointer will be set to 0
and the value of :NEAR will be set to the number of the first record in the
index with a key greater than the FIND string; if the index contains no key
greater than the FIND string, :NEAR is set to the bottom of file, and EOF is
set to T (true). For a fuller discussion, see the FIND command. NOTE: In Shark, SCOPE and LIMIT are identical. However, the LIMIT command doesn't exist in VP-Info, only a simpler SCOPE command. Limit the records available within the current master index to those matching all or part of the current record's index key. Options: When the current file has an index, Shark can be made to treat the file as though it includes only those records matching the current record's key expression, or some leftmost part of it. When a LIMIT is in effect, no Shark command can access a record outside that limit. You can most quickly implement this command by using the <num exp> option. The effect is to have Shark set the LIMIT to the leftmost <num exp> characters of the key expression of the master index. If <num exp> exceeds the length of the key, the effect is identical to setting the LIMIT to the entire index expression. (Maximum index-key length is 60 characters.) When LIMIT is used with no option, or when <num exp> is zero, the limit is deactivated. Using LIMIT with <key exp> requires precision in its use to avoid problems that may become extremely serious. Note that the <key exp> expression must be the same as the master index key in use at the moment, or some LEFT( portion of it. Do not attempt to use an expression that does not meet this requirement. Cautions: 1. FIND should not be used on a file with an active limit. If you choose to do so, be certain that the FIND will be successful. An unsuccessful FIND places the record pointer on record 0 which is by definition not in the index. This causes an error, suspends operation of a program, and turns off the LIMIT. 2. Do not use REPLACE ALL on a field included in an active limit expression, since upon completion, no records will be included in the limit; the result is the same as above. 3. Do not use APPEND, APPEND BLANK or BROWSE APPEND, or enter "append mode" in EDIT, while a limit is active unless you are sure to make all new records equal to the current LIMIT key before leaving the new records. Doing so causes the record pointer to move outside the LIMIT; the result is the same as above. 4. LIMIT should be used with extreme care, and left in effect for the minimum number of commands possible. For instance, if used with BROWSE, LIMIT should be invoked immediately before the BROWSE command and canceled immediately afterward. 5. LIMIT is automatically canceled when the index or the file with which it is active is closed, or the master index is changed with SET INDEX TO n. 6. LIMIT cannot be used with a string constant instead of a <key exp>. The <key exp> can be implemented with a macro. List expressions from selected records. Options: This command lists the whole selected data file (including the records flagged as DELETED, unless the command SET DELETE ON is given). If the data file is indexed, the listing is by the indexed order. The records to be listed can be selected by scope and/or by a condition. To list only selected fields of the records, use an expression list. Examples: List files from the directory. Options: This command lists the data files, with the default extension DBF, from
the current or other specified disk drive. LIST FILES is provided only for
compatibility with earlier xBase languages; DIR should be used instead. If the LIKE clause is used, the type of file required can be specified;
the wild cards * and ? (see the DIR command) can be used just as in the
operating system command DIR. If the ON <drive letter> clause is used, only the files from the drive
specified are listed. See the Shark command DIR Examples:
List the memory variables. The command LIST MEMORY displays a listing of all non-matrix memory
variables and their contents, and a separate listing of the matrix variables
and their dimensions. Examples: Note that matrix variables are stored in high memory (see Appendix A).
The number of "bytes used" message does not take this into account. To see the
usage of high memory, use the STATUS command. See also DIM. List the structure of the selected file The command LIST STRUCTURE displays the structure of the selected data file. Examples: List the function key definitions and system variables. The command LIST SYSTEM displays the current contents of the 10 function
keys and system variables (see Sections 1.2 and 2.6). Example: To set the system variables to suit your needs, use your CNF file
as appropriate, see Section 1,"Command and Function Reference". Search for a record that satisfies the condition.
The command LOCATE searches for records by a condition. This command
works quicker if there is no index file. If a match is found with SET TALK ON, Record n
informs the user of the record number (n). The LOCATE command line cannot be more than 128 characters. The keyword
FOR cannot be in a macro. The CONTINUE command continues the search after the current record using
the condition of the last LOCATE. Normally, the selected file should not be indexed. The command LOCATE
executes several times slower in an indexed file. If an index file is in use, the search will take place in the indexed order. The preferred way to locate a record in an indexed file is with the FIND command. With the default scope ALL, LOCATE starts at the top of file and scans
either until the first record matching the condition is found, or the end of
file is reached; an unsuccessful LOCATE sets the EOF flag to T (true). You can use an alternate scope, NEXT or WHILE, to have LOCATE begin with
the record after the current record. Unlike all other uses of limit in Shark (or SCOPE in VP-Info), however,
LOCATE does not require anything other than the keyword to make the limit act in this way.
1>DIR
SEN_NAME.NDX 1024 10-24-89 1:07a SEN_NUM.NDX 1024 10-24-89 1:07a
SEN_REIN.PRG 757 8-31-89 11:30p SEN_SYST.DBF 53 9-06-89 9:02a
SEN_ZIP.NDX 1024 10-24-89 1:07a SUBDUE.ARC 342658 11-29-89 8:25p
SUBDUE.PRG 2027 11-29-89 7:21p SUBDUE2.PRG 1168 11-29-89 2:29a
349735 bytes in 8 files.
5251072 bytes remaining.
1>dir \*.
LIB DIR 8-04-89 2:42p MAX DIR 8-04-89 1:27p
RELTEST DIR 8-06-89 10:27a SILVERAD DIR 8-07-89 2:32p
SUPER DIR 8-27-89 8:30p TMP DIR 8-04-89 1:28p
V14 DIR 8-23-89 9:22p VAWORK DIR 8-04-89 12:09p
MANUAL DIR 10-30-89 10:53a GEN DIR 11-08-89 12:00a
0 bytes in 10 files.
5251072 bytes remaining.
1>DIR c*.dbf
1>DIR C:\TEMP\*.DBF
CCUST.DBF 522 10-13- 99 5:42p COMMS.DBF 6546 1-06-122 5:11p
COMMS2.DBF 6342 1-07-112 1:00p CUSTJUNK.DBF 7062 9-17-123 3:57p
CUSTOMER.DBF 734 11-29-112 10:43p
21206 bytes in 5 files.
5251072 bytes remaining.
1>DIR C:\TEMP\CUSTOMER.DBF
CUSTOMER.DBF 734 11-29-112 10:43p
1>? DATE(6)
29-NOV-2012
1>? DATE(4)
Friday, November 29, 2012
DIRF
DIRF <file specification>
<file specification> a file name, with optional DOS wildcards; an extension is required if present
FILES
*.dbf,\data\
*.cpl,\cpl\
*.ndx,\indexes\
ENDFILES
1>DIRF C:\TEMP\*.DBF
CCUST.DBF 522 10-13- 99 5:42p COMMS.DBF 6546 1-06-122 5:11p
COMMS2.DBF 6342 1-07-112 1:00p CUSTJUNK.DBF 7062 9-17-123 3:57p
CUSTOMER.DBF 734 11-29-112 10:43p
1>DIRF C:\TEMP\CUSTOMER.DBF
CUSTOMER.DBF 734 11-29-112 10:43p
1>? DATE(6)
29-NOV-2012
1>? DATE(4)
Friday, November 29, 2012
DISPLAY
DISPLAY <scope> [FOR <cond> <exp list>] [OFF]
DISPLAY FILES [LIKE <skeleton>] [ON <drive letter>]
DISPLAY MEMORY
DISPLAY STRUCTURE
DISPLAY SYSTEM
<scope> select by scope (default: the current record)
FOR <cond> select by condition
OFF do not display the record number
LIKE <skeleton> the file specification, with optional wildcards
ON <drive letter> a drive designation, with optional colon
DO
DO <file>
<file> the name of the program called
...
PERFORM STEST
...
PERFORM STEST
...
*
PROCEDURE STEST
DO TEST
ENDPROCEDURE
PROCEDURE TEST1
SELECT 2
DO TEST
ENDPROCEDURE
*
PROCEDURE TEST2
SELECT 3
DO TEST
ENDPROCEDURE
DO INVOICE
DO CASE
DO CASE
DO CASE
CASE <cond1>
<program segment1>
CASE <cond2>
<program segment2>
...
CASE <condn>
<program segmentn>
OTHERWISE
<program segment>
ENDCASE
ans2='P'
@ 22,10 SAY 'E-edit A-add O-order L-look Q-quit ' GET ans2
READ
@ 22,10
DO CASE
CASE UPPER(ans2)='Q'
picked=f
ok=f
LOOP
CASE UPPER(ans2)='E'
@ y,3 GET style
@ y,10 GET color
@ y,14 GET descript
@ y,35 GET q1
@ y,39 GET q2
@ y,43 GET q3
@ y,47 GET q4
@ y,51 GET q5
@ y,55 GET q6
@ y,59 GET q7
@ y,63 GET q8
READ
IF q1+q2+q3+q4+q5+q6+q7+q8=0
DELETE
ENDIF
mpick=t
CASE UPPER(ans2)='O'
REPLACE type WITH 'O'
...
OTHERWISE
IF type='P'
REPLACE type WITH 'O'
ENDIF
picked=f
ENDCASE
DO WHILE
DO WHILE <cond>
<cond> the condition controlling the loop
DO WHILE <cond>
<program segment>
ENDDO
STACK OVERFLOW
EDIT
EDIT <recnum> [FIELDS <field list>] [/ OFF] [/ TEXT <textfile>]
<recnum> begin EDIT on record number <recnum>
FIELDS <field list> the fields to be edited
OFF rather than generate an EDIT input screen,
uses an existing screen and its Get Table
TEXT <textfile> erases the screen, displays the text file,
and then does EDIT using the text file
layout and embedded format pictures
1>USE employee
1>EDIT FIELDS name, fname, tel_no
<Left> or Ctrl-S moves the cursor back one character
<Right> or Ctrl-D moves the cursor forward one character
Ctrl-<Left> moves to the beginning of the field
Ctrl-<Right> moves to the end of the field
<Ins> or Ctrl-V puts you in insert mode: what you type gets inserted
(normally, you are in overtype mode: what you type
overtypes the existing text); pressing <Ins> or
Ctrl-V again, puts you back into overtype mode
EDIT TEXT
EDIT OFF
1>USE employee
1>GO 2
1>EDIT
1>EDIT 2
#1 EMPLOYEE.DBF EDIT Record 2
Page 1
REC: prev <PgUp> next <PgDn> delete ^U PAGE: prev ^K next ^L
FILE: top ^<Home> bottom ^<End> DELETE: char <Del> to end of field ^Y
APPEND MODE: begin ^<PgDn> exit <PgUp> EXIT: with save <End> no save ^Q
NAME........... Steiner
FNAME.......... Tom
ADDR........... 114 North Pitt St.
CITY........... Lakewood
STATE.......... MD
ZIP............ 02111
TEL_NO......... 596-0017
MARRIED........ y
SALARY......... 35780.00
YEAR_EMP....... 1984
DEPT........... Engineering
1>USE employee
1>SET MENU ON
1>EDIT FIELDS name, fname, tel_no
This displays:
#1 EMPLOYEE.DBF EDIT Record 7
Page 1
REC: prev <PgUp> next <PgDn> delete ^U PAGE: prev ^K next ^L
FILE: top ^<Home> bottom ^<End> DELETE: char <Del> to end of field ^Y
APPEND MODE: begin ^<PgDn> exit <PgUp> EXIT: with save <End> no save ^Q
NAME........... Marek
FNAME.......... Joe
TEL_NO......... 566-7012
EDIT TEXT
1>USE employee
1>EDIT TEXT employee
1>USE employee
1>TEXT Employee
1>EDIT OFF
EDIT Record 23
NAME........... ARTHUR NEUMANN
ADD_1.......... 4274 MATHERS BLVD. E. UPSON DOWNS
ZIP............ 59768
PHONE.......... 243-5548 (614)
WPHONE......... 643-5657 (614)
EXPERIENCE.....
ACCT STUDENT, WORKED FOR CPA SCARECROW & MOSCOWITZ, BOSTON
COMMENTS
KNOWS INCOME-TAX LAW, WITH SPECIALTIES IN DEpreCIATION AND
TAX SHELTERS; SUGGEST ASSIGN TO CENTRAL OFFICE
.. zip,!9! 9!9
.. phone,999-9999 (999)
.. wphone,999-9999 (999)
.. training,99/99
NAME........... %FNAME %NAME
ADD_1.......... %ADD_1 %AREA
ZIP............ @ZIP
PHONE.......... @PHONE
WPHONE......... @WPHONE
EXPERIENCE.....
@EXPERIENCE
COMMENTS
@COMMENT1
@COMMENT2
EDIT OFF
* EDIToff.prg demonstration program for the EDIT OFF command
* Note the technique used to "wrap" the file...when skipping
* past EOF, program "wraps to top of file, and vice versa,
* using SOUND command to beep (silent if NOEFFECTS in SHARK.SET).
USE customer
ON escape ;what to do when <Esc> is pressed
WINDOW ;cancel small window
CURSOR 23,0 ;put cursor in bottom left corner of screen
CANCEL ;exit program
ENDON
WINDOW
ERASE
*
TEXT
REC: prev <PgUp> next <PgDn> DELETE RECORD <Ctrl>U
FILE: top <Ctrl><Home> bottom <Ctrl><End> DELETE: char <Del> to end of field <Ctrl>Y
APPEND MODE: begin <Ctrl><PgDn> exit <PgUp> EXIT: with save <End> no save <Ctrl>Q
ENDTEXT
WINDOW 8,10,17,69 double
TEXT
.. custnum,!!!-!-99
.. hphone,999-9999 (999)
.. wphone,999-9999 (999)
.. state,!!
Enter customer data:
Number...... @custnum
Name........ %firstname %lastname
Address..... @address
City, State. %city %state
Zip Code.... @zip
Phones (H/W) %hphone %wphone
ENDTEXT
DO WHILE t
EDIT off ;edit using Get Table created with TEXT above
DO CASE
CASE :key=335 ;exit loop when <End> key pressed
BREAK
CASE eof ;skipped past end of file; start again at top
ring
GOTO top
CASE #<1 ;backed up past beginning of file; start again at bottom
ring
GOTO bottom
IF eof ;if no undeleted records left in file, get out
BREAK
ENDIF
ENDCASE
ENDDO
WINDOW ;cancel small window
CURSOR 23,0 ;put cursor in bottom left corner of screen
EJECT
EJECT
1>EJECT
SPOOL junk
EJECT
SPOOL
ELSE
ELSE
IF count>5
ok=t
ELSE
IF count<2
ok=f
ENDIF
? 'ok'
ENDIF
END commands
ENDCASE
ENDDO
ENDIF
ENDFILES
ENDON
ENDPROCEDURE
ENDREPEAT
ENDTEXT
ERASE (or CLS)
ERASE [line1,line2]
line1, line2 erase from line1 to line2
CLS
ERASE 0,24
CLS 0,24
1>ERASE
1>ERASE 2,4
1>ERASE 2,2
FIELD
FIELD <fieldname>/<fieldnum>
fieldname name of a field in a Get Table
fieldnum number of a field in a Get Table
FIELD 3
FIELD cust
FIELD name#3
FIELDS=
FIELDS= <num>
<num> = maximum number of fields allowed in all data files
open at any one time (including Shark's
internal work file); range 128 to 1000
FIELDS=500
FILES
FILES
FILES
file direction any legal DOS path, consisting of drive letter and colon and/or directory path
mode any one of the optional file-opening modes used
in network operation -- LOCK or L, WRITE or W,
READ or R, or SHARE or S. If no mode is set,
or if Network Edition is not in use, the
default mode is LOCK
FILES
1>FILES
FILES *.frm
FILES *.ndx,ndx,READ
FILES *.dbf,,WRITE.)
FILES ... ENDFILES
FILES
mode any one of the optional file-opening modes used
in network operation -- LOCK or L, WRITE or W,
READ or R, or SHARE or S. If no mode is set,
or if Network Edition is not in use, the
default mode is LOCK
*.dbf,c:\data
FILES
ENDFILES
*.ndx,ndx,READ
FILES=
FILES= <num const>
<num const> maximum number of files that can be open at any one time; range 21 to 65
1>FILES=50
FILES LIST
FILES LIST
1>FILES LIST
File Spec Drive and/or Path
*.CPL CPL2\
*.NDX NDX2\
*.DBF DBF\
*.DBK DBK\
FIND
FIND <string>
FIND TAYLOR
FIND &var
SEEK var
1>FIND TAYLOR
1>FIND TOM
1>FIND AB
1>FIND ab
1>FIND Taylor
1>FIND &'Taylor'
1>SEEK 'Taylor'
or if name='Taylor' use one of the following forms:
1>FIND &name
1>SEEK name
IF #=0 or
IF RECNO()=0
FLUSH
FLUSH
1>FLUSH
GLOBAL
GLOBAL <memvar list>
GLOBAL a,b,c,d
GLOBAL a,b,c,d
GLOBAL x,y,c,d
GLOBAL a,b,c
GLOBAL a,b,c,d,e
CHAIN PROG2
GLOBAL transact,process,custrange,type
GLOBAL transact,process,custrange,type
GLOBAL transact,process,custrange,type,trdate
GLOBAL transact,process,custrange,type,trdate
GO
<num const>
GO <num exp>
GOTO <num exp>
GO RECORD <num exp>
GOTO RECORD <num exp>
GO TOP
GOTO TOP
GO BOTTOM
GOTO BOTTOM
GO <num exp>
GOTO <num exp>
GO RECORD <num exp>
GOTO RECORD <num exp>
1>2
1>GO 2
1>GOTO 2
1>GO (2+2)/2
1>(2+2)/2
1>USE employee
1>GOTO 2
1>DISPLAY name
2 Steiner
1>5
1>DISPLAY name
5 Poyner
1>GOTO 1
1>DISPLAY name
1 Marek
1>GO BOTTOM
1>DISPLAY name
6 Wilson
1>GO TOP
1>DISPLAY name
1 Marek
GOTO
<num const>
GO <num exp>
GOTO <num exp>
GO RECORD <num exp>
GOTO RECORD <num exp>
GO TOP
GOTO TOP
GO BOTTOM
GOTO BOTTOM
GO <num exp>
GOTO <num exp>
GO RECORD <num exp>
GOTO RECORD <num exp>
1>2
1>GO 2
1>GOTO 2
1>GO (2+2)/2
1>(2+2)/2
1>USE employee
1>GOTO 2
1>DISPLAY name
2 Steiner
1>5
1>DISPLAY name
5 Poyner
1>GOTO 1
1>DISPLAY name
1 Marek
1>GO BOTTOM
1>DISPLAY name
6 Wilson
1>GO TOP
1>DISPLAY name
1 Marek
HELP
HELP <string>
<string> the topic for which help is wanted
1>HELP
1>HELP
1>HELP REPLACE
IF
IF <cond>
<cond> the condition to be evaluated; if true, segment is executed
IF <cond>
<program segment>
ELSE
<ELSE program segment>
ENDIF
IF count>5
STORE T TO ok
ELSE
IF count<2
STORE F TO ok
ENDIF
? 'ok'
ENDIF
do while count<5
if name='DAVID'
name=name+fname
enddo
endif
as follows:
DO WHILE count<5
IF name='DAVID'
name=name+fname
ENDIF
ENDDO
IF num=1
name='DAVID'
ELSE
IF num=2
name='GEORGE'
ELSE
IF num=3
name='TOM'
ELSE
name='UNKNOWN'
ENDIF
ENDIF
ENDIF
DO CASE
CASE num=1
name='DAVID'
CASE num=2
name='GEORGE'
CASE num=3
name='TOM'
OTHERWISE
name='UNKNOWN'
ENDCASE
cond2=' ' ;make sure cond2 exists
cond2=&condition ;assign macro to pre-existing variable
IF cond2 ; now IF does not have a macro
...
INDEX - See the following:
INDEX ON
INDEX ON <str exp> TO <file> [FOR <cond>]
<str exp> the expression providing the key
<file> the name of the index file
FOR <cond> a selection; only records for which <cond> is true are
included in the index.
inde on $(CUST,1,3) TO CUSTOMER
1>USE employee
1>INDEX ON name+age TO senior
6 RECORDS IN TOTAL INDEXED
1>USE employee
1>FIND B
27. File is not indexed.
1>INDEX ON name TO employee
6 RECORDS IN TOTAL INDEXED
1>LIST name
2 Balzer
1 Marek
5 Poyner
4 Rayme
3 Steiner
6 Wilson
1>FIND R
1>DISP name
4 Rayme
FIND R
1>? name
4 Rayme
STR(10000-amount,6)
USE maillist
INDEX ON zip TO utah FOR state='UT'
INDEX FROM
INDEX FROM
<file> the name of the SharkBase index file to be created
with the same key expression as
1>USE employee
1>INDEX FROM emplnum TO emplnum
6 RECORDS IN TOTAL INDEXED
1>INDEX FROM emplnum
6 RECORDS IN TOTAL INDEXED
1>INDEX FROM emplnum TO empmarry FOR married
4 RECORDS IN TOTAL INDEXED
FILES
*.dbf,c:\data
*.ndx,c:\data
*.ndt,c:\shark\ntx
*.frm,c:\shark\prg
ENDFILES
INPUT
INPUT ['<string>'] TO <memvar>
'<string>' prompt message
<memvar> cannot be a matrix variable.
1>INPUT 'Your name: ' TO name
Your name: 'Cathy'
1>INPUT 'Your age: ' TO age
Your age: 32
1>INPUT 'Are you telling the truth? ' TO truth
Are you telling the truth? n
1>LIST MEMO
Name Type Width Contents
NAME C 5 Cathy
AGE N 8 32
TRUTH L 2 .F.
** Total ** 3 variables, 15 bytes
1>prompt='"This is a prompt: "'
1>INPUT &prompt TO hello
This is a prompt: 4
1>LIST MEMORY
Name Type Width Contents
PROMPT C 20 "This is a prompt: "
HELLO N 8 4
** Total ** 2 variables... 28 bytes
KEY
KEY <number> <caption>
KEY <func_key> <caption>
<number> character number as returned by INKEY( function
<func_key> function key name, in range F1 to F10
caption string to be printed on line 24 of screen
(space permitting)
Ctrl-<Pg Dn>.
ON KEY
KEY F1 Help
SCREEN 1,2
WINDOW
CLS
TEXT help
WAIT
SCREEN 2,1
KEY F2 Browse
SAVE gets to test
SCREEN 1,2
WINDOW
CLS
TEXT browse
BROWSE off
SCREEN 2,1
RESTORE gets from test
KEY 328
* deactivate up arrow key
KEY 374
* deactivate Ctrl-<Pg Dn> key
KEY F10 Turn Off Keys
ON KEY
ENDON
ENDON
LAST
LAST <string>
<string> the characters to match in the current master index
LAST TAYLOR
LAST &var
1>LAST TAYLOR
1>LAST TOM
1>LAST AB
1>LAST ab
1>LAST Taylor
1>LAST &'Taylor'
1>LAST &name
LIMIT
LIMIT <num exp>
LIMIT <key exp>
LIMIT
<num exp> the number of characters in the key expression of
the current master index
<key exp> the string expression to match in the current master index
LIST
LIST <scope> [FOR <cond> <exp list>] [OFF]
<scope> select by scope (default scope: ALL)
FOR <cond> select by condition
<exp list> items to list
OFF do not print the record numbers
1>USE employee
1>LIST
1 Marek Joe 231 River Drive Broomsdale
2 Balzer Joan 2407 E 38th Street Broomsdale
3 Steiner Tom 114 North Pitt St. Lakewood
4 Rayme Pamela 42368 Wedgewood Dr. Broomsdale
5 Poyner Roger 2757 Regency Road Florington
6 Wilson Robert 16255 Ventura Street Broomsdale
1>GO TOP
1>LIST NEXT 3 fname,name
1 Joe Marek
2 Joan Balzer
3 Tom Steiner
LIST FILES
LIST FILES [LIKE <file format>] [ON <drive letter>]
LIKE <file format> limit to those files matching the file format
specification (default .DBF)
ON <drive letter> show only files on named disk (colon optional)
1>LIST FILES
CCUST.DBF 1024 10-24-89 1:07a COMMS.DBF 1024 10-24-89 1:07a
COMMS.DBF 757 8-31-89 11:30p CUSTJUNK.DBF 653 9-06-89 9:02a
CUSTOMER.DBF 1024 10-24-89 1:07a RUST2.DBF 342058 11-29-89 8:25p
SUBDUE.DBF 2027 11-29-89 7:21p SUBDUE2.DBF 1168 11-29-89 2:29a
WAY_BUSI.DBF 506022 10-24-89 2:24a WAY_PHON.DBF 45525 10-24-89 1:29a
WAY_DBFS.DBF 1291 10-24-89 3:15a WAY_RES.DBF 406175 10-24-89 1:05a
1024349 bytes in 12 files.
5251072 bytes remaining.
1>LIST FILES ON A
THREE.DBF 189 6-12-88 9:21a TRANSACT.DBF 2 5-02-88 2:48p
VAITEST.DBF 552 7-28-88 12:32p
795603 bytes in 41 files.
51072 bytes remaining.
1>LIST FILE LIKE c*.*
CCUST.DBF 522 10-13-88 5:42p COMMS.DBF 6546 1-06-90 5:11p
COMMS2.DBF 6342 1-07-90 1:00p CUSTJUNK.DBF 7062 9-17-89 3:57p
CUSTOMER.DBF 734 11-29-89 10:43p
21206 bytes in 5 files.
5251072 bytes remaining.
LIST MEMORY
LIST MEMORY
1>LIST MEMO
Name Type Width Contents
** Total ** 0 Variables used 0 Bytes used
1>name='David'
1>number=12.78
1>LIST MEMO
Name Type Width Contents
NAME C 5 David
NUMBER N 8 12.78
** Total ** 2 Variables used 13 Bytes used
1>DIM NUM a[12]
1>DIM CHAR table[2,12]
1>LIST MEMO
Name Type Width Contents
NAME C 5 David
NUMBER N 8 12.78
Matrix Name Type Width Dimensions
A N 8 [12]
TABLE C 10 [2,12]
** Total ** 4 Variables used 33 Bytes used
LIST STRUCTURE
LIST STRUCTURE
1>USE employee
1>LIST STRU
Data file: EMPLOYEE.DBF
Number of records: 6
File number: 1
Field Name Type Width Dec
1 NAME C 15
2 FNAME C 10
3 ADDR C 20
4 CITY C 20
5 STATE C 2
6 ZIP C 5
7 TEL_NO C 8
8 MARRIED L 1
9 SALARY N 9 2
10 YEAR_EMP N 4
11 DEPT C 15
** Record Length ** 110
1>USE#5 order
1>LIST#5 STRU
Data file: ORDER.DBF
Number of records: 3
File number: #5
Field Name Type Width Dec
1 ORDER:NO C 6
2 CUST:NO C 6
3 INVEN:NO C 6
4 STYLE:NO C 4
5 COLOR C 2
6 CATEGORY C 2
7 DESCR C 30
8 SLSMAN:NO C 3
9 PRICE N 9 2
10 QTY N 9 2
11 COST N 9 2
12 AMOUNT N 9 2
** Record Length ** 96
LIST SYSTEM
LIST SYSTEM
1>LIST SYST
Name Type Width Contents
:F1 C 5 HELP
:F2 C 10 LIST STRU;
:F3 C 6 WRITE
:F4 C 10 LIST MEMO;
:F5 C 7 BROWSE;
:F6 C 5 STAT;
:F7 C 12 ^wCONT;EDIT;
:F8 C 11 LOCATE FOR
:F9 C 5 FIND
:F10 C 5 EDIT;
:TIME C 8 22:53:43
:DATE C 24 Thursday, March 19, 1991
:VERSION C 4 520
:SERIAL C 10 5208796982
:COMPANY C 34 Sub Rosa Publishing Inc.
:PICTURE C 10 9999999.99
:TITLE C 1
:UNDOC C 1 2003.03.14 <-- you can store application data in system
:KEY N 8 13
:AVAIL N 8 0
:FIELD N 8 0
:ERROR N 8 0
:MESSAGE C 1
:RETRY N 8 25
:USER N 8 1
:DIR C 11 C:\SHARK
:NEAR N 8 0
:COLOR N 8 48
** Total ** 28 variables... 244 bytes
LOCATE
LOCATE <scope> FOR <cond>
Option: <scope> search only within the limit (default limit: ALL)
LOCATE NEXT FOR cust>'M' ;looks for a matching record anywhere in the file, starting with the next record.
LOCATE WHILE FOR cust>'M' ;works exactly the same.
Examples:
1>USE employee 1>LIST name, salary 1 Marek 2 Balzer 3 Steiner 4 Rayme 5 Poyner 6 Wilson 1>GO TOP 1>LOCATE FOR salary > 20000 Record 1 1>? name, salary Marek 25800.00 1>CONT Record 3 1>? name, salary Steiner 35780.00 1>CONT Record 4 1>? name, salary Rayme 79110.00 1>CONT Record 6 1>? name, salary Wilson 33870.00 1>CONT 1>? EOF T
LOCK
Lock the current record.
LOCK
In Shark Network Edition, this command locks the current record to all other users so that you can safely make changes to a record key while the file is open in SHARE mode.
If SET NETWORK OFF, LOCK is ignored.
In the single-user edition, LOCK has no effect, but is accepted for program compatibility across versions.
See the command on how to get into the multi-user mode. See also UNLOCK.
Example:
mcust=cust FIND &mcust LOCK
LOCK INDEXES
Lock the current record.
LOCK INDEXES
In Shark Network Edition this command locks all indexes attached to the current data file so that you can safely make changes to a record's key while the file is open in SHARE mode.
Like the LOCK command (which locks records in a data file), and SET LOCK ON (which automatically locks each record as it is used), LOCK INDEX should be used only when files are opened in SHARE mode on a network.
LOCK INDEXES allows only one person to change the index files, though any number of others can access the indexes if they open the data file in either SHARE or READ mode. UNLOCK INDEXES will unlock the all the index file.
See the SET NETWORK command on how to get into the multi-user mode. See also UNLOCK INDEXES.
In the single-user edition, LOCK INDEXES has no effect, but is accepted for program compatibility across versions.
Example:
mcust=cust FIND &mcust LOCK INDEXES
LOOP
Jump to the top of the DO WHILE loop.
LOOP
When the LOOP command is found in a DO WHILE <cond> loop, program execution jumps to the top of loop (evaluates the condition). See also DO WHILE and BREAK.
Example:
USE cust USE#2 trans INDEX trans1 DO WHILE T ACCEPT 'Enter the customer number ' TO mcust IF TRIM(mcust)=' ' BREAK ENDIF FIND#2 &mcust IF RECNO(2)=0 LOOP ENDIF SELECT 2 DO WHILE custn=mcust .AND. .NOT. EOF ? date,descript,amount SKIP ENDDO SELECT 1 ENDDO
MAX
Scan selected records for the highest values of one or more numeric expressions.
MAX <scope> <num exp list> [TO <memvar list>] [FOR <cond> ] <num exp list> the numeric expressions to sum
Options:
<scope> select by scope (default scope: ALL) <memvar list> store the results in these memory variables FOR <cond> select by condition
The command MAX evaluates numeric expressions for selected records of the selected data file, determining the highest value encountered for each expression. Up to 10 expressions can be scanned with one command.
Optionally, the results can be stored in numeric memory variables; the expression list and the numeric memory variable list must have the same number of entries. <memvar list> cannot contain numeric matrix variables.
Records flagged as DELETED are not scanned. See also MIN, SUM, COUNT and AVERAGE.
Example:
The highest hourly wages, the highest annual earnings, and the highest number of hours worked in the year:
1>USE employee 1>MAX hourly,ydt_earned,ytd_hours 6 RECORDS CHECKED 32.57, 51579.65, 2632.65 1>SET TALK OFF 1>MAX hourly,ydt_earned,ytd_hours TO maxrate,maxearned,maxhours 1>? maxrate,maxearned,maxhours 32.57 51579.65 2632.65
MEMORY=
Request a specific memory configuration.
MEMORY=<blocks> (SHARK.SET file only) <blocks> number of 1K blocks of memory to reserve for high memory
The command MEMORY= in the SHARK.SET file allocates a specific amount of high memory for use of Shark rather than the default of 128K.
The number of blocks can be as little as 32, although Shark can be expected to be sluggish in performance at that level, and there will be little space available for matrixes and background screens.
High memory is used for a wide variety of tasks in Shark, including storage of index blocks, print spooling, background screen storage, matrixes, table storage, program swap area, etc. Requesting 32 to 127 blocks decreases the space available for these tasks, but increases the space available for storing binary files to be executed with the CALL command (see BINSPACE= command) and for running programs in DOS (see RUN command).
If large amounts of memory are required for matrixes, you may need to request more than 128 blocks. Requesting more memory than available will not cause an error; Shark always takes all the memory there is or the amount requested, whichever is less.
See Appendix A for more about organization of memory.
Example:
MEMORY=96
MIN
Scan selected records for the lowest values of one or more numeric expressions.
MIN <scope> <num exp list> [TO <memvar list>][FOR <cond> ] <num exp list> the numeric expressions to sum Options:<scope> select by scope (default scope: ALL) <memvar list> store the results in these memory variables FOR <cond> select by condition
The command MIN evaluates numeric expressions for selected records of the selected data file, determining the lowest value encountered for each expression. Up to 10 expressions can be scanned with one command.
Optionally, the results can be stored in numeric memory variables; the expression list and the numeric memory variable list must have the same number of entries. <memvar list> cannot contain numeric matrix variables.
Records flagged as DELETED are not scanned. See also MAX, SUM, COUNT and AVERAGE.
Example:
Compute the lowest hourly wages, the lowest annual earnings, and the lowest number of hours worked in the year:
1>USE employee 1>MIN hourly,ydt_earned,ytd_hours 6 RECORDS CHECKED 5.57, 1579.65, 232.65 1>SET TALK OFF 1>MIN hourly,ydt_earned,ytd_hours TO maxrate,maxearned,maxhours 1>? maxrate,maxearned,maxhours 5.57, 1579.65, 232.65
MODIFY
Modify the structure of a data file.
MODIFY [STRUCTURE]
The command MODIFY (or MODIFY STRUCTURE) modifies the structure of the selected file. The display is the same as in CREATE, the keys retain their meaning. Each field is represented by four editing fields.
All records in the file will be automatically appended. If any types or names are changed, the contents of the affected fields will be lost.
Restrictions:
Do not use MODIFY in a program
Do not use MODIFY merely to change the name of a field. Fields may be renamed instantaneously with the RENAME FIELD command.
Editing keys:
<Left> or Ctrl-S Moves the cursor back one character <Right> or Ctrl-D Moves the cursor forward one character <Ctrl-Left> Moves to the beginning of the editing field <Ctrl-Right> Moves to the end of the editing field <Ins> or Ctrl-V Puts you in insert mode: what you type gets inserted (normally, you are in overtype mode: what you type overtypes the existing text); pressing <Ins> or Ctrl-V again, puts you back into overtype mode <BACKSPACE> Deletes the character to the left of the cursor <Del> or Ctrl-G Deletes the character on the cursor Ctrl-Y Deletes the rest of the editing field <Up> or Ctrl-E Moves the cursor to the previous editing field <Dn> or Ctrl-X Moves the cursor to the next editing field Ctrl-Q Quits and does not modify the file <End> or Ctrl-W Quits and modifies the file Ctrl-K Moves back to the top of the previous page Ctrl-L Moves to the top of the next page Ctrl-N Inserts a new line Ctrl-T Deletes the line
To be safe, make a back up copy of the file to be modified before the MODIFY command is given. After the MODIFY, the new fields will be blank, the deleted fields disappear. All deleted records will also be lost.
If
Changing the characteristics of a field (say the width) effects the field the same way as in APPEND FROM.
On a network with SET NETWORK ON in Shark Network Edition, attempting to MODIFY a file while another user is accessing it will cause a LOCK error. Always open a file in LOCK mode before modifying it.
Example:
Change the FNAME field in EMPLOYEE.DBF from 10 characters to 15 characters.
1>USE employee 1>COPY employee to temp making a backup copy 1>MODIFY Thursday, March 22, 1990 Shark Modify EMPLOYEE.DBF Name Type Width Dec Name Type Width Dec NAME C 15 0 FNAME C 10 0 ADDR C 20 0 CITY C 20 0 STATE C 2 0 ZIP C 6 0 TEL_NO C 10 0 MARRIED L 1 0 SALARY N 9 2 YEAR_EMP N 4 0 DEPT C 15 0 UP/DOWN COLUMN MOVE ROW SAVE STRUCTURE C..Strings previous. <PgUp> left... ^K insert... ^N update... <End> N..Numbers next..... <PgDn> right.. ^L delete... ^T nochange. ^Q L..Yes/No Now change 10 to 15: Thursday, March 22, 1990 Shark Modify EMPLOYEE.DBF Name Type Width Dec Name Type Width Dec NAME C 15 0 FNAME C 15 0 ADDR C 20 0 CITY C 20 0 STATE C 2 0 ZIP C 6 0 TEL_NO C 10 0 MARRIED L 1 0 SALARY N 9 2 YEAR_EMP N 4 0 DEPT C 15 0 UP/DOWN COLUMN MOVE ROW SAVE STRUCTURE C..Strings previous. <PgUp> left... ^K insert... ^N update... <End> N..Numbers next..... <PgDn> right.. ^L delete... ^T nochange. ^Q L..Yes/No
NEAREST
Find the first record whose index key is equal to or greater than a given FIND string by its index in the selected data file.
NEAREST <string> <string> the characters to match in the current master index
NEAREST is one of a family of commands that finds a record in an indexed data file by matching a given string with key values in the index file: NEAREST positions the file on the first record in the index equal to or greater than the FIND string. If no key in the index is equal to or greater than the FIND string, the current record pointer and :NEAR are set to the bottom of file, and EOF is set to T (true)
FIND positions the file on the first record in the index matching the LAST string (no-find positions the file at the top of file)
LAST positions the file on the last record in the index matching the FIND string (no-find positions the file at the top of file) SEEK is identical to FIND, except that it searches for the match to the value of a character expression instead of a string constant (no-find positions the file at the top of file)
All forms allow a search to be made on a character expression when the expression if preceded by the macro symbol "&". When the variable var='TAYLOR', both of the following command lines are equivalent:
NEAREST TAYLOR NEAREST &var
In Conversational Shark, just type NEAREST and the key.
Examples:
1>NEAREST TAYLOR 1>NEAREST TOM
If SET DELETE ON, deleted records will not be found. (See the command SET.) Numbers must always be treated as strings, even if the key expression is a numeric field. If NUM is a numeric field of width 2, NEAREST 1 will not find 1, but NEAREST &STR(1,2) or NEAREST &' 1' will be successful.
For the users' convenience, Conversational Shark converts all command lines to upper case before execution. So, to find the inventory numbers that start with AB, type either of the following two commands:
1>NEAREST AB 1>NEAREST ab
It follows that
1>NEAREST Taylor
is understood by Shark as NEAREST TAYLOR. If you have to find Taylor, either use the string directly with the macro symbol:
1>NEAREST &'Taylor'
or if name='Taylor' use the following:
1>NEAREST &name
By definition, NEAREST is always successful (unless the file is empty). If an exact match is found, both the current record pointer (as shown by the # and RECNO( functions) and the system variable :NEAR are set to the first matching record.
If an exact match is not found, the current record pointer and the value of :NEAR will be set to the number of the first record in the index with a key greater than the FIND string; if the index contains no key greater than the FIND string, the current record pointer and :NEAR are set to the bottom of file, and EOF is set to T (true).
To position the record pointer to the record equal to or immediately less than the FIND string, do the following:
NEAREST &findstring IF keyexpr<findstring SKIP -1 ENDIF
NOEFFECTS
Suppress special effects.
NOEFFECTS
(Use in SHARK.SET file only)
This command in the SHARK.SET file suppresses the special screen and sound effects used for the sign-on screen, as well as for the SCREEN, SOUND, and RING commands.
Examples:
NOEFFECTS
NOTE
Add notes to Shark programs.
NOTE <string>
Option:
<string> any text line: the comment
This is the same as the command * (see *). Any Shark command line that starts with NOTE is ignored by Shark.
Notes can also be added to any command line with a semicolon(;)
Since notes are not compiled, they have no effect on the execution of programs. Comments should be used liberally to help you (and possibly others) understand your programs later. If programs are very large, however, some comments may have to be shortened or eliminated to allow the compiler and/or WRITE to load them properly.
Examples:
NOTE This is the start of the main menu display (Shark ignores this line) IF cust=mcust ;the start of the processing for the current customer (Shark ignores text after ";")
NOUPDATE
Do not write changes made to the current record back to the disk.
NOUPDATE
Whenever a change is made to the current record in an open data file, leaving the record or closing the file causes the changes to be written to the disk. This automatic action can be overridden by the NOUPDATE command, which tells Shark to ignore the changes.
This is essentially what happens when Ctrl-Q is pressed during EDIT and BROWSE.
Example in a program:
Suppose full-screen editing is in effect with the READ command, and you want to ignore any changes made to the record if the user presses Ctrl-Q or an erroneous key like Ctrl-T and Ctrl-U. Using the :KEY system variable that stores the key number of the key pressed to terminate the last process:
DO WHILE t READ IF :key=17 .OR. :key=20 .OR. :key=21 ;key numbers of ^Q, ^T and ^U NOUPDATE LOOP ENDIF DO CASE CASE :key=... ;check a key ... ;action based on :key value ENDCASE ENDDO
ON ERROR
Tell Shark what to do if an error is encountered during program execution.
ON ERROR
The command ON ERROR starts the ON ERROR/ENDON structure. There can be any program segment between ON ERROR and ENDON, except that no data files should be opened or closed, and no new variables created or released. This program segment is executed whenever the program encounters an error.
The ON ERROR is in effect in the program from the point where it is located. It remains in effect until another ON ERROR structure is found, or until execution leaves the current module, either on a RETURN or DO command.
ON ERROR has no effect within a subroutine called by the DO command; if the subroutine needs the same ON ERROR structure, repeat the structure in the subroutine.
Since the ON ERROR structure has no effect after returning to a calling program from a subroutine, you should consider putting this structure (possibly together with the ON ESCAPE structure) into a procedure that is performed at the beginning of the program, and after every DO command.
ON ERROR should normally include a CHAIN, CANCEL, or QUIT command to allow execution to leave the current program. Do not RETURN from a main routine.
When editing with the internal Shark programming editor (see WRITE command), Alt-F reformats the file with all structures properly indented, making it easy to see unbalanced structures.
Example:
ON ERROR ? 'Aborting program execution because Error',:error,'encountered' ? :message ; :error contains the latest error number, and ? ; :message contains its meaning RING CANCEL ENDON
ON ESCAPE
Tell Shark what to do if the user presses
ON ESCAPE
The command ON ESCAPE starts the ON ESCAPE/ENDON structure. There can be
any program segment between ON ESCAPE and ENDON, except that no data files
should be opened or closed, and no new variables created or released. This
program segment is executed whenever the user presses
The ON ESCAPE is in effect in the program from the point where it is located. It remains in effect until another ON ESCAPE structure is found, or until execution leaves the current module, either on a RETURN or DO command.
ON ESCAPE has no effect within a subroutine called by the DO command; if the subroutine needs the same ON ESCAPE structure, repeat the structure in the subroutine.
Since the ON ESCAPE structure has no effect after returning to a calling program from a subroutine, you should consider putting this structure (possibly together with the ON ERROR structure) into a procedure that is performed at the beginning of the program, and after every DO command.
ON ESCAPE should normally include a CHAIN, CANCEL, or QUIT command to allow execution to leave the current program.
When editing with the internal Shark programming editor (see WRITE command), Alt-F reformats the file with all structures properly indented, making it easy to see unbalanced structures.
Example:
ON ESCAPE ? 'Aborting program execution becausekey pressed.' RING CANCEL ENDON
ON FIELD
Control the processing of data input during execution of the full-screen editing commands: READ, EDIT, APPEND, and BROWSE.
ON FIELD
The command ON FIELD starts the ON FIELD/ENDON structure. There can be any program segment between ON FIELD and ENDON, except that no data files should be opened or closed, and no new variables created or released.
Inside the ON FIELD structure is a number of FIELD statements, each telling Shark what to do when the user leaves a specific field, enters a new record, or leaves the record. There can be one FIELD statement for each input field in a Get Table, in addition to the two FIELD statements controlling entry and exit from READ (or the current record in EDIT and BROWSE).
(Note that the term editing field does not refer in this case only to fields, but to the on-screen area where you're expected to enter or edit data; an editing field may be a "window into" a data-file field, a memory variable, or a system variable. An element in a matrix cannot be accessed with the full-screen editing commands, so cannot be tied to an editing field.)
ON FIELD is used primarily for the following three functions:
1. To verify data input. If the value entered does not meet a condition, the cursor can be directed back to the current field with the :FIELD=FIELD(fieldname) command.
2. To do data lookups from the selected or other files. For example, suppose the first field in the screen is mcust; when a customer number is entered FIND &mcust is executed and the proper record found in the current file. If an invoice number is entered, data can be retrieved from the proper invoice with a FIND into another indexed file.
3. To change the order in which the cursor goes to the next field. For example, a TEXT can have three columns of input figures; Shark normally goes left to right on each line, and then top to bottom, but appropriate use of the :FIELD system variable can direct the cursor to do one column at a time.
ON FIELD exception handling only works with memvars (eg: 'MC') and not with dbf fields (eg: 'CA1'). The data handling works OK, but the ON FIELD doesn't catch the exceptions.
The form of the ON FIELD structure:
ON FIELD FIELD 0 <initiating command sequence> ;The FIELD 0 code is executed when READ is entered or whenever a new record is entered in BROWSE OFF, EDIT OFF, etc. Field 1 <command sequence 1> ;The FIELD 1 code is executed when the cursor leaves the first editing field (and again when the current record is exited provided SET EXECUTE ON). Field 2 <command sequence 2> ;The FIELD 2 code is executed when the cursor leaves the second editing field (and again when the current record is exited provided SET EXECUTE ON). Field <n> <command sequence <n> ;The FIELD <n> code is executed when the cursor leaves the nth (final) editing field (and again when the current record is exited provided SET EXECUTE ON). Field 65 <command sequence 65> ;The FIELD 1 code is executed when the cursor leaves READ or when the current record is exited in BROWSE OFF, EDIT OFF, etc. ENDON
Fields 1 through 64 may be referenced either by number of by the name of the field or variable being edited. Names are usually more understandable and always more flexible, since a field can later be added or omitted without having to renumber the entire ON FIELD structure.
You can force Shark to execute the entire set of FIELD commands from 1 through 64 by SET EXECUTION ON. The default is OFF. Do not use ON if there is a possibility of creating an endless loop which doesn't allow a graceful exit.
The Get Table is usually canceled as soon as execution leaves the current program, even when just executing a subroutine with the DO command. You can SET GET ON to maintain the Get Table, provided it is not cleared in the sub- program. (A Get Table is cleared either with the CLEAR GETS command, or by creating a GET with TEXT or an @ GET command after a READ command.) The default is SET GET OFF.
When editing with the internal Shark programming editor (see WRITE command), Alt-F reformats the file with all structures properly indented, making it easy to see unbalanced structures.
Example:
date1=date(1) CLS TEXT .. date1,99/99/99 Enter game date (must be a Wednesday) @date1 ENDTEXT ON FIELD FIELD date1 IF DATE(FULL,date1)<>"W" :field=FIELD(date1) ;use FIELD( to get correct number ENDIF ENDON DO WHILE t READ <command modules> ENDDO
Note the placement of the three elements: the TEXT with its input macro and the ON FIELD come before the READ or other full-screen editing command, and are usually outside the DO WHILE loop unless the screen is rewritten elsewhere inside the loop.
When filling in forms in a text screen, Shark moves from left to right. If you wish to fill in fields from top to bottom, you will need to use the field names/numbers to cause Shark to move to the field BELOW rather than the field to the right:
ON FIELD FIELD 0 @ 0,0 say "Edit Image of Customer Record " @ 0,52 SAY "Screen 1 File:"+mrnum color 31,24,0,24,78 :FIELD=1 FIELD 1 :FIELD=3 <-- This field is BELOW Field 1 in a 2 column screen. FIELD 3 :FIELD=5 FIELD 5 :FIELD=6 FIELD 6 :FIELD=7 FIELD 7 :FIELD=2 FIELD 2 :FIELD=4 FIELD 4 :FIELD=8 FIELD 8 :FIELD=9 FIELD 9 ENDON
ON KEY
Begin ON KEY structure, which contains one or more KEY modules defining actions to execute when specific keys are pressed.
ON KEY
The ON KEY structure, like the other ON structures in SharkBase, is not executed "in line'' as are other SharkBase commands; it is executed only when a specific condition is encountered.
In the case of the ON KEY structure, every time a key is pressed its key number is checked; if it is in the range 256 through 511, the ON KEY structure is checked to see if a special program segment has been specified for that key number and, if it has been, the program segment is executed.
The form of the ON KEY structure is as follows:
ON KEY KEY <key spec 1> <caption> <program segment 1> KEY <key spec 2> <caption> <program segment 2> .. KEY <key spec n> <caption> <program segment n> ENDON
Each KEY command introduced a program segment that is essentially a complete procedure, and like other procedures in SharkBase require a stable environment. Any program segments can be between ON KEY and ENDON, except that no data files may be opened or closed, and no new variables created or released. The data files open when the ON KEY structure is executed must remain use as long as the ON KEY is in effect.
In addition, the current work area for the program segments in the ON KEY structure will be the same as the work area in effect when the structure is first encountered. Therefore, an ON KEY program segment cannot be used to change the work area
There can be a maximum of 32 KEY statements in an ON KEY structure. All existing Key procedures are terminated by CHAINing or exiting from a program, or by encountering another ON KEY/ENDON structure.
ON KEY structures can be contained inside ON KEY structures. An ON KEY structure with no KEY commands is used to deactivate all KEY procedures.
Note: KEY commands in the ON KEY structures cannot be accessed while SharkBase waits for a keystroke in the MENU( function or the WAIT command.
The following is a trivial but complete program using an ON KEY structures to edit a file while READ is being executed on a TEXT screen:
USE test WINDOW CLS dum1='1234' dum2='ABCD' ON key KEY F10 EDIT SAVE gets to test SAVE screen to test EDIT dum1='2468' RESTORE screen from test RESTORE gets from test ENDON TEXT @dum1 @dum2 TEST SCREEN LINE ....................0 TEST SCREEN LINE ....................1 ENDTEXT DO while t READ ENDDO
Here is a more complex example in which an ON KEY structure is used to add members to a data file while:
** DEMO3.PRG SET talk off ;suppress messages SET function off ;we want the raw function keys - not the pre-loaded messages. :company="United Widgets, Inc." USE#1 order index order USE#2 members index cust_no SET relation on cust:no to 2 ON escape PERFORM shutdown ;turns on function keys and cancels ENDON WINDOW 0,23 ON KEY KEY F5 'NEW CUST' SAVE gets TO temp SAVE screen TO temp WINDOW 0,23 SELECT 2 ;work on second file APPEND blank ;add new member record EDIT ;fill it in SELECT 1 ;back to main file REPLACE CUST:NO WITH CUST_NO#2;transfer new member number to current order RESTORE screen temp RESTORE gets temp ENDON IF :color<>7 ;test for color monitor SET color to 31 ;white on blue ENDIF COLOR :color,0,0,23,79,177 ;fill screen with pattern * 177 is a shaded fill character. DO WHILE t ;put main menu in an infinite loop ERASE WINDOW 6,18,19,62 double ;declare space for menu text mode='?' ERASE ;fills window with blanks SELECT 1 TEXT Edit/Browse Demonstation 0. Exit SharkBase And return to DOS. 1. Edit Last Order. 2. Edit New Order. 3. Exit program - stay in Shark. ENDTEXT CURSOR 12,26 ; positions menu cursor over 1st character of 1st choice * Note: KEY commands in the ON KEY structures cannot be accessed while * SharkBase waits for a keystroke in the MENU( function or the WAIT command selection=menu(3,36); six choices menu bar width 36 DO CASE CASE selection=0 QUIT CASE selection=1 GOTO bottom PERFORM order_edit CASE selection=2 APPEND blank PERFORM order_edit CASE selection=3 PERFORM shutdown ENDCASE ENDDO * PROCEDURE shutdown WINDOW ON KEY ENDON SET function on CANCEL ENDPROCEDURE shutdown * PROCEDURE order_edit WINDOW 0,23 ERASE WINDOW 6,12,19,68 TEXT orders ON field FIELD cust:no FIND#2 &cust:no#1 IF lname#2=' ' ;member number not found in MEMBERS file SAVE gets to ord ;saves get table to file ORD.GET SCREEN 1,2 ;save current screen to internal screen buffer WINDOW 0,23 SELECT 2 ;work on members file NEAR#2 &cust:no#1 ;position as close as possible to right member BROWSE ;give user chance to select correct member SELECT 1 ;back to main file REPLACE cust:no#1 with cust_no#2 ;transfer selected member number SCREEN 2,1 ;restore EDIT screen RESTORE gets from ord ENDIF ENDON EDIT OFF WINDOW 0,23 ENDPROCEDURE order_edit * * *** end of DEMO3.PRG ***
OTHERWISE
Introduce the optional clause in a DO CASE program structure.
OTHERWISE
In a DO CASE program structure, if no condition is true, Shark executes the program segment following the OTHERWISE command, if any. Only one OTHERWISE command is permitted within any DO CASE structure.
Example:
DO CASE CASE CHOICE = 1 (some code to do something) CASE CHOICE = 2 (some code) CASE CHOICE = 3 (some code) OTHERWISE CANCEL ENDCASE
See more information under DO CASE.
OVERWRITE TO
Copy the fields from a record in one data file directly into the current record of another data file.
OVERWRITE TO <filenum> <filenum> any number of the data file containing the record to be overwritten
The OVERWRITE TO command is primarily used to implement transaction processing and to avoid lengthy record locks while records are being edited in a network environment. Its companion command is APPEND TO.
The technique in both cases is essentially the same, utilizing a main, indexed file and a small, unindexed personal file for each operator.
The operator edits only in the personal file, adding records as required and verifying that everything is correct before moving the data back into the main file. If the records already exist in the main file, OVERWRITE TO is used to put the corrected records back where they came from; if new records were appended to the personal file, APPEND TO is used to add them to the end of the main file.
The two files do not need to have the same structures. Any fields which do not exist in both files will be unaffected; any that are smaller in one than the other create risks of losing some data due to string truncation or numeric overflow.
Executing OVERWRITE TO is much faster than a long series of REPLACE commands.
Example in a program with SET NETWORK ON (Shark Network Edition only):
USE customer INDEX custnum,custname SHARE USE#2 personal SET FUNCTION OFF DO WHILE t SET SAVE OFF EDIT TEXT customer ;use formatted EDIT IF usedby<>0 WINDOW 20,30,22,75 DOUBLE ;pop up a window for message recnum=RECNO(1) TEXT .. recnum,'999,999' .. usedby,999 Record &recnum is in use by user &usedby press any key to skip to next record... ENDTEXT junk=INKEY() ;wait to keystroke SKIP LOOP ENDIF IF :key=324 ;F10 means edit this record REPLACE usedby with :USER ;mark record as in use by you OVERWRITE TO 2 ;then move into personal file SELECT 2 ;select personal file SET SAVE ON ;allow changes to be saved CLS ;clear the screen TEXT custedit ;with "CHANGES PERMITTED" message READ WINDOW 20,30,22,75 DOUBLE ;pop up a window for confirmation ans='No ' recnum=RECNO(1) TEXT .. recnum,'999,999' ..,ans,!xx Changes may have been made to record #recnum Save all changes (Yes/No) @ans ENDTEXT IF ans='Y' OVERWRITE to 1 ENDIF REPLACE usedby with 0 ;free the record for other users ENDIF ENDDO
PACK
Remove deleted records from the selected file.
PACK [TRUNCATE]
Option:
TRUNCATE reduce the DOS size of the file
This command removes records that have been marked for deletion by the DELETE command or the Ctrl-U of the EDIT and BROWSE commands.
All the index files in use are automatically reindexed after PACK. (See INDEX and REINDEX.)
Make sure you have a back up copy of the file before packing it. If PACK is interrupted, the file may be corrupt or contain duplicate records.
PACK does not release disk space unless the TRUNCATE option is used. If a file frequently gets large, has many records deleted and then grows again, it may be more efficient to PACK without TRUNCATE, so that DOS is not constantly adding disk clusters and recovering them again.
On a network with SET NETWORK ON in Shark Network Edition, attempting to PACK or create an index while another user is accessing the data file or an index file with the same name as any of the current indexes will cause a LOCK error. Always LOCK the data file before attempting to PACK.
Examples:
1>USE employee 1>GO 2 1>DELETE 1 DELETE(S) 1>LIST name 1 Marek 2 *Balzer 3 Steiner 4 Rayme 5 Poyner 6 Wilson 1>PACK 5 TOTAL PACKED 1>LIST name 1 Marek 2 Steiner 3 Rayme 4 Poyner 5 Wilson
PERFORM
Execute a procedure.
PERFORM <procedure> <procedure> the name of the procedure
The command PERFORM is used to execute a procedure, <procedure>, defined in the current program; <procedure> cannot be a macro. The procedure is defined with the PROCEDURE command (see PROCEDURE).
The procedure is compiled where it is first called with PERFORM. If the procedure makes references to fields, the structure and order of the files in use must be the same any time the procedure is used. The same comment also applies to memory variables. Normally, procedures perform tasks that are independent of the environment (files in use and memory variables) or they are always invoked in the same environment.
If you need the same procedure in different environments, write the procedure as a separate program, and invoke it as a subroutine with the DO command. See the command DO.
Performing procedures is a very fast way of executing the same program segment from many places in the program. The procedures themselves must be at the end of the program.
Example:
PERFORM header DO WHILE .NOT. EOF ... line=line+1 IF line>55 PERF header ENDIF ENDDO CHAIN menu * PROCEDURE header TEXT &:DATE &:COMPANY Page &page Sales Journal Date Invoice # Description Units Dollars ENDTEXT line=6 ENDPROCEDURE
POST
Post the FROM (transaction) file to the POSTING file (selected file with index).
POST ON <str exp> FROM <file> [FIELDS] [<scope>] [FOR <cond> <str exp> the expression that is the key for finding the records in the FROM file <file> the FROM file
Options:
FIELDS <mixed field list> the fields to be totalled in the FROM file and added to the fields in the POSTING file (the selected file); <field> WITH <num exp> can add an expression <scope> selection restricted by scope (default scope: ALL) FOR <cond> selection restricted by <cond>
The selected file, called the POSTING file, must be indexed by <str exp>, an expression formed from fields of the FROM file, called the FROM file, and constants and memory variables.
This procedure takes all the appropriate records (that is, the first record satisfying the <cond> and within the scope) of the FROM file, one at a time. It picks the first appropriate record, and evaluates <str exp> in the FROM file. Next it finds the matching record in the POSTING file. If the find is not successful, an error message POST ERROR" is sent.
If the find is successful, the procedure posts. Posting consists of one of two actions, depending on whether a field name is listed alone in the mixed field list, or if a field name has a WITH clause attached.
1. If the field is named alone, the value of that field in the FROM file is added to the value already in the POSTING file.; that is, it adds the fields in the <field list> of the current record of the FROM file to the fields of the same name in the current record of the POSTING file.
2. In a mixed field list, the clause <field> WITH <num exp> allows adding any numeric expression <field> to the field in the POSTING file. <num exp> is formed using the fields of the FROM file, and optionally fields from other files (including the POSTING file), variables, and constants.
If a find is unsuccessful and SET ADD ON, a record will be appended to the POSTING file, the non-numeric fields of the POSTING file record will be replaced by the matching fields in the FROM file record, and, finally, the procedure posts as above.
The procedure continues with the next appropriate record of the FROM file.
If there is no FIELDS clause, POST simply checks whether there is a record in the POSTING file for each value of <str exp> in the FROM file. This is valuable to check whether every record in the FROM file has a matching record in the POSTING file without changing any fields.
If SET PRINT OFF (the default), the error messages appear on the screen; otherwise, they are echoed to (printed on) the printer (or to the alternate text file, if SET ALTERNATE ON).
Deleted records are not posted, irrespective of SET DELETED.
Important programming note: The POST command automatically opens the FROM file in its internal work area; if the FROM file is already open in another work area, the compiler will assume it is closed when the POST command is passed during execution, even if that command is in an IF, CASE or other structure module that is not executed!
Therefore, if there is any reference to the FROM file later in the program, open the file in the proper work area again immediately after the POST command. If it is not actually needed after the POST is executed (e.g., the program exits after the POST), open it with the COMPILE keyword. Example:
USE#4 invoices COMPILE
See also the related commands: TOTAL and UPDATE.
Example:
Use the data files SALESMEN and ORDER (see Appendix), to record the amount of merchandise sold.
1>SET TALK ON 1>USE salesmen 1>INDEX ON slsman:no TO salesmen 2 RECORDS IN TOTAL INDEXED 1>POST ON slsman:no FROM order FIELDS amount FROM order 2 ** POST ERROR ** 4 5 POST(S) 1>LIST 1 1 Smith John 4386.00 2 5 Willson Tom 14679.50
The error message POST ERROR indicates that in the ORDER file there is a record (number 2) with a salesman code ("4") not found in the SALESMEN file.
Note that the amount for Smith is 2709.00 (the amount that was in the SALESMEN file) +1677.00 (the amount in ORDER record 5).
The amount for Willson is 12089.00 (the amount that was in the SALESMEN file) +597.50 (the amount in order 1) +559.00 (the amount in order 3) +1434.00 (the amount in order 4).
Of course, the most typical example of the use of the command POST is posting to a general ledger (the POSTING file) from a journal (the transaction file).
PROCEDURE
Procedure (subroutine) definition.
PROCEDURE <procedure> <procedure> the name of the procedure
The PROCEDURE command indicates the start of a procedure definition, the ENDPROCEDURE command indicates the end of the procedure:
PROCEDURE <procedure> <program segment> ENDPROCEDURE
Procedures should be used for all Shark program segments that are used more than once in a program. However, if the procedure makes references to fields, the structure and order of the files in use must be the same any time the procedure is used. The same comment also applies to memory variables. Normally, procedures perform tasks that are independent of the environment (files in use and memory variables) or they are always invoked in the same environment.
If the whole program will not fit in memory, then replace the procedures by subroutines invoked by the DO command. (See CHAIN, PERFORM, and PROCEDURE.)
The procedure name, <procedure>, follows the same rules as variable names (see Section 2); <procedure> cannot be a macro. Procedures must be placed at the end of the program. A procedure can perform other procedures.
A procedure is compiled at the first PERFORM invoking it. (See Example 1 in Appendix A)
Hint: If the same procedure must be used in more than one subroutine, add a digit (1, 2, 3, etc.) to the name in the various subroutines. Example: if a procedure called BELL is needed in main program ENTER and subroutines ENTER1 and ENTER2, call it BELL, BELL1 and BELL2 in the three program modules respectively.
Examples:
1. A simple label printing procedure.
INPUT 'Enter the number of labels to print ' TO nlabel REPEAT nlabel TIMES PERFORM label SKIP ENDREPEAT * PROCEDURE label ; prints 5 lines of data and 4 blank lines ? name ; on standard labels one across ? add:1 ? add:2 ? add:3 ? postal ? ? ? ? ENDPROCEDURE ; end of label printing
2. A procedure to clear screen, make border, set standard heading, and create reverse video black for menu choices. This procedure would be called before any menu display in the program.
PROCEDURE MENUSCREEN ERASE WINDOW 2,1,23,77 DOUBLE COLOR 112, 6, 4, 22, 74 @ 3,0 SAY CEN(:COMPANY, 80) @ 5,0 SAY CEN('Enter your choice below:',80) ENDPROCEDURE menuscreen
PSTRING
The PSTRING command sends a printer-control string to the printer without itself printing. It is used for styling printer fonts in Shark documents.
PSTRING = a list of characters, in a special format, to be output to the printer or the printer file
An enormous variety of printers emerged under MS-DOS, with their often-obtuse control languages such as HP's PCL (printer control language). Programming languages like Shark needed to pass these instructions embedded in text output in order to control attached printers.
SharkBase offers a limited set of tools to specify characters in your printouts.
The setup string is a list of character descriptors, separated by commas. Each descriptor may be a number (the ASCII value of a character), a hex number followed by an "h" (the hex value of a character), or any alpha character.
Examples:
PSTR 27,W,1Bh,41h,3h A variable or field containing the setup string may be used in a macro: ps='27,W,1Bh,41h,3h' PSTRING &ps
A group of HP's PCL instructions looks like this:
27,"(8U",27,"(sp12h5vs3b8T" 27,"(8U",27,"(sp10h12v3T" 27,"(8U",27,"(sp10h12v3T" 27,"(8U",27,"(sp10h12v0s3b3T" 27,"(8U",27,"(sp10h12v3T" 27,"(8U",27,"(s1p14v0s0b4T" 27,"(8U",27,"(sp10h12v3T" 27,"(8U",27,"(sp10h12v3T" 27,"(8U",27,"(sp10h12v3T" 27,"E" 12
These macros can be stored in a text file which is read by a Shark program along with a text document that is to be printed.
In order to be fed properly to the printer, the macros need to be parsed by a Shark program and stored in memory at the time of printing. They are read into memory with a small program such as this:
* read in printer data macros from PRINTER.DTA ... OK=ROPEN("PRINTER.DTA",2); opens the printer PCL data file IF .NOT. OK RING ? "Printer not installed!" WAIT CANCEL ELSE OK=READ(_PNORM,2)<-- normal text OK=READ(_PCOMP,2)<-- compressed OK=READ(_PCOFF,2)<-- compressed off OK=READ(_PBOLD,2)<-- bold OK=READ(_PBOFF,2)<-- bold off OK=READ(_PWIDE,2)<-- wide OK=READ(_PWOFF,2)<-- wide off OK=READ(_PRSET,2)<-- reset printer OK=READ(_PFF,2)<-- form feed (not used in vDOS/Windows) ENDIF *release printer OK=CLOSE(2)
vDOS prints Shark text output without PCL codes, but the printout will be limited to your single basic default font, likely the Windows "Courier" font. PSTRING allows some limited management of your default font, mainly character weight (light, bold, etc).
QUIT
Leave Shark.
QUITOption: a value passed to DOS, which allows batch files to control their execution with the IF ERRORLEVEL command
The command QUIT exits from Shark. It closes all the files and gives you the prompt of the operating system.
If Shark is running unattended in a batch file, a program can pass an "errorlevel" to DOS indicating if some condition was encountered during execution. For instance, if there is an error reading a data file, you can QUIT to DOS with an errorlevel of 1, which the batch file can detect so that the tape backup is not run. The command in this case wound be QUIT 1. Consult your DOS reference manual for the IF ERRORLEVEL batch program command.
Example:
DO CASE CASE ans='0' QUIT CASE ans='2' CHAIN prog1 ... OTHERWISE QUIT 1 ;tells DOS an error encountered by Shark ENDCASE
READ
Enter full-screen editing and data entry specified by the @ GET and TEXT commands.
READ
The READ command activates the input aspect of the @ GET commands (including the @ and % macros in a TEXT). The @ GET command displays the variable at the specified location and format. The READ command puts the screen in full-screen editing mode with the current values of all fields and memory variables shown, and the new values of all the variables in the @ GET (and the @ and % macros in TEXT) commands can be entered.
If the READ changes any key of a record in an index file in use, then the index files are updated.
The READ command clears all the pending GET commands.
For the use of the editing keys in full-screen editing.
Example:
@ SAY 20,0 'Enter your choice: ' GET ans READ
is the same as:
ACCEPT 'Enter your choice: ' TO ans
except that @ SAY does not create ANS, ACCEPT does; @ SAY directs the query to a specific location on the screen.
Of course, the real use of the @ SAY and READ commands is to display more than one field for input.
RECALL
Undelete selected deleted records in the selected file.
RECALL <scope> [FOR <cond>]
Options:
<scope> select by scope (default scope: current record) FOR <cond> select by condition
Records are flagged as DELETED either with Ctrl-U in BROWSE, or EDIT, or with the DELETE command (see the commands BROWSE, DELETE, and EDIT). The command RECALL reverses the DELETED flag.
The command PACK physically removes all records flagged for deletion. After a PACK, the records can no longer be recalled.
Note that if SET DELETE ON, then RECALL will work only on a deleted record only if it is also the current record. Normally SET DELETE OFF before using RECALL.
Examples:
1>USE employee 1>GO 2 1>DELETE 1 DELETE(S) 1>LIST name 1 Marek 2 *Steiner 3 Rayme 4 Poyner 5 Poyner 6 Wilson 1>GO 2 1>RECALL 1 RECALL(S) ;record 2 was recalled 1>RECALL ;the default is the current record 0 RECALL(S) 1>DELETE RECORD 2 1 DELETE(S) 1>DELETE RECORD 4 1 DELETE(S) 1>DELETE RECORD 6 1 DELETE(S) 1>RECALL ALL 3 RECALL(S) Note: Records 2, 4, 6 are recalled 1>GO TOP 1>DELETE 1 DELETE(S) 1>DELETE RECORD 3 1 DELETE(S) 1>DELETE RECORD 5 1 DELETE(S) 1>LIST name 1 *Marek 2 Steiner 3 *Rayme 4 Poyner 5 *Poyner 6 Wilson 1>GO TOP 1>RECALL NEXT 4 2 RECALL(S) Note: Records 1 and 3 are recalled
REINDEX
Reindex all index files in use.
REINDEX [FOR <cond>]
Option:
FOR <cond> select by condition
This command takes all the index files currently in use for the selected data file, and rebuilds each index file.
In Conversational Shark, and in programs with SET TALK ON, REINDEX will output the key, the progress of the indexing procedure, showing the completion of each 100 records, and the total number of records indexed.
A FOR clause can be used to limit the records in the index(es) to those for which <cond> is true. See INDEX.
On a network with SET NETWORK ON in Shark Network Edition, attempting to REINDEX while another user is accessing an index file with the same name as one of the current file's indexes will cause a LOCK error.
Examples:
The commands:
1>USE employee 1>INDEX on name+fname TO employee accomplish the same as the following: 1>USE employee INDEX employee 1>REINDEX
Note that for REINDEX, you do not have to specify the key (name+fname) or the name of the index file (EMPLOYEE.NDX).
In a program:
USE employee INDEX employee,empl1,empl2 REINDEX
will rebuild three index files: EMPLOYEE.NDX,EMPL1.NDX,EMPL2.NDX.
The following uses a FOR clause to limit the index to current employee only, based on date of termination being blank:
USE employee INDEX employee,empl1,empl2 REINDEX FOR terminated=' '
RELEASE
Erase memory variables.
RELEASE <memvar list>/EXCEPT <memvar list>/ALL]
Options:
<memvar list> the memory variables to be released, separated by commas EXCEPT <memvar list> the memory variables not to be released, separated by commas ALL release ALL
The command RELEASE erases memory variables; it releases memory space for new memory variables. You can make a list of the memory variables you want removed, use the parameter ALL to remove them all, or use the parameter EXCEPT <memvar list> to remove all except those on the list. RELEASE ALL may cripple your application if your application loops back to the beginning (the variables required will all be gone).
This command should be used in programs only with the utmost care. Compiled programs set pointers to memory variables. If the memory variables are released, the release must be absolute, not dependent on some conditions.
Since 128 memory variables can be used at any one time, and any number of them may be matrix variables, the use of RELEASE during a program may require careful debugging afterward! When programs are chained, Shark will do a CLEAR, which includes a RELEASE ALL.
RELEASE does not affect the values of the function keys and the system variables.
Examples:
1. In conversational Shark:
1>LIST MEMO Name Type Width Contents ** Total ** 0 variables, 0 bytes 1>name='David' 1>age='11' 1>LIST MEMO Name Type Width Contents NAME C 5 David AGE C 2 11 ** Total ** 2 variables, 7 bytes 1>RELEASE age 1>LIST MEMO Name Type Width Contents NAME C 5 David ** Total ** 1 variables, 5 bytes 1>RELEASE ;RELEASE by itself does nothing 1>LIST MEMO Name Type Width Contents NAME C 5 David ** Total ** 1 variables, 5 bytes 1>age=11 1>LIST MEMO Name Type Width Contents NAME C 5 David AGE N 8 11 ** Total ** 2 variables, 13 bytes 1>RELEASE ALL 1>LIST MEMO Name Type Width Contents ** Total ** 0 variables, 0 bytes
2. In programming, from a program you might DO a number of subroutines; each uses a number of memory variables, most of which are unique to it, but which in total exceed the 128 memory variable limit. In this case, decide which variables needed to be retained, and use the RELEASE EXCEPT after each subroutine as follows:
@ 20,30 SAY ' Enter your choice: ' GET choice PICTURE'!' DO CASE choice ;menu choices CASE choice='A' DO proga RELEASE EXCEPT choice,cust,due,amount CASE choice='B' DO progb RELEASE EXCEPT choice,cust,due,amount CASE choice='C' DO progc RELEASE EXCEPT choice,cust,due,amount ENDCASE ENDDO ;menu choices
REMARK
Display message on screen or printer.c
REMARK ['']
Option:
'<file>' the text line to be displayed
Same as the command ?. <file> may be an expression list.
RENAME
Rename a file.
RENAME <file> TO <new file> <file> the file name to be changed (default extension DBF) <new file> the new name for the file (default extension DBF)
This command is similar to the RENAME command of the operating system: a file is renamed. No wild card characters are allowed.
If the file name has no extension, the extension DBF is assumed. (Do not rename a data or index file to a name starting with the letters COMP; Shark is unable to open such a file.)
Examples:
1>RENAME employee TO empl Renames EMPLOYEE.DBF to EMPL.DBF 1>RENAME employee.dbf TO employee.xyz
RENAME FIELD
Rename a field in a data file.
RENAME FIELD <field> TO <new fieldname> <field> the field name to be changed <new fieldname> the new name for the field
This command allows you to change the name of a field in a data file without doing a MODIFY, which potentially endangers the file and removes all deleted records, often necessitating a REINDEX.
Examples:
1>RENAME FIELD employee TO empl
Renames the field EMPLOYEE to EMPL in the current data file.
1>RENAME#3 FIELD cust TO customer
Caution: All programs, report forms and index files that reference the old field name must be revised before they will work properly after a field is renamed.
REPEAT
Repeat program segment a specified number of times.
REPEAT <num exp> TIMES [VARYING <num var>]
<num exp> a numeric expression; repeat the loop this many times
Option:
VARYING <num var> loop counter
The REPEAT command introduces the program structure:
REPEAT <num exp> TIMES [VARYING <num var>] <program segment> ENDREPEAT
The program lines in the <program segment> are repeated <num exp> times. The end of the program segment is indicated by ENDREPEAT.
The optional VARYING clause is used to vary a memory variable from 1 to <num exp>; at the start of the first loop, <num var> is initialized as 1; <num var> is incremented by 1 each time the top of the loop is reached.
This command is especially useful to manipulate matrix variables.
Repeats can be nested.
The BREAK command is used in a REPEAT loop to exit at the bottom of the loop. If there are nested loops, the exit is at the bottom of the innermost loop then being executed.
The Shark keywords: TIMES and VARYING should not be in macros. <num var> cannot be a matrix variable.
Note that, if <program segment> contains commands that move the current record pointer (for instance, a SKIP command), REPEAT does not terminate if EOF becomes true. Thus displaying a record and skipping in a file with 50 records, using REPEAT 100 TIMES, will display the last record in the file 51 times. DO WHILE .NOT. EOF is the better construction for such a task.
When editing with the internal Shark programming editor (see WRITE command), Alt-F reformats the file with all structures properly indented, making it easy to see unbalanced structures.
Examples:
SET WIDTH TO 40 DIM NUM num[10] REPEAT 10 TIMES VARYING count num[count]=POW(2,count) ENDREPEAT ? num
This displays:
2.00 4.00 8.00 16.00 32.00 64.00 128.00 256.00 512.00 1024.00
REPLACE
Replace field(s) in the selected data file.
REPLACE <scope> <field1> WITH <exp1> [,<field2> WITH <exp2> ... ] [FOR <cond>]
Options:
<scope> select by scope (default scope: current record) <field> WITH <exp>... list fields and expressions for replacement FOR <cond> select by condition
This command is used for changing some records in the selected data file. The number of <field> WITH <exp> is only limited by the length of a command line (254 characters).
The scope ALL can be used to change all the records in the data file. This could be dangerous. Consider backing up your data file before you use this command.
This command is very useful, especially in conjunction with SET RELATION TO, so that the fields from which <exp> is formed may come from a number of data files.
Examples:
1>USE employee 1>REPLACE name WITH 'Mareck' 1>? name Mareck 1>REPLACE ALL salary WITH salary*1.05 6 REPLACE(S) 1>LIST name,salary 1 Mareck 27090.00 2 Steiner 37569.00 3 Rayme 83065.50 4 Poyner 9145.50 5 Poyner 9145.50 6 Wilson 35563.50 1>GO TOP 1>REPLACE NEXT 4 salary WITH salary*1.06 FOR name < 'P' 1 REPLACE(S) 1>USE order 1>USE#2 clothing 1>SET RELATION ON inven:no TO 2 1>REPLACE price WITH price#2
To replace more than one field:
REPLACE q1 WITH q1-q1#2,q2 WITH q2-q2#2,q3 WITH q3-q3#2
REPORT GENERATOR
The report generator.
REPORT [FORM]