SheerPower® 4GL
A Guide to the SheerPower Language


Previous Contents Index

15.8.1.12 Item: NAME


        ASK STRUCTURE struc_name, FIELD field_expr: NAME str_var 

NAME returns the name of the specified field in a string variable.

15.8.1.13 Item: NULL


        ASK STRUCTURE struc_name, FIELD field_name: NULL int_var 

If the specified field is NULL (i.e. contains no data), this statement returns TRUE. If the field is not NULL, the statement returns FALSE.

15.8.1.14 Item: NUMBER


        ASK STRUCTURE struc_name, FIELD field_expr: NUMBER num_var 

NUMBER returns the field number of the specified field in a numeric variable. Fields are numbered sequentially. If the field does not exist, SheerPower returns a value of 0.

15.8.1.15 Item: OPTIMIZED


        ASK STRUCTURE struc_name, FIELD field_expr: OPTIMIZED num_var 

OPTIMIZED returns a value of TRUE or FALSE in a specified numeric variable. If the key field in field_expr is optimized, the value is TRUE. Otherwise, the value is FALSE.

Example 15-30 OPTIMIZED - field definition item

  open structure cl: name 'sheerpower:samples\client' 
  ask structure cl, field id: optimized z 
  print z 
  close structure cl 
  end
 
 
1 

15.8.1.16 Item: POSITION


        ASK STRUCTURE struc_name, FIELD field_expr: POSITION num_var 

POSITION returns the starting position for the specified field in a numeric variable.

15.8.1.17 Item: PRINTMASK


        ASK STRUCTURE struc_name, FIELD field_expr: PRINTMASK str_var 

PRINTMASK returns the print mask for the specified field in a string variable.

15.8.1.18 Item: PROMPT


        ASK STRUCTURE struc_name, FIELD field_expr: PROMPT str_var 

PROMPT returns the prompt for the specified field in a string variable.

15.8.1.19 Item: SCREENMASK


        ASK STRUCTURE struc_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.

15.8.1.20 Item: VRULES


        ASK STRUCTURE struc_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 structure cl : name 'sheerpower:samples\client' 
  ask structure cl, field bday: vrules str$ 
  print str$ 
  end
 
 
date ymd; minlength 8 

15.8.2 ASK STRUCTURE: CURRENT

FORMAT:


        ASK STRUCTURE struc_name: CURRENT str_var 

EXAMPLE:

Example 15-32 ASK 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:

ASK STRUCTURE: CURRENT assigns the current record value to the str_var. Once the current record has been assigned with ASK STRUCTURE: 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.

15.8.3 ASK STRUCTURE: DATAFILE

FORMAT:


        ASK STRUCTURE struc_name: DATAFILE str_var 

EXAMPLE:

Example 15-33 ASK STRUCTURE: DATAFILE

  open structure cust: name 'sheerpower:samples\customer' 
  open structure cl: name 'sheerpower:samples\client' 
  ask structure cust: datafile z1$ 
  ask structure cl: datafile z2$ 
  print z1$ 
  print z2$ 
  end
 
 
C:\SHEERPOWER\samples\CUSTOMER.ARS 
C:\SHEERPOWER\samples\CLIENT.ARS 

DESCRIPTION:

The ASK STRUCTURE: DATAFILE statement returns the full file name/file specification of a specified structure. struc_name is the specified structure name. str_var contains the returned file specification.

15.8.4 ASK STRUCTURE: FIELDS

FORMAT:


        ASK STRUCTURE struc_name: FIELDS num_var 

EXAMPLE:

Example 15-34 ASK STRUCTURE: FIELDS

  open structure cl: name 'sheerpower:samples\client', access input
  ask structure cl: fields z 
  print z 
  end
 
 
18 

DESCRIPTION:

The number of fields in a structure can be determined with the ASK STRUCTURE: FIELDS statement. The number is assigned to the numeric variable num_var.

15.8.5 ASK STRUCTURE: KEYS

FORMAT:


        ASK STRUCTURE struc_name: KEYS num_var 

EXAMPLE:

Example 15-35 ASK STRUCTURE: KEYS

  open structure cl: name 'sheerpower:samples\client', access input
  ask structure cl: keys z 
  print z 
  end
 
 
2 

DESCRIPTION:

The ASK STRUCTURE: KEYS statement returns the number of keys that are accessible by SheerPower. It returns the value of 0 if no keys are available.

15.8.6 ASK STRUCTURE: CAPABILITY

FORMAT:


        ASK STRUCTURE struc_name: CAPABILITY str_var 

EXAMPLE:

Example 15-36 ASK STRUCTURE: CAPABILITY

  open structure cl: name 'sheerpower:samples\client', access input
  ask structure cl: capability z$ 
  print z$ 
  end
 
 
INDEXED,INPUT 

DESCRIPTION:

Given a structure expression, ASK STRUCTURE: CAPABILITY sets str_expr to a comma delimited string containing one or more of the following: INDEXED, INPUT, OUTPUT

Table 15-1 Structure Types
Structure Type Description
INDEXED The structure is indexed; it can be accessed by key with statements such as SET STRUCTURE...KEY.
INPUT You can read from the structure.
OUTPUT You can write to the structure.
null string The structure is not currently open.


Previous Next Contents Index