Harbour All Functions – E

ELAPTIME()
EMPTY()
EOF()

EOM
EOQ
EOY

ERRORSYS()
EVAL()
EXP()

Exponent 

Advertisements

FieldWBlock()

FIELDWBLOCK()

Return a sets/gets code block for field in a given work area

Syntax

      FIELDWBLOCK( <cFieldName>, <nWorkArea> ) --> bFieldBlock

Arguments

<cFieldName> is a string that contain the field name.

<nWorkArea> is the work area number in which <cFieldName> exist.

Returns

FIELDWBLOCK() return a code block that when evaluate could retrieve field value or assigning a new value for a field in a given work area. If <cFieldName> is not specified or from type other than character, or if <nWorkArea> is not specified or is not numeric FIELDWBLOCK() return NIL.

Description

FIELDWBLOCK() return a code block that sets/gets the value of field from a given work area. When this code block is evaluated without any parameters passed then it returns the current value of the given field. If the code block is evaluated with a parameter, than its value is used to set a new value to the field, this value is also return by the block. If the block is evaluate and there is no field with the name <cFieldName> in work area number <nWorkArea>, the code block return NIL.

Examples

      LOCAL bField
      // this block work on the field "name" that exist on work area 2
      bFiled := FIELDBLOCK( "name", 2 )
      // open a file named One in work area 1
      // that have a field named "name"
      SELECT 1
      USE one
      // open a file named Two in work area 2
      // it also have a field named "name"
      SELECT 2
      USE two
      SELECT 1
      ? "Original names: ", One->name, Two->name
      ? "Name value for file Two :", EVAL( bField )
      EVAL( bField, "Two has new name" )
      ? "and now: ", One->name, Two->name

Compliance

If the block is evaluate and there is no field with the name <cFieldName> in the given work area, the code block return NIL.

CA-Cl*pper would raise BASE/1003 error if the field does not exist.

Files

Library is rtl

Seealso

EVAL(), FIELDBLOCK(), MEMVARBLOCK()

FieldBlock()

FIELDBLOCK()

Return a code block that sets/gets a value for a given field

Syntax

      FIELDBLOCK( <cFieldName> ) --> bFieldBlock

Arguments

<cFieldName> is a string that contain the field name.

Returns

FIELDBLOCK() return a code block that when evaluate could retrieve a field value or assigning a new value to the field. If <cFieldName> is not specified or from type other than character, FIELDBLOCK() return NIL.

Description

FIELDBLOCK() return a code block that sets/gets the value of field. When this code block is evaluated without any parameters passed then it returns the current value of the given field. If the code block is evaluated with a parameter, than its value is used to set a new value to the field, this value is also return by the block. If the block is evaluate and there is no field with the name <cFieldName> in the current work area, the code block return NIL.

Note that FIELDBLOCK() works on the current work area, if you need a specific work area code block use FIELDWBLOCK() instead.

Examples

      // open a file named Test that have a field named "name"
      LOCAL bField
      bFiled := FIELDBLOCK( "name" )
      USE Test
      ? "Original value of field 'name' :", EVAL( bField )
      EVAL( bField, "Mr X new name" )
      ? "New value for the field 'name' :", EVAL( bField )

Compliance

If the block is evaluate and there is no field with the name <cFieldName> in the current work area, the code block return NIL.

CA-Cl*pper would raise BASE/1003 error if the field does not exist.

Files

Library is rtl

Seealso

EVAL(), FIELDWBLOCK(), MEMVARBLOCK()

dbEval()

DBEVAL()

Performs a code block operation on the current Database

Syntax

      DBEVAL( <bBlock>,
      [<bFor>], [<bWhile>],
      [<nNext>], [<nRecord>],
      [<lRest>] ) --> NIL

Arguments

<bBlock> Operation that is to be performed

<bFor> Code block for the For condition

<bWhile> Code block for the WHILE condition

<nNext> Number of NEXT records to process

<nRecord> Record number to work on exactly

<lRest> Toggle to rewind record pointer

Returns

DBEVAL() always returns NIL

Description

Performs a code block operation on the current Database

Examples

      PROCEDURE Main()
         LOCAL nCount

         USE test

         dbGoto( 4 )
         ? RecNo()
         COUNT TO nCount
         ? RecNo(), nCount
         COUNT TO nCount NEXT 10
         ? RecNo(), nCount

         RETURN

Compliance

Clipper

Files

Library is rdd

Seealso

EVAL()

Eval()

EVAL()

Evaluate a code block

Syntax

      EVAL( <bBlock> [, <xVal> [,...]])  --> xExpression

Arguments

<bBlock> Code block expression to be evaluated

<xVal> Argument to be passed to the code block expression

<xVal…> Argument list to be passed to the code block expression

Returns

<xExpression> The result of the evaluated code block

Description

This function evaluates the code bloc expressed as <bBlock> and returns its evaluated value. If their are multiple expressions within the code block, the last expression will be value of this function.

If the code block requires parameters to be passed to it, they are specified in the parameter list <xVal> and following. Each parameter is separated by a comma within the expression list.

Examples

      PROCEDURE Main()
         LOCAL bBlock := {|| NIL }
         ? Eval( 1 )
         ? Eval( @bBlock )

         ? Eval( {| p1 | p1 }, "A", "B" )
         ? Eval( {| p1, p2 | p1 + p2 }, "A", "B" )
         ? Eval( {| p1, p2, p3 | p1 }, "A", "B" )
         RETURN

Tests

      See examples

Compliance

Clipper

Platforms

All

Files

Library is vm

Seealso

AEVAL(), DBEVAL()

ASort()

 

ASORT()

Sort an array

Syntax

      ASORT( <aArray>, [<nStart>], [<nCount>], [<bSort>] ) --> aArray

Arguments

<aArray> Array to be sorted.

<nStart> The first element to start the sort from, default is 1.

<nCount> Number of elements starting from <nStart> to sort, default is all elements.

<bSort> Code block for sorting order, default is ascending order {| x, y | x < y }. The code block should accept two parameters and must return .T. if the sort is in order, .F. if not.

Returns

<aArray> reference to the now sorted <aArray> or NIL if the passed <aArray> is not an array.

Description

ASORT() sort all or part of a given array. If <bSort> is omitted, the function expect <aArray> to be one dimensional array containing single data type (one of: Character, Date, Logical, Numeric) and sort this array in ascending order: Character are sorted by their ASCII value, Dates are sorted chronologically, Logical put .F. values before .T., Numeric are sorted by their value.

If <bSort> is specified, it is used to handle the sorting order. With each time the block is evaluate, two array elements are passed to the code block, and <bSort> must return a logical value that state if those elements are in order (.T.) or not (.F.). Using this block you can sort multidimensional array, descending orders or even (but why would you want to do that) sort array that contain different data type.

Examples

      // sort numeric values in ascending order
      ASort( { 3, 1, 4, 42, 5, 9 } )     // result: { 1, 3, 4, 5, 9, 42 }

      // sort character strings in descending lexical order
      aKeys := { "Ctrl", "Alt", "Delete" }
      bSort := {| x, y | Upper( x ) > Upper( y ) }
      ASort( aKeys,,, bSort )      // result: { "Delete", "Ctrl", "Alt" }

      // sort two-dimensional array according to 2nd element of each pair
      aPair := { { "Sun", 8 }, { "Mon", 1 }, { "Tue", 57 }, { "Wed", -6 } }
      ASort( aPair,,, {| x, y | x[ 2 ] < y[ 2 ] } )
      // result: { { "Wed", -6 }, { "Mon", 1 }, { "Sun", 8 }, { "Tue", 57 } }

Compliance

Clipper (arrayblock)

Files

Library is vm

Seealso

ASCAN(), EVAL(), SORT