| Previous | Contents | Index |
ASK TABLE table_name, FIELD field_expr: POSITION num_var
|
POSITION returns the starting position for the specified field in a numeric variable.
ASK TABLE table_name, FIELD field_expr: PRINTMASK str_var
|
PRINTMASK returns the print mask for the specified field in a string variable.
ASK TABLE table_name, FIELD field_expr: PROMPT str_var
|
PROMPT returns the prompt for the specified field in a string variable.
ASK TABLE table_name, FIELD field_expr: SCREENMASK str_var
|
SCREENMASK returns the screen mask for the specified field in a string variable. This option is not currently used.
ASK TABLE table_name, FIELD field_expr: VRULES str_var
|
VRULES returns the validation rules for the specified field in a string variable.
Refer to the Section 6.6.6, VALID(text_str, rule_str) for information on validation rules.
| Example 15-31 VRULES - Field Definition Item |
|---|
open table cl : name 'sheerpower:samples\client' ask table cl, field bday: vrules str$ print str$ end date ymd; minlength 8 |
ASK TABLE table_name: CURRENT str_var
|
| Example 15-32 ASK 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
|
ASK TABLE: CURRENT assigns the current record value to the str_var. Once the current record has been assigned with ASK TABLE: CURRENT, the SET STRUCTURE: CURRENT statement can be used to get this record.
Sheerpower returns a zero-length string if there is no CURRENT record.
[ASK | SET] TABLE table_name: DATA str_var
|
| Example 15-33 ASK | SET TABLE: DATA |
|---|
open table daily: name 'sheerpower:samples\daily_data'
open table arch : name 'sheerpower:samples\archive_data', access outin
extract table arch
end extract
print 'Number of records in ARCHIVE_DATA: '; _extracted
delay
extract table daily
ask table daily: data row$
print row$
add table arch
set table arch: data row$
end add
end extract
extract table arch
ask table arch: data newrow$
print 'Daily data record now written to the archive data table: '; newrow$
end extract
print
print 'Updated number of records in ARCHIVE_DATA: '; _extracted
end
Number of records in ARCHIVE_DATA: 0
1AMY JOHNSON 1276
450062
100123JOSEPH FRANKLIN 2333
72800
100046ROBERT HOWARD 2333
4 92000
Daily data record now written to the archive data table: 1AMY
JOHNSON 1276 450062
Daily data record now written to the archive data table: 100123JOSEPH
FRANKLIN 2333 72800
Daily data record now written to the archive data table: 100046ROBERT
HOWARD 23334 92000
Updated number of records in ARCHIVE_DATA: 3
|
ASK/SET TABLE: DATA gets all of the data for the current record/row. This eliminates the need to make fields like "WHOLE" or "ALL" that stand for the entire data record. The new feature is especially useful when copying data from one table to another where the two tables share the same definitions (record layout).
When doing the SET, if the data is longer than the recordsize of the current record, then the data is truncated. If the data is shorter than the recordsize of the current record, then the data is filled with nulls (byte values of zero).
ASK TABLE table_name: DATAFILE str_var
|
| Example 15-34 ASK TABLE: DATAFILE |
|---|
open table cust: name 'sheerpower:samples\customer' open table cl: name 'sheerpower:samples\client' ask table cust: datafile z1$ ask table cl: datafile z2$ print z1$ print z2$ end C:\SHEERPOWER\samples\CUSTOMER.ARS C:\SHEERPOWER\samples\CLIENT.ARS |
The ASK TABLE: DATAFILE statement returns the full file name/file specification of a specified table. table_name is the specified structure name. str_var contains the returned file specification.
ASK TABLE table_name: FIELDS num_var
|
| Example 15-35 ASK TABLE: FIELDS |
|---|
open table cl: name 'sheerpower:samples\client', access input ask table cl: fields z print z end 18 |
The number of fields in a table can be determined with the ASK TABLE: FIELDS statement. The number is assigned to the numeric variable num_var.
ASK TABLE table_name: KEYS num_var
|
| Example 15-36 ASK TABLE: KEYS |
|---|
open table cl: name 'sheerpower:samples\client', access input ask table cl: keys z print z end 2 |
The ASK TABLE: KEYS statement returns the number of keys that are accessible by Sheerpower. It returns the value of 0 if no keys are available.
ASK TABLE table_name: CAPABILITY str_var
|
| Example 15-37 ASK DATA: CAPABILITY |
|---|
open data cl: name 'sheerpower:samples\client', access input ask data cl: capability z$ print z$ end INDEXED,INPUT |
Given a data expression, ASK DATA: CAPABILITY sets str_expr to a comma delimited string containing one or more of the following: INDEXED, INPUT, OUTPUT
| Table Type | Description |
|---|---|
| INDEXED | The table is indexed; it can be accessed by key with statements such as SET TABLE...KEY. |
| INPUT | You can read from the table. |
| OUTPUT | You can write to the table. |
| null string | The table is not currently open. |
| Previous | Next | Contents | Index |