SheerPower® 4GL
A Guide to the SheerPower Language


Previous Contents Index

15.8.7 ASK STRUCTURE: EXTRACTED

FORMAT:


        ASK STRUCTURE struc_name: EXTRACTED num_var 

EXAMPLE:

Example 15-37 ASK STRUCTURE: EXTRACTED

  open structure cl: name 'sheerpower:samples\client' 
  extract structure cl 
  end extract
  ask structure cl: extracted z 
  print 'Records found: '; z 
  end
 
 
Records found:  13 

DESCRIPTION:

ASK STRUCTURE: EXTRACTED asks the operating system for the last extracted count for the structure specified.

15.8.8 ASK STRUCTURE: ID

FORMAT:


        ASK STRUCTURE struc_name: ID str_var 

EXAMPLE:

Example 15-38 ASK STRUCTURE: ID

  declare structure str 
  open structure cl: name 'sheerpower:samples\client' 
  ask structure cl: id cl_id$ 
  set structure str: id cl_id$ 
  extract structure 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 STRUCTURE: ID statement asks the operating system for the ID of a structure and returns it in the string variable str_var.

15.8.9 ASK STRUCTURE: POINTER

FORMAT:


        ASK STRUCTURE struc_name: POINTER num_var 

EXAMPLE:

Example 15-39 ASK STRUCTURE: POINTER

  open structure cl: name 'sheerpower:samples\client' 
  extract structure cl 
  end extract
  for each cl 
    ask structure 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 STRUCTURE_NAME block, ASK STRUCTURE: POINTER asks the structure for the number of the current record pointer.

15.8.10 ASK STRUCTURE: RECORDSIZE

FORMAT:


        ASK STRUCTURE struc_name: RECORDSIZE int_var 

EXAMPLE:

Example 15-40 ASK STRUCTURE: RECORDSIZE

  open structure cl: name 'sheerpower:samples\client' 
  ask structure cl: recordsize recsize 
  print 'Logical recordsize: '; recsize 
  end
 
 
Logical recordsize:   400 

DESCRIPTION:

The ASK STRUCTURE: RECORDSIZE statement returns the record size of the structure data file.

15.8.11 ASK STRUCTURE: ACCESS

FORMAT:


        ASK STRUCTURE struc_name: ACCESS str_var 

EXAMPLE:

Example 15-41 ASK STRUCTURE: ACCESS

  open structure inv: name 'sheerpower:samples\invoice', access input
  ask structure inv: access x$ 
  print x$ 
  close structure inv 
  end
 
 
SECURITY:N, READ:N, WRITE:N, UPDATE:N, DELETE:N                

DESCRIPTION:

The ASK STRUCTURE: ACCESS statement retrieves the access rules for the specified structure. Security level, data file read, write, update, and delete rules are returned.

15.8.12 ASK | SET STRUCTURE #string_expr . . .

FORMAT:


        ASK STRUCTURE #string_expr. . . 
        SET STRUCTURE #string_expr. . . 

EXAMPLE:

Example 15-42 ASK | SET STRUCTURE#string_expr . . .

  open structure cl: name 'sheerpower:samples\client' 
  str$ = 'CL' 
  fld$ = 'ID' 
  do_work 
  stop
 
  routine do_work 
    ask structure #str$, field #fld$: description dsc$ 
    print 'Description is: '; dsc$ 
  end routine        
  end
 
 
Description is: Client ID number 

DESCRIPTION:

A string expression for the structure name can be used in an ASK STRUCTURE #string_expr or SET STRUCTURE #string_expr statement. This allows generalized code to be written to work for several structures.

15.8.13 ASK STRUCTURE: ENGINE

FORMAT:


        ASK STRUCTURE struc_name : ENGINE str_var 

EXAMPLE:

Example 15-43 ASK STRUCTURE: ENGINE

  open structure cl : name 'sheerpower:samples\vendor' 
  ask structure  cl : engine ename$ 
  print 'DATABASE ENGINE is: '; ename$ 
  end 
 
 
DATABASE ENGINE is: ARS 

DESCRIPTION:

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

15.9 SET STRUCTURE

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

FORMAT:


        SET STRUCTURE struc_name: struc_option [num_var | str_var] 

SET STRUCTURE sets characteristics of structures. struc_name is the name of the structure whose characteristics are being set. struc_option is the option being set. The options are explained in the following sections.

15.9.1 SET STRUCTURE: CURRENT

FORMAT:


        SET STRUCTURE struc_name: CURRENT str_expr 

EXAMPLE:

Example 15-44 SET STRUCTURE: CURRENT

  dim a$(100) 
  let i = 0 
  open structure cl: name 'sheerpower:samples\client' 
  extract structure 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 structure cl: current a$(i) 
    end if
  next cl 
  print
  for j = 1 to i 
    set structure 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 STRUCTURE: CURRENT is used to store a current record value into a string variable.

When SheerPower executes a SET STRUCTURE: CURRENT statement, it uses the structure name and sets the current record to the value specified by the string variable. The structure must be open and str_expr must contain a value stored with the ASK STRUCTURE: CURRENT statement.

If a null string is used for the value, SheerPower sets the structure to no current record and sets _EXTRACTED to zero.


        SET STRUCTURE struc_name: CURRENT '' 

15.9.2 SET STRUCTURE, FIELD: KEY

FORMAT:


        SET STRUCTURE struc_name, FIELD field_expr: KEY str_expr 

EXAMPLE:

Example 15-45 SET STRUCTURE, FIELD: KEY

  open structure cl: name 'sheerpower:samples\client' 
  line input 'Enter an ID': id$ 
  set structure 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