Sheerpower®
A Guide to the Sheerpower Language


Previous Contents Index

15.8.8 ASK TABLE: EXTRACTED

FORMAT:


        ASK TABLE table_name: EXTRACTED num_var 

EXAMPLE:

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 

DESCRIPTION:

ASK TABLE: EXTRACTED asks the operating system for the last extracted count for the table specified.

15.8.9 ASK TABLE: ID

FORMAT:


        ASK TABLE table_name: ID str_var 

EXAMPLE:

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 

DESCRIPTION:

The ASK TABLE: ID statement asks the operating system for the ID of a table and returns it in the string variable str_var.

15.8.10 ASK TABLE: POINTER

FORMAT:


        ASK TABLE table_name: POINTER num_var 

EXAMPLE:

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 

DESCRIPTION:

From within a FOR EACH...NEXT TABLE_NAME block, ASK TABLE: POINTER asks the table for the number of the current record pointer.

15.8.11 ASK TABLE: RECORDSIZE

FORMAT:


        ASK TABLE table_name: RECORDSIZE int_var 

EXAMPLE:

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 

DESCRIPTION:

The ASK TABLE: RECORDSIZE statement returns the record size of the table data file.

15.8.12 ASK TABLE: ACCESS

FORMAT:


        ASK TABLE table_name: ACCESS str_var 

EXAMPLE:

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                

DESCRIPTION:

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 . . .

FORMAT:


        ASK TABLE #string_expr. . . 
        SET TABLE #string_expr. . . 

EXAMPLE:

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 

DESCRIPTION:

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.

15.8.14 ASK TABLE: ENGINE

FORMAT:


        ASK TABLE table_name : ENGINE str_var 

EXAMPLE:

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 

DESCRIPTION:

The ASK TABLE: ENGINE statement returns the name of the database engine (record management system) being used for the specified table in str_var.

15.9 SET TABLE

The SET TABLE statement is used to change various device and table characteristics from within your programs.

FORMAT:


        SET TABLE table_name: table_option [num_var | str_var] 

SET TABLE sets characteristics of tables. table_name is the name of the table whose characteristics are being set. table_option is the option being set. The options are explained in the following sections.

15.9.1 SET TABLE: CURRENT

FORMAT:


        SET TABLE table_name: CURRENT str_expr 

EXAMPLE:

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 

DESCRIPTION:

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 '' 

15.9.2 SET TABLE, FIELD: KEY

FORMAT:


        SET TABLE table_name, FIELD field_expr: KEY str_expr 

EXAMPLE:

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