Sheerpower Logo
I.2  Build Generalized Database Utilities
Sheerpower gives programmers full access to database table metadata. This allows for the easy development of generalized utilities.

Sheerpower ASK TABLE Statement

The ASK TABLE statement is used to query various characteristics of a table, such as field descriptions, prompts, positions, lengths, headings, print masks, screen masks, and help messages. This allows for dynamic inspection of table structures within a program.

Example

open table cl: name 'sheerpower:samples\client'
ask table cl: fields num_fields

for i = 1 to num_fields
  clear
  ask table cl, field #i: description b$
  ask table cl, field #i: prompt a$
  ask table cl, field #i: position a%
  ask table cl, field #i: length b%
  ask table cl, field #i: heading f$
  ask table 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 table cl
end

Explanation

The example opens a table named 'client' and queries various field characteristics using the ASK TABLE statement.

  • open table: Opens the specified table.
  • ask table cl: fields num_fields: Retrieves the number of fields in the table.
  • ask table cl, field #i: Retrieves various characteristics of each field.
  • description b$: Retrieves the description of the field.
  • prompt a$: Retrieves the prompt associated with the field.
  • position a%: Retrieves the position of the field.
  • length b%: Retrieves the length of the field.
  • heading f$: Retrieves the report heading of the field.
  • printmask c$: Retrieves the print mask of the field.
  • screenmask d$: Retrieves the screen mask of the field.
  • help e$: Retrieves the help message for the field.

Hide Description

    

       


      

Enter or modify the code below, and then click on RUN

Looking for the full power of Sheerpower?
Check out the Sheerpower website. Free to download. Free to use.
Wide screen