| Previous | Contents | Index |
ASK TABLE table_name: EXTRACTED num_var
|
| Example 15-38 ASK TABLE: EXTRACTED |
|---|
open table cl: name 'sheerpower:samples\client' extract table cl end extract ask table cl: extracted z print 'Records found: '; z end Records found: 13 |
ASK TABLE: EXTRACTED asks the operating system for the last extracted count for the table specified.
ASK TABLE table_name: ID str_var
|
| Example 15-39 ASK TABLE: ID |
|---|
declare table str
open table cl: name 'sheerpower:samples\client'
ask table cl: id cl_id$
set table str: id cl_id$
extract table str
end extract
for each str
print str(#1); ' '; str(#2)
next str
end
20000 Smith
20001 Jones
20002 Kent
23422 Johnson
32001 Waters
43223 Errant
80542 Brock
80543 Cass
80544 Porter
80561 Derringer
80573 Farmer
|
The ASK TABLE: ID statement asks the operating system for the ID of a table and returns it in the string variable str_var.
ASK TABLE table_name: POINTER num_var
|
| Example 15-40 ASK TABLE: POINTER |
|---|
open table cl: name 'sheerpower:samples\client'
extract table cl
end extract
for each cl
ask table cl: pointer ptr
print ptr, cl(last)
next cl
end
1 Smith
2 Jones
3 Kent
4 Johnson
5 Waters
6 Errant
7 Brock
8 Cass
9 Porter
10 Derringer
11 Farmer
|
From within a FOR EACH...NEXT TABLE_NAME block, ASK TABLE: POINTER asks the table for the number of the current record pointer.
ASK TABLE table_name: RECORDSIZE int_var
|
| Example 15-41 ASK TABLE: RECORDSIZE |
|---|
open table cl: name 'sheerpower:samples\client' ask table cl: recordsize recsize print 'Logical recordsize: '; recsize end Logical recordsize: 400 |
The ASK TABLE: RECORDSIZE statement returns the record size of the table data file.
ASK TABLE table_name: ACCESS str_var
|
| Example 15-42 ASK TABLE: ACCESS |
|---|
open table inv: name 'sheerpower:samples\invoice', access input ask table inv: access x$ print x$ close table inv end SECURITY:N, READ:N, WRITE:N, UPDATE:N, DELETE:N |
The ASK TABLE: ACCESS statement retrieves the access rules for the specified table. Security level, data file read, write, update, and delete rules are returned.
15.8.13 ASK | SET TABLE #string_expr . . .
ASK TABLE #string_expr. . .
SET TABLE #string_expr. . .
|
| Example 15-43 ASK | SET TABLE#string_expr . . . |
|---|
open table cl: name 'sheerpower:samples\client'
str$ = 'CL'
fld$ = 'ID'
do_work
stop
routine do_work
ask table #str$, field #fld$: description dsc$
print 'Description is: '; dsc$
end routine
end
Description is: Client ID number
|
A string expression for the table name can be used in an ASK TABLE #string_expr or SET TABLE #string_expr statement. This allows generalized code to be written to work for several tables.
ASK TABLE table_name : ENGINE str_var
|
| Example 15-44 ASK TABLE: ENGINE |
|---|
open table cl : name 'sheerpower:samples\vendor' ask table cl : engine ename$ print 'DATABASE ENGINE is: '; ename$ end DATABASE ENGINE is: ARS |
The ASK TABLE: ENGINE statement returns the name of the database engine (record management system) being used for the specified table in str_var.
The SET TABLE statement is used to change various device and table characteristics from within your programs.
SET TABLE table_name: table_option [num_var | str_var]
|
SET TABLE table_name: CURRENT str_expr
|
| Example 15-45 SET TABLE: CURRENT |
|---|
dim a$(100)
let i = 0
open table cl: name 'sheerpower:samples\client'
extract table cl
end extract
for each cl
print cl(last); ', '; cl(first)
input 'Would you like to see this record (Y/N)': yn$
if yn$ = 'Y' then
let i = i + 1
ask table cl: current a$(i)
end if
next cl
print
for j = 1 to i
set table cl: current a$(j)
print cl(last); ','; cl(first), cl(state), cl(phone)
next j
end
Errant, Earl Would you like to see this record (Y/N)? Y
Abott, Al Would you like to see this record (Y/N)? Y
Brock, Bud Would you like to see this record (Y/N)? N
Cass, Cathy Would you like to see this record (Y/N)? N
Derringer, Dale Would you like to see this record (Y/N)? Y
Farmer, Fred Would you like to see this record (Y/N)? Y
Errant, Earl CA (408) 844-7676
Abott, Al NY (202) 566-9892
Derringer, Dale CA (818) 223-9014
Farmer, Fred FL (305) 552-7872
|
The CURRENT option sets the current record to that specified by the str_expr. The str_expr contains the information for the current record for the record management system being used. ASK TABLE: CURRENT is used to store a current record value into a string variable.
When Sheerpower executes a SET TABLE: CURRENT statement, it uses the table name and sets the current record to the value specified by the string variable. The table must be open and str_expr must contain a value stored with the ASK TABLE: CURRENT statement.
If a null string is used for the value, Sheerpower sets the table to no current record and sets _EXTRACTED to zero.
SET TABLE struc_name: CURRENT ''
|
SET TABLE table_name, FIELD field_expr: KEY str_expr
|
| Example 15-46 SET TABLE, FIELD: KEY |
|---|
open table cl: name 'sheerpower:samples\client'
line input 'Enter an ID': id$
set table cl, field id: key id$
if _extracted = 0 then
message error: 'Not found'
else
print cl(id), cl(last)
end if
end
Enter an ID? 80561
80561 Derringer
|
| Previous | Next | Contents | Index |