SP_QUERY

QUERY()

  Short:
  ------
  QUERY() Popup Interactive query by example condition
  builder

  Returns:
  --------
  <cQuery> => macro expandable logical condition
  expression

  Syntax:
  -------
  QUERY([aFields,aDesc,aTypes],[cQuitTo],[lUseBuildex])

  Description:
  ------------
  A point and shoot condition builder. Complex
  conditions are allowed with multiple .and./.or. Called without
  parameters, all fields in the current dbf are presented for condition
  building.

  [aFields,aDesc,aTypes] give field array, field
  description and field types.These, if passed will be used in
  place of the default of all dbf fields. (pass all or none)

  [cQuitTo] is a 'quit to' phrase. Default exit option
  is 'Quit'. 'Quit to' phrase will be tacked to the end of this .
  i.e. "Quit"+quit_to  [ Quit to Report Writer ]

  [lUseBuildex] determines whether BUILDEX() expression
  builder will be available from QUERY(). Default is not.

  Examples:
  ---------
   USE CUSTOMER

   aFields := {"fname", "lname",  "mi" }
   aFdesc  := {"First", "Last",  "Middle" }
   aTypes  := {"C","C","C"}
   cFilt   := QUERY(aFields,aFdesc,aTypes,nil,.t.)

   count for &cFilt  to nCount

   // or (preferably)
   count for eval( sls_bquery() ) to nCount

  Notes:
  -------
  Query always stores the current query with the
  function SLS_QUERY(). Calling SLS_QUERY() will return the
  currently stored query string. SLS_BQUERY() returns the query as
  a codeblock. Remember to clear sls_query()/sls_bquery() when
  changing DBFs.

  Source:
  -------
  S_QUERY.PRG

See also : SLS_BQUERY(), SLS_QUERY()

 

 

SP_GENVAL

GENVAL()

  Short:
  ------
  GENVAL() Generic VALID clause validation with message

  Returns:
  --------
  <lValid> => logical result of passed condition

  Syntax:
  -------
  GENVAL(expValid,expMessage)

  Description:
  ------------
  Evaluates <expValid>, which is either a bode block or
  a string to be macro expanded, as a logical value. If result is
  False, displays message <expMessage> and waits for a keypress.
  <expMessage> can be a single string, or an array of strings (see
  aMsg() ).

  Examples:
  ---------
   if genval("fcount() < 60",'Too many fields')
       COPY TO TEMP
   endif

   * ...or as a VALID CLAUSE macro'd

   @10,10 get lname VALID ;
     GENVAL("!empty(lname)","Need a last name")

   * ...or as a VALID CLAUSE eval'd

   @10,10 get fname VALID ;
     GENVAL( { || !empty(fname) },"Need a last name")

  Source:
  -------
  S_GENVA.PRG

 

SP_AVARIANCE

AVARIANCE()

  Short:
  ------
  AVARIANCE() Determines the variance of an array with condition

  Returns:
  --------
  <nVariance> => Array variance

  Syntax:
  -------
  AVARIANCE(aTarget,[bCondition])

  Description:
  ------------
  <aTarget> is the target array. Normally an array of
  numeric values. [bCondition] is an optional codeblock used to
  select a subset of the array. This could be used to filter out
  0's or non-numeric elements. The block must accept an array
  element as a parameter, and return true or false <expL> to
  determine if this element is part of the desired subset.

  Examples:
  ---------
   v := AVARIANCE(aSales)
   v := AVARIANCE(aSales,{|e|valtype(e)=="N".and.e<>0})

  Source:
  -------
  S_ASTATS.PRG

 

Command Terms

Clause :

An optional or required section of a Clipper language command beginning with a keyword that modifies or enhances the command.

Command :

A statement to be translated by the Clipper preprocessor into source code that will perform a particular operation. All Clipper language commands are defined in the standard header file, STD.CH, located in …INCLUDE. Also, the preprocessor directives that define a command.

See Also: Header File, Statement, STD.CH

Condition :

A logical expression that determines whether an operation will take place. With database commands, a logical expression that determines what records are included in an operation. Conditions are specified as arguments of the FOR or WHILE clause.

Keyword :

A word that has a special meaning to a compiler or other utility program. Commands, directives, or options are often recognized by examining supplied text to see if it contains keywords.

List :

A list of expressions, field names, or filenames, separated by commas specified generally as command, procedure, or function arguments. Code blocks can also execute a list of expressions.

Optional Clause :

A portion of a match pattern that is enclosed in square ([ ]) brackets. An optional clause specifies part of a match pattern that need not be present for source text to match the pattern. An optional clause may contain any of the components legal within a match pattern, including other optional clauses. When a match pattern contains a series of optional clauses that are immediately adjacent to each other, the matching portions of the source text are not required to appear in the same order as the clauses in the match pattern. If an optional clause is matched by more than one part of the source text, the multiple matches may be handled using a repeating clause in the result pattern.

Scope :

In a database command, a clause that specifies a range of database records to be addressed by the command. The scope clause uses the qualifiers ALL, NEXT, RECORD, and REST to define the record scope.

See Also: Condition

Skeleton :

A wildcard mask used to specify a group of filenames or memory variables. The * is used to specify one or more characters and the ? to specify a single character.

Toggle :

As a verb, to choose between an on or off state. As a noun, a value or setting that can be either on or off. A toggle is often represented using a logical value, with true (.T.) representing on, and false (.F.) representing off.

Verb :

The first word of a command that describes the action to perform.

See Also: Command

Database Terms

Alias :

The name of a work area; an alternate name given to a database file. Aliases are often used to give database files descriptive names and are assigned when the database file is opened. If no alias is specified when the database file is USEd, the name of the database file becomes the alias.

An alias can be used to reference both fields and expressions (including user-defined functions). In order to alias an expression, the expression must be enclosed in parentheses.

See also : Work Area

Attribute :

As a formal DBMS term, refers to a column or field in a table or database file.

See Also: Column, Field

Beginning of File :

The top of the database file. In Clipper language there is no beginning of file area or record. Instead, it is indicated by BOF() returning true (.T.) if an attempt is made to move the record pointer above the first record in the database file or the database file is empty.

Cell :

In a table, a cell is the intersection of a Row and a Column.

Column :

A database term used to describe a field in a table or database file.

See Also: Field

Concurrency :

The degree to which data can be accessed by more than one user at the same time.

Condition :

A logical expression that determines whether an operation will take place. With database commands, a logical expression that determines what records are included in an operation. Conditions are specified as arguments of the FOR or WHILE clause.

See Also: Scope

Controlling/Master Index :

The index currently being used to refer to records by key value or sequential record movement commands.

See Also: Index, Natural Order

Database :

An aggregation of related operational data used by an application system. A database can contain one or more data files or tables.

See Also: Field, Record, Tuple, View

DBMS :

An acronym for the term database management system. A DBMS is a software system that mediates access to a database through a data manipulation language.

Delimited File :

A text file that contains variable-length database records with each record separated by a carriage return/linefeed pair (CHR(13) + CHR(10)) and terminated with an end of file mark (CHR(26)). Each field within a delimited file is variable length, not padded with either leading or trailing spaces, and separated by a comma. Character strings are optionally delimited to allow for embedded commas.

End of File :

The bottom of a database file. In Clipper language, this is LASTREC() + 1 and is indicated by EOF() returning true (.T.).

Field :

The basic column unit of a database file. A field has four attributes: name, type, length, and decimals if the type is numeric.

See Also: Database, Record, Tuple, Vector, View

Field Variable :

A variable that refers to data in a database field, as opposed to data in memory.

See Also: Local Variable, Memory Variable, Variable

Index :

An ordered set of key values that provides a logical ordering of the records in an associated database file. Each key in an index is associated with a particular record in the database file. The records can be processed sequentially in key order, and any record can be located by performing a SEEK operation with the associated key value.

See Also: Controlling/Master Index, Key Value, Natural Order

Join :

An operation that takes two tables as operands and produces one table as a result. It is, in fact, a combination of other operations including selection and projection.

See Also: Projection, Selection

Key Expression :

An expression, typically based on one or more database fields, that when evaluated, yields a key value for a database record. Key expressions are most often used to create indexes or for summarization operations.

See Also: Index, Key Value

Key Value :

The value produced by evaluating a key expression. When placed in an index, a key value identifies the logical position of the associated record in its database file.

See Also: Index, Key Expression

Master Index :

The index currently being used to refer to records by key value or sequential record movement commands.

See Also : Controlling/Master Index

Memo Type :

A special database field type consisting of one or more characters in the extended character set. The maximum size of a memo field In Clipper language is 65,534 bytes. A memo field differs only from a character string by the fact it is stored in a separate memo (.DBT file) and the field length is variable-length.

See Also: Character String

Natural Order :

For a database file, the order determined by the sequence in which records were originally entered into the file. Also called unindexed order.

See Also: Index

Normalization :

The process of elimination and consolidation of redundant data elements in a database system.

Projection :

A DBMS term specifying a subset of fields. In Clipper, the analogy is the FIELDS clause.

See Also: Join Selection

Query :

A request for information to be retrieved from a database. Alternately, a data structure in which such a request is encoded.

Record :

The basic row unit of a database file consisting of one or more field elements.

See Also: Database, Field, Table, Tuple

Relation :

A link between database files that allows the record pointer to move in more than one database file based on the value of a common field or expression. This allows information to be accessed from more than one database file at a time.

Relational Database System :

A system that stores data in rows and columns, without system dependencies within the data. In other words, relationships between different databases are not stored in the actual database itself, as is the case in a system that uses record pointers.

Row :

A group of related column or field values that are treated as a single entity. It is the same as a Clipper language record.

See Also: Column, Field, Record

Search Condition :

See : Condition, Scope

Scope :

In a database command, a clause that specifies a range of database records to be addressed by the command. The scope clause uses the qualifiers ALL, NEXT, RECORD, and REST to define the record scope.

See Also: Condition

SDF File :

A text file that contains fixed-length database records with each record separated by a carriage return/linefeed pair (CHR(13) + CHR(10)) and terminated with an end of file mark (CHR(26)). Each field within an SDF file is fixed-length with character strings padded with trailing spaces and numeric values padded with leading spaces. There are no field separators.

See Also: Database, Delimited File, Text File

Selection :

A DBMS term that specifies a subset of records meeting a condition. The selection itself is obtained with a selection operator. In Clipper language, the analogy is the FOR clause.

Separator :

The character or set of characters that differentiate fields or records from one another. In Clipper language, the DELIMITED and SDF file types have separators. The DELIMITED file uses a comma as the field separator and a carriage return/linefeed pair as the record separator. The SDF file type has no field separator, but also uses a carriage return/linefeed pair as the record separator.

See Also: Delimiter

Sort Order :

Describes the various ways database files and arrays are ordered.

. Ascending

Causes the order of data in a sort to be from lowest value to highest value.

. Descending

Causes the order of data in a sort to be from highest value to lowest value.

. Chronological

Causes data in a sort to be ordered based on a date value, from earliest to most recent.

. ASCII

Causes data in a sort to be ordered according to the ASCII Code values of the data to be sorted.

. Dictionary

The data in a sort is ordered in the way it would appear if the items sorted were entries in a dictionary of the English language.

. Collating Sequence

Data in a sort will be placed in sequence following the order of characters in the Extended Character Set.

. Natural

The order in which data was entered into the database.

Table :

A DBMS term defining a collection of column definitions and row values. In Clipper, it is represented and referred to as a database file.

Tuple :

A formal DBMS term that refers to a row in a table or a record in a database file. In DIF files, tuple also refers to the equivalent of a table record.

See Also: Database, Field, Record

Update :

The process of changing the value of fields in one or more records. Database fields are updated by various commands and the assignment operator.

Vector :

In a DIF file, vector refers to the equivalent of a table field.

See Also: Database, Field, Record, Tuple

View :

A DBMS term that defines a virtual table. A virtual table does not actually exist but is derived from existing tables and maintained as a definition. The definition in turn is maintained in a separate file or as an entry in a system dictionary file. In Clipper, views are supported only by DBU.EXE and are maintained in (.vew) files.

See Also: Database, Field, Record

Work Area :

The basic containment area of a database file and its associated indexes. Work areas can be referred to by alias name, number, or a letter designator.

See Also: Alias

Expression Terms

Assignment :

The act of copying a new value into a variable. In Clipper language this is done with the simple assignment operators (=) and (:=), or the compound operators (+=, -=, *=, **=).

Binary Operator :

An operator that operates on two operands. For example, the addition operator.

See Also: Operator

Character Functions :

Those functions that act upon individual characters or strings of ASCII characters in the performance of their tasks.

See Also: ASCII, Function, String

Concatenate :

To combine two groups of character data together by placing them in a sequence to form a new string of characters.

See Also: Data Type

Condition :

A logical expression that determines whether an operation will take place. With database commands, a logical expression that determines what records are included in an operation. Conditions are specified as arguments of the FOR or WHILE clause.

Conversion Functions :

Generally referring to a category of functions whose purpose is to change one data type to another (e.g., to change a number or a date to a character string).

Date Functions :

Functions that operate on date values (as opposed to character, numeric or other values).

See Also: Function

Decrement :

To decrease a value by a fixed amount, usually one. In Clipper, the decrement operator (–) can be used to decrement a numeric value in a variable.

See Also: Assignment Increment

Destination :

The variable or array element to receive data in an assignment.

See Also: Assignment

Evaluate :

To execute part of a program in order to produce a value. For an expression, to execute the program code associated with the expression and return the resulting value. For the macro operator, to compile the macro string, execute the resulting program code, and return the resulting value.

See also : Expression

Expression :

A combination of constants, identifiers, operators, and functions that yield a single value when evaluated.

Increment :

To increase a value by a fixed amount, usually one. In Clipper language the increment operator (++) can be used to increment a numeric value in a variable.

List :

A list of expressions, field names, or filenames, separated by commas specified generally as command, procedure, or function arguments. Code blocks can also execute a list of expressions.

Macro :

In Clipper language, an operation that allows source code to be compiled and executed at runtime. In Clipper language, the macro symbol (&) does not perform text substitution unless embedded within a character string. Instead, it is generally treated as a unary operator that operates on a character string. The text in the character string is compiled on the fly using a special runtime compiler. The resulting code is then executed, and the value obtained is returned as the result of the macro operation.

See Also: Code Block, Unary Operator

Operand :

A value that is operated on by an operator, or the term in an expression that specifies such a value. For example, in the expression x + 5, x and 5 are operands.

See Also: Operator

Operator :

A symbol that identifies a basic operation. For example, the multiplication operator (*) denotes that two values are to be multiplied. Operators are categorized as either unary or binary, depending on whether they require one or two operands, respectively.

See Also: Binary Operator, Operand, Unary Operator

Precedence :

The stature of an operator in the hierarchy that determines the order in which expressions are evaluated. For example, the expression 5 + 2 * 3 is interpreted as 5 + (2 * 3) because the multiply operator (*) has a higher precedence than the addition operator (+).

See Also: Expression

Recursion :

The calling of a procedure by a statement in that same procedure. When a procedure calls itself it is said to recurse. A recursive call causes a new activation of the procedure. If the source code for the procedure includes a declaration of local variables, a new set of local variables is created for each activation. A private variable created by the procedure is associated with the activation in which it is created, and is visible in that activation and any lower-level activations, unless obscured by a private variable created in a lower-level activation.

See Also: Activation, Function, Private Variable, Procedure

Shortcutting :

A compiler optimization that causes expressions to be evaluated only to the extent required to determine their outcome. For example, in the expression f() .OR. g() function g need not be executed if function f returns true (.T.). Clipper language performs shortcutting on all logical operators (.OR. .AND. .NOT.).

Truncate :

To remove insignificant information from the end of an item of data. With numerics, to ignore any part of the number that falls outside of the specified precision.

Unary Operator :

An operator that operates on a single operand. For example, the .NOT. operator.

See Also: Binary Operator, Operator