| Previous | Contents | Index |
| Example 15-21 CANCEL EXTRACT |
|---|
open table cl: name 'sheerpower:samples\client'
extract table cl
print 'Client: '; cl(last)
line input 'Press enter to continue': z$
if _exit then cancel extract
end extract
print 'Records extracted:'; _extracted
close table cl
end
Client: Smith
Press enter to continue? EXIT
Records extracted: 0
|
CANCEL EXTRACT cancels the current extract of a record and transfers control to the next statement after the END EXTRACT statement.
This statement can only be used within an EXTRACT block---that is, between an EXTRACT TABLE and an END EXTRACT pair of statements.
EXIT EXTRACT
|
| Example 15-22 EXIT EXTRACT |
|---|
open table cl: name 'sheerpower:samples\client'
extract table cl
print 'Client: '; cl(last)
line input 'Press enter to continue': z$
if _exit then exit extract
end extract
print 'Records extracted:'; _extracted
close table cl
end
Client: Smith
Press enter to continue? <ENTER>
Client: Kent
Press enter to continue? EXIT
Records extracted: 1
|
EXIT EXTRACT passes control to the corresponding END EXTRACT statement, performs final sorting (if any), and creates the extracted collection.
REEXTRACT TABLE table_name
---
[INCLUDE | EXCLUDE] cond_expr...
[SORT [ASCENDING | DESCENDING] BY expression...
---
END EXTRACT
|
| Example 15-23 REEXTRACT TABLE ... END EXTRACT |
|---|
open table cl: name 'sheerpower:samples\client', access input
extract table cl
include cl(state) = 'CA'
end extract
reextract table cl
exclude cl(phone)[1:3] <> '619'
sort ascending by cl(last)
end extract
print 'List of California Clients in Area Code 619'
for each cl
print cl(first); ' '; cl(last), cl(phone)
next cl
close table cl
end
List of California Clients in Area Code 619
Cathy Cass (619) 743-8582
Paul Johnson (619) 489-5551
Keith Kent (619) 967-5021
Pete Porter (619) 778-6709
Wayne Waters (619) 564-1231
|
REEXTRACT TABLE can be used to do a second extract on a list of structure records you previously extracted. This allows for increasingly specific records to be chosen through a series of REEXTRACTs.
REEXTRACT does an extract on the list of records previously extracted. table_name is the name associated with an open table.
END EXTRACT marks the end of the REEXTRACT construct. REEXTRACT operates the same as EXTRACT. However, REEXTRACT operates on a previously extracted list.
Extract operations by key cannot be performed with REEXTRACT. |
EXTRACT TABLE table_name: APPEND
|
| Example 15-24 APPEND Option in EXTRACT TABLE |
|---|
open table detail: name 'sheerpower:samples\detail'
set table detail: extracted 0
extract table detail, field lineid : &
key '10301001' to '10302000', append
sort by detail(prodnbr)
sort by detail(invnbr)
end extract
extract table detail, field lineid : &
key '10311001' to '10312000', append
sort by detail(prodnbr)
sort by detail(invnbr)
end extract
print 'Prod'; tab(7); 'Line ID'; tab(17); 'Quantity'
for each detail
print detail(prodnbr); tab(7); detail(lineid); &
tab(17); detail(qty)
next detail
close table detail
end
Prod Line ID Qty
22800 10301-002 2
22800 10301-004 1
22800 10301-006 2
24100 10311-003 1
24200 10301-003 1
24200 10311-009 1
28400 10311-001 2
28800 10301-009 2
28800 10311-002 9
28800 10311-005 1
28800 10311-006 1
31020 10301-005 1
31040 10311-010 2
31150 10301-001 1
31150 10301-008 8
31150 10311-004 1
31150 10311-008 1
33090 10301-007 2
33090 10311-007 1
|
The EXTRACT TABLE: APPEND statement adds records to the last collection of extracted records rather than creating a new collection.
ASK TABLE table_name: table_option [num_var | str_var]
|
The ASK TABLE statement is used to ask about various device and stable characteristics from within your programs. table_name is the name of a table whose characteristics are being asked about. table_option can be any of the table options available. The options are explained in the following sections.
ASK TABLE table_name, FIELD field_expr: item var
|
| Example 15-25 ASK TABLE FIELD: item |
|---|
open table cl: name 'sheerpower:samples\client'
ask table cl: fields num_fields
for i = 1 to num_fields
clear
ask table cl, field #i: description b$
ask table cl, field #i: prompt a$
ask table cl, field #i: position a%
ask table cl, field #i: length b%
ask table cl, field #i: heading f$
ask table cl, field #i: printmask c$, &
screenmask d$, &
help e$
print at 5,5: ''
print 'Description : '; b$
print 'Prompt : '; a$
print 'Position : '; a%
print 'Field length :' ; b%
print 'Rpt. heading : '; f$
print 'Print mask : '; c$
print 'Screen mask : '; d$
print 'Help : '; e$
delay
next i
close table cl
end
Description : Client ID number
Prompt : Client ID number
Position : 1
Field length : 5
Rpt. heading : CLNT,ID
Print mask : >####
Screen mask : digits:#####
Help : Client ID number
|
The FIELD option allows you to get information about a specific field in a table. table_name is the name of the table. field_expr is the field you are inquiring about. item specifies what type of information you are asking. The information is stored in the variable specified.
The following sections provide more information on what you can use for field_expr and on the various field items.
The ITEM information is created when the SETUP routine is used to define the field. You can refer to Chapter 16, Database Setup for information on defining fields. |
The field_expr used in the ASK TABLE FIELD: item statement can be either a constant or a string or numeric expression.
A string constant can be used to specify the field name. To use a string constant, just enter the field name, without quotes. Sheerpower will then use the string constant as the field name:
ASK TABLE sheerpower:samples\CLIENT, FIELD LAST: DESCRIPTION A$
/
the field is specified by its field name
|
You can also specify a field name with an expression. To use an expression, precede the expression with a pound sign (#). The pound sign tells Sheerpower that the following characters are an expression, not the field name. If a pound sign is not included Sheerpower will interpret the characters as a field name.
ASK TABLE CL, FIELD #FIELDNAME$: DESCRIPTION A$
/
the field is specified by the value of the variable FIELDNAME$
ASK TABLE CL, FIELD #FIELDNUM: DESCRIPTION A$
/
the field is specified by the value of the variable FIELDNUM
|
| Previous | Next | Contents | Index |