SheerPower® 4GL
A Guide to the SheerPower Language


Previous Contents Index

DESCRIPTION:

REEXTRACT STRUCTURE can be used to do a second extract on a list of structure records you previously extracted. This allows for increasingly specific records to be chosen through a series of REEXTRACTs.

REEXTRACT does an extract on the list of records previously extracted. struc_name is the structure name associated with an open structure.

END EXTRACT marks the end of the REEXTRACT construct. REEXTRACT operates the same as EXTRACT. However, REEXTRACT operates on a previously extracted list.

Note on EXTRACT

Extract operations by key cannot be performed with REEXTRACT.

15.7.10 EXTRACT STRUCTURE: APPEND

FORMAT:


        EXTRACT STRUCTURE struc_name: APPEND 

EXAMPLE:

Example 15-22 APPEND option in EXTRACT STRUCTURE

  open structure detail: name 'sheerpower:samples\detail' 
  set structure detail: extracted 0 
  extract structure detail, field lineid : & 
      key '10301001' to '10302000', append
    sort by detail(prodnbr) 
    sort by detail(invnbr) 
  end extract
  extract structure detail, field lineid : & 
      key '10311001' to '10312000', append
    sort by detail(prodnbr) 
    sort by detail(invnbr) 
  end extract
  print 'Prod'; tab(7); 'Line ID'; tab(17); 'Quantity' 
  for each detail 
    print detail(prodnbr); tab(7); detail(lineid); & 
        tab(17); detail(qty) 
  next detail 
  end
 
 
Prod  Line ID   Qty 
22800 10301-002      2 
22800 10301-004      1 
22800 10301-006      2 
24100 10311-003      1 
24200 10301-003      1 
24200 10311-009      1 
28400 10311-001      2 
28800 10301-009      2 
28800 10311-002      9 
28800 10311-005      1 
28800 10311-006      1 
31020 10301-005      1 
31040 10311-010      2 
31150 10301-001      1 
31150 10301-008      8 
31150 10311-004      1 
31150 10311-008      1 
33090 10301-007      2 
33090 10311-007      1 

DESCRIPTION:

The EXTRACT STRUCTURE: APPEND statement adds records to the last collection of extracted records rather than creating a new collection.

15.8 ASK STRUCTURE

FORMAT:


        ASK STRUCTURE struc_name: struc_option [num_var | str_var] 

DESCRIPTION:

The ASK STRUCTURE statement is used to ask about various device and structure characteristics from within your programs. struc_name is the name of a structure whose characteristics are being asked about. struc_option can be any of the structure options available. The options are explained in the following sections.

15.8.1 ASK STRUCTURE FIELD: item

FORMAT:


        ASK STRUCTURE struc_name, FIELD field_expr: item var 

EXAMPLE:

Example 15-23 ASK STRUCTURE FIELD: item

  open structure cl: name 'sheerpower:samples\client' 
  ask structure cl: fields num_fields 
  for i = 1 to num_fields 
    clear
    ask structure cl, field #i: description b$ 
    ask structure cl, field #i: prompt a$ 
    ask structure cl, field #i: position a% 
    ask structure cl, field #i: length b% 
    ask structure cl, field #i: heading f$ 
    ask structure cl, field #i: printmask c$, & 
                                screenmask d$, & 
                                help e$ 
    print at 5,5: '' 
    print 'Description   : '; b$ 
    print 'Prompt        : '; a$ 
    print 'Position      : '; a% 
    print 'Field length  :' ; b% 
    print 'Rpt. heading  : '; f$ 
    print 'Print mask    : '; c$ 
    print 'Screen mask   : '; d$ 
    print 'Help          : '; e$ 
    delay
  next i 
  close structure cl 
  end
 
 
Description   : Client ID number 
Prompt        : Client ID number 
Position      :  1 
Field length  : 5 
Rpt. heading  : CLNT,ID 
Print mask    : >#### 
Screen mask   : digits:##### 
Help          : Client ID number 

DESCRIPTION:

The FIELD option allows you to get information about a specific field in a structure. struc_name is the name of the structure. field_expr is the field you are inquiring about. item specifies what type of information you are asking. The information is stored in the variable specified.

The following sections provide more information on what you can use for field_expr and on the various field items.

For more information:

The ITEM information is created when the SETUP routine is used to define the field. You can refer to Chapter 16, Database Setup for information on defining fields.

15.8.1.1 FIELD Expressions

The field_expr used in the ASK STRUCTURE FIELD: item statement can be either a constant or a string or numeric expression.

A string constant can be used to specify the field name. To use a string constant, just enter the field name, without quotes. SheerPower will then use the string constant as the field name:


        ASK STRUCTURE sheerpower:samples\CLIENT, FIELD LAST: DESCRIPTION A$ 
                                        / 
                  the field is specified by its field name 

You can also specify a field name with an expression. To use an expression, precede the expression with a pound sign (#). The pound sign tells SheerPower that the following characters are an expression, not the field name. If a pound sign is not included SheerPower will interpret the characters as a field name.


        ASK STRUCTURE CL, FIELD #FIELDNAME$: DESCRIPTION A$ 
                                    / 
          the field is specified by the value of the variable FIELDNAME$ 
 
 
        ASK STRUCTURE CL, FIELD #FIELDNUM: DESCRIPTION A$ 
                                    / 
          the field is specified by the value of the variable FIELDNUM 

EXAMPLE:

This example shows how to access the actual field data using field expressions.

Example 15-24 Field expressions in ASK STRUCTURE FIELD

  open structure cl: name 'sheerpower:samples\client' 
  do
  clear
  print at 1, 1:; 
    ask_fields 
    if  _back or _exit  then exit do
    show_data 
  loop
  close structure cl 
  stop
 
  routine ask_fields 
  do
    if  _error  then  set error off
    print 'Field List:  '; & 
        'ID, LAST, FIRST, MIDDLE, STREET, CITY, STATE, ZIP, PHONE' 
    print
    line input 'Select fields to display': field_list$ 
    if  _back or _exit  then exit do
    for f = 1 to elements(field_list$) 
      field$ = element$(field_list$, f) 
      ask structure cl, field #field$: number z 
      if  z = 0  then
        message error: 'Illegal field: '; field$ 
      end if
    next f 
  loop while _error
  end routine
 
  routine show_data 
  print
  extract structure cl 
    for f = 1 to elements(field_list$) 
      field$ = element$(field_list$, f) 
      print cl(#field$), 
    next f 
    print
  end extract
  delay
  end routine
  end
 
 
Field List:  ID, LAST, FIRST, MIDDLE, STREET, CITY, STATE, ZIP, PHONE 
 
Select fields to display? last,first,phone 
 
Smith               Sam                 (809) 555-8789 
Kent                Keith               (619) 967-5021 
Johnson             Paul                (619) 489-5551 
Waters              Wayne               (619) 564-1231 
Rodrigues           Homero              (   )    -   0 
Donaldson           George              (   )    -   0 
Errant              Earl                (408) 844-7676 
Abott               Al                  (202) 566-9892 
Brock               Bud                 (218) 555-4322 
Cass                Cathy               (619) 743-8582 
Porter              Pete                (619) 778-6709 
Derringer           Dale                (818) 223-9014 
Farmer              Fred                (305) 552-7872 

15.8.1.2 Item: ACCESS


        ASK STRUCTURE struc_name, FIELD field_name: ACCESS str_var 

ACCESS retrieves the access (read and write) rules for the specified field. This information tells if the field can be read and written to. N is normal--meaning the field can be read and written to if the structure is also "N"ormal. Depending on whether security levels have been set on the structure and/or field, the letter can be in the range of A thru Z. SheerPower defaults to N when the structure is created and fields are defined.

Example 15-25 ACCESS - field definition item

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


Previous Next Contents Index