C5_BIN2W

 BIN2W()
 Convert a 16-bit unsigned integer to a numeric value
------------------------------------------------------------------------------
 Syntax

     BIN2W(<cUnsignedInt>) --> nNumber

 Arguments

     <cUnsignedInt> is a character string in the form of a 16-bit
     unsigned integer number--least significant byte first.  Only the first
     two characters are used by the function; all others are ignored.

 Returns

     BIN2W() returns an integer numeric value.

 Description

     BIN2W() is a low-level file function that is used with FREAD() to
     convert a two-byte character string formatted as an unsigned integer to
     a Clipper numeric data type.  This is most useful when you are
     reading from a binary file and want to read data in its native format.

 Examples

     .  This example opens a database file using low-level file
        functions and reads the number of bytes per record (bytes 10-11).
        The result is the same as with RECSIZE():

        #include "Fileio.ch"
        //
        nHandle := FOPEN("Sales.dbf", FO_READ)
        // Note:  The length of a record in Sales.dbf is 124
        //
        // Point to byte 10, the first record size byte
        FSEEK(nHandle, 10, FS_SET)
        //
        // Read record size
        cRecSize := SPACE(2)
        FREAD(nHandle, @cRecSize, 2)
        //
        ? LTRIM(STR(BIN2W(cRecSize)))            // Result: 124
        FCLOSE(nHandle)

 Files   Library is EXTEND.LIB, source file is SOURCE\SAMPLE\EXAMPLEA.ASM

See Also: BIN2I() BIN2L() FREAD() FREADSTR() I2BIN() L2BIN()

 

C5_BIN2L

 BIN2L()
 Convert a 32-bit signed integer to a numeric value
------------------------------------------------------------------------------
 Syntax

     BIN2L(<cSignedInt>) --> nNumber

 Arguments

     <cSignedInt> is a character string in the form of a 32-bit signed
     integer number--least significant byte first.  Only the first four
     characters are used by the function; all others are ignored.

 Returns

     BIN2L() returns an integer numeric value.

 Description

     BIN2L() is a low-level file function that is used with FREAD() to
     convert a four-byte character string formatted as a signed integer to a
     Clipper numeric data type.  This is most useful when you are reading
     foreign file types and want to read numeric data in its native format.

 Examples

     .  This example opens a database file using low-level file
        functions and reads the number of records (bytes 4-7).  The result is
        the same as with LASTREC():

        #include "Fileio.ch"
        //
        nHandle := FOPEN("Sales.dbf", FO_READ)
        // Note:  Sales.dbf contains 84 records
        //
        // Point to byte 4
        FSEEK(nHandle, 4, FS_SET)
        //
        // Read the number of records
        cRecords := SPACE(4)
        FREAD(nHandle, @cRecords, 4)
        //
        ? LTRIM(STR(BIN2L(cRecords)))         // Result: 84
        FCLOSE(nHandle)

 Files   Library is EXTEND.LIB, source file is SOURCE\SAMPLE\EXAMPLEA.ASM

See Also: BIN2I() BIN2W() FREAD() FREADSTR() I2BIN() L2BIN()

 

C5_BIN2I

 BIN2I()
 Convert a 16-bit signed integer to a numeric value
------------------------------------------------------------------------------
 Syntax

     BIN2I(<cSignedInt>) --> nNumber

 Arguments

     <cSignedInt> is a character string in the form of a 16-bit signed
     integer number--least significant byte first.  Only the first two
     characters are used by the function; all others are ignored.

 Returns

     BIN2I() returns an integer numeric value.

 Description

     BIN2I() is a low-level file function that is used with FREAD() to
     convert a two-byte character string formatted as a signed integer to a
     Clipper numeric data type.  This is most useful when you are reading
     foreign file types and want to read numeric data in its native format.

 Examples

     .  This example opens a database file using low-level file
        functions and reads the date of last update (bytes 1-3).  The result
        is the same as with LUPDATE():

        #include "Fileio.ch"
        //
        nHandle := FOPEN("Sales.dbf", FO_READ)
        //
        // Point to byte 1 in the file
        FSEEK(nHandle, 1, FS_SET)
        //
        // Read date of last update
        nYear := BIN2I(FREADSTR(nHandle, 1) + CHR(0))
        nMonth := BIN2I(FREADSTR(nHandle, 1) + CHR(0))
        nDay := BIN2I(FREADSTR(nHandle, 1) + CHR(0))
        //
        ? LTRIM(STR(nMonth)), LTRIM(STR(nDay)), LTRIM(STR(nYear))
        FCLOSE(nHandle)

 Files   Library is EXTEND.LIB, source file is SOURCE\SAMPLE\EXAMPLEA.ASM

See Also: BIN2L() BIN2W() FREAD() FREADSTR() I2BIN() L2BIN()

 

C5_Functions

 AADD()          Add a new element to the end of an array
 ABS()           Return the absolute value of a numeric expression
 ACHOICE()       Execute a pop-up menu
 ACLONE()        Duplicate a nested or multidimensional array
 ACOPY()         Copy elements from one array to another
 ADEL()          Delete an array element
 ADIR()*         Fill a series of arrays with directory information
 AEVAL()         Execute a code block for each element in an array
 AFIELDS()*      Fill arrays with the structure of the current database file
 AFILL()         Fill an array with a specified value
 AINS()          Insert a NIL element into an array
 ALERT()         Display a simple modal dialog box
 ALIAS()         Return a specified work area alias
 ALLTRIM()       Remove leading and trailing spaces from a character string
 ALTD()          Invoke the CA-Clipper debugger
 ARRAY()         Create an uninitialized array of specified length
 ASC()           Convert a character to its ASCII value
 ASCAN()         Scan an array for a value or until a block returns true (.T.)
 ASIZE()         Grow or shrink an array
 ASORT()         Sort an array
 AT()            Return the position of a substring within a character string
 ATAIL()         Return the highest numbered element of an array
 BIN2I()         Convert a 16-bit signed integer to a numeric value
 BIN2L()         Convert a 32-bit signed integer to a numeric value
 BIN2W()         Convert a 16-bit unsigned integer to a numeric value
 BOF()           Determine when beginning of file is encountered
 BREAK()         Branch out of a BEGIN SEQUENCE...END construct
 BROWSE()*       Browse records within a window
 CDOW()          Convert a date value to a character day of the week
 CHR()           Convert an ASCII code to a character value
 CMONTH()        Convert a date to a character month name
 COL()           Return the screen cursor column position
 COLORSELECT()   Activate attribute in current color settings
 CTOD()          Convert a date string to a date value
 CURDIR()        Return the current DOS directory
 DATE()          Return the system date as a date value
 DAY()           Return the day of the month as a numeric value
 DBAPPEND()      Append a new record to the database in the current work area
 DBCLEARFIL()    Clear a filter condition
 DBCLEARIND()    Close all indexes for the current work area
 DBCLEARREL()    Clear active relations
 DBCLOSEALL()    Close all occupied work areas
 DBCLOSEAREA()   Close a work area
 DBCOMMIT()      Flush pending updates
 DBCOMMITALL()   Flush pending updates in all work areas
 DBCREATE()      Create a database file from a database structure array
 DBCREATEIND()   Create an index file
 DBDELETE()      Mark a record for deletion
 DBEDIT()        Browse records in a table layout
 DBEVAL()        Evaluate code block for each record matching scope/condition
 DBF()*          Return current alias name
 DBFIELDINFO()   Return and optionally change information about a field
 DBFILEGET()     Insert the contents of a field into a file
 DBFILEPUT()     Insert the contents of a file into a field
 DBFILTER()      Return the current filter expression as a character string
 DBGOBOTTOM()    Move to the last logical record
 DBGOTO()        Position record pointer to a specific identity
 DBGOTOP()       Move to the first logical record
 DBINFO()        Return and optionally change database file information
 DBORDERINFO()   Return and optionally change order and index file information
 DBRECALL()      Reinstate a record marked for deletion
 DBRECORDINFO()  Return and optionally change information about a record
 DBREINDEX()     Recreate all active indexes for the current work area
 DBRELATION()    Return the linking expression of a specified relation
 DBRLOCK()       Lock the record at the current or specified identity
 DBRLOCKLIST()   Return an array of the current lock list
 DBRSELECT()     Return the target work area number of a relation
 DBRUNLOCK()     Release all or specified record locks
 DBSEEK()        Move to the record having the specified key value
 DBSELECTAR()    Change the current work area
 DBSETDRIVER()   Return the database driver and optionally set a new driver
 DBSETFILTER()   Set a filter condition
 DBSETINDEX()    Empty orders from an order bag into the order list
 DBSETORDER()    Set the controlling order
 DBSETRELAT()    Relate two work areas
 DBSKIP()        Move relative to the current record
 DBSTRUCT()      Create an array containing the structure of a database file
 DBUNLOCK()      Release all locks for the current work area
 DBUNLOCKALL()   Release all locks for all work areas
 DBUSEAREA()     Use a database file in a work area
 DELETED()       Return the deleted status of the current record
 DESCEND()       Create a descending index key value
 DEVOUT()        Write a value to the current device
 DEVOUTPICT()    Write a value to the current device using a picture clause
 DEVPOS()        Move the cursor or printhead to a new position
 DIRCHANGE()     Change the current DOS directory
 DIRECTORY()     Create an array of directory and file information
 DIRMAKE()       Create a directory
 DIRREMOVE()     Remove a directory
 DISKCHANGE()    Change the current DOS disk drive
 DISKNAME()      Return the current DOS drive
 DISKSPACE()     Return the space available on a specified disk
 DISPBEGIN()     Begin buffering screen output
 DISPBOX()       Display a box on the screen
 DISPCOUNT()     Return the number of pending DISPEND() requests
 DISPEND()       Display buffered screen updates
 DISPOUT()       Write a value to the display
 DOSERROR()      Return the last DOS error number
 DOW()           Convert a date value to a numeric day of the week
 DTOC()          Convert a date value to a character string
 DTOS()          Convert a date value to a string formatted as yyyymmdd
 EMPTY()         Determine if the result of an expression is empty
 EOF()           Determine when end of file is encountered
 ERRORBLOCK()    Post a code block to execute when a runtime error occurs
 ERRORLEVEL()    Set the CA-Clipper return code
 EVAL()          Evaluate a code block
 EXP()           Calculate e**x
 FCLOSE()        Close an open binary file and write DOS buffers to disk
 FCOUNT()        Return the number of fields in the current .dbf file
 FCREATE()       Create and/or truncate a binary file to zero-length
 FERASE()        Delete a file from disk
 FERROR()        Test for errors after a binary file operation
 FIELD()         Return a field name from the current database (.dbf) file
 FIELDBLOCK()    Return a set-get code block for a given field
 FIELDGET()      Retrieve the value of a field using the field position
 FIELDNAME()     Return a field name from the current database (.dbf) file
 FIELDPOS()      Return the position of a field in a work area
 FIELDPUT()      Set the value of a field variable using the field position
 FIELDWBLOCK()   Return a set-get code block for a field in a given work area
 FILE()          Determine if files exist in the default directory or path
 FKLABEL()*      Return function key name
 FKMAX()*        Return number of function keys as a constant
 FLOCK()         Lock an open and shared database file
 FOPEN()         Open a binary file
 FOUND()         Determine if the previous search operation succeeded
 FREAD()         Read characters from a binary file into a buffer variable
 FREADSTR()      Read characters from a binary file
 FRENAME()       Change the name of a file
 FSEEK()         Set a binary file pointer to a new position
 FWRITE()        Write to an open binary file
 GETACTIVE()     Return the currently active Get object
 GETAPPLYKEY()   Apply a key to a Get object from within a reader
 GETDOSETKEY()   Process SET KEY during GET editing
 GETENV()        Retrieve the contents of a DOS environment variable
 GETPOSTVALID()  Postvalidate the current Get object
 GETPREVALID()   Prevalidate a Get object
 GETREADER()     Execute standard READ behavior for a Get object
 HARDCR()        Replace all soft carriage returns with hard carriage returns
 HEADER()        Return the current database file header length
 I2BIN()         Convert a CA-Clipper numeric to a 16-bit binary integer
 IF()            Return the result of an expression based on a condition
 IIF()           Return the result of an expression based on a condition
 INDEXEXT()      Return index extension defined by the current database driver
 INDEXKEY()      Return the key expression of a specified index
 INDEXORD()      Return the order position of the controlling index
 INKEY()         Extract a character from the keyboard buffer or a mouse event
 INT()           Convert a numeric value to an integer
 ISALPHA()       Determine if the leftmost character in a string is alphabetic
 ISCOLOR()       Determine if the current computer has color capability
 ISDIGIT()       Determine if the leftmost character in a string is a digit
 ISLOWER()       Determine if the leftmost character is a lowercase letter
 ISPRINTER()     Determine whether LPT1 is ready
 ISUPPER()       Determine if the leftmost character in a string is uppercase
 L2BIN()         Convert a CA-Clipper numeric value to a 32-bit binary integer
 LASTKEY()       Return INKEY() value of last key extracted from the keyboard
 LASTREC()       Determine the number of records in the current .dbf file
 LEFT()          Extract substring beginning with first character in a string
 LEN()           Return the length of a string or number of array elements
 LOG()           Calculate the natural logarithm of a numeric value
 LOWER()         Convert uppercase characters to lowercase
 LTRIM()         Remove leading spaces from a character string
 LUPDATE()       Return the last modification date of a database (.dbf) file
 MAX()           Return the larger of two numeric or date values
 MAXCOL()        Determine the maximum visible screen column
 MAXROW()        Determine the maximum visible screen row
 MEMOEDIT()      Display or edit character strings and memo fields
 MEMOLINE()      Extract a line of text from a character string or memo field
 MEMOREAD()      Return the contents of a disk file as a character string
 MEMORY()        Determine the amount of available free pool memory
 MEMOSETSUPER()  Set an RDD inheritance chain for the DBFMEMO database driver
 MEMOTRAN()      Replace carriage return/linefeeds in character strings
 MEMOWRIT()      Write a character string or memo field to a disk file
 MEMVARBLOCK()   Return a set-get code block for a given memory variable
 MENUMODAL()     Activate a top bar menu
 MIN()           Return the smaller of two numeric or date values
 MLCOUNT()       Count the number of lines in a character string or memo field
 MLCTOPOS()      Return position of a string based on line and column position
 MLPOS()         Determine the position of a line in a string or memo field 
 MOD()*          Return the dBASE III PLUS modulus of two numbers
 MONTH()         Convert a date value to the number of the month
 MPOSTOLC()      Return line/ column position of a string based on a position
 NETERR()        Determine if a network command has failed
 NETNAME()       Return the current workstation identification
 NEXTKEY()       Read the pending key in the keyboard buffer 
 NOSNOW()        Toggle snow suppression
 ORDBAGEXT()     Return the default order bag RDD extension
 ORDBAGNAME()    Return the order bag name of a specific order
 ORDCOND()       Specify conditions for ordering
 ORDCONDSET()    Set the condition and scope for an order
 ORDCREATE()     Create an order in an order bag
 ORDDESCEND()    Return and optionally change the descending flag of an order
 ORDDESTROY()    Remove a specified order from an order bag
 ORDFOR()        Return the FOR expression of an order
 ORDISUNIQUE()   Return the status of the unique flag for a given order
 ORDKEY()        Return the key expression of an order
 ORDKEYADD()     Add a key to a custom built order
 ORDKEYCOUNT()   Return the number of keys in an order
 ORDKEYDEL()     Delete a key from a custom built order
 ORDKEYGOTO()    Move to a record specified by its logical record number
 ORDKEYNO()      Get the logical record number of the current record
 ORDKEYVAL()     Get key value of the current record from controlling order
 ORDLISTADD()    Add orders to the order list
 ORDLISTCLEAR()  Clear the current order list
 ORDLISTREBUI()  Rebuild all orders in the order list of the current work area
 ORDNAME()       Return the name of an order in the order list
 ORDNUMBER()     Return the position of an order in the current order list
 ORDSCOPE()      Set or clear the boundaries for scoping key values
 ORDSETFOCUS()   Set focus to an order in an order list
 ORDSETRELAT()   Relate a specified work area to the current work area
 ORDSKIPUNIQUE() Move record pointer to the next or previous unique key
 OS()            Return the operating system name
 OUTERR()        Write a list of values to the standard error device
 OUTSTD()        Write a list of values to the standard output device
 PAD()           Pad character, date, and numeric values with a fill character
 PCOL()          Return the current column position of the printhead
 PCOUNT()        Determine the position of the last actual parameter passed
 PROCLINE()      Return source line number of current or previous activation
 PROCNAME()      Return name of the current or previous procedure or function
 PROW()          Return the current row position of the printhead
 QOUT()          Display a list of expressions to the console
 RAT()           Return the position of the last occurrence of a substring
 RDDLIST()       Return an array of the RDDs
 RDDNAME()       Return name of RDD active in current or specified work area
 RDDSETDEFAULT() Set or return the default RDD for the application
 READEXIT()      Toggle Up arrow and Down arrow as READ exit keys
 READFORMAT()    Return and optionally set code block to implement format file
 READINSERT()    Toggle the current insert mode for READ and MEMOEDIT()
 READKEY()*      Determine what key terminated a READ
 READKILL()      Return and optionally set whether current READ can be exited
 READMODAL()     Activate a full-screen editing mode for a GetList
 READUPDATED()   Determine whether any GET variables changed during a READ
 READVAR()       Return the current GET/MENU variable name
 RECCOUNT()*     Determine the number of records in the current database file
 RECNO()         Return the identity at the position of the record pointer
 RECSIZE()       Determine the record length of a database (.dbf) file
 REPLICATE()     Return a string repeated a specified number of times
 RESTSCREEN()    Display a saved screen region to a specified location
 RIGHT()         Return a substring beginning with the rightmost character
 RLOCK()         Lock the current record in the active work area
 ROUND()         Return a numeric value rounded to a specified number of digits
 ROW()           Return the screen row position of the cursor
 RTRIM()         Remove trailing spaces from a character string
 SAVESCREEN()    Save a screen region for later display
 SCROLL()        Scroll a screen region up or down, right or left
 SECONDS()       Return the number of seconds elapsed since midnight
 SELECT()        Determine the work area number of a specified alias
 SET()           Inspect or change a system setting
 SETBLINK()      Toggle * interpretation between blinking/background intensity
 SETCANCEL()     Toggle Alt+C and Ctrl+Break as program termination keys
 SETCOLOR()      Return the current colors and optionally set new colors
 SETCURSOR()     Set the cursor shape
 SETKEY()        Assign an action block to a key
 SETMODE()       Change display mode to a specified number of rows and columns
 SETPOS()        Move the cursor to a new position
 SETPRC()        Set PROW() and PCOL() values
 SOUNDEX()       Convert a character string to "soundex" form
 SPACE()         Return a string of spaces
 SQRT()          Return the square root of a positive number
 STR()           Convert a numeric expression to a character string
 STRTRAN()       Search and replace characters within a string or memo field
 STUFF()         Delete and insert characters in a string
 SUBSTR()        Extract a substring from a character string
 TIME()          Return the system time
 TONE()          Sound a speaker tone for a specified frequency and duration
 TRANSFORM()     Convert any value into a formatted character string
 TRIM()          Remove trailing spaces from a character string
 TYPE()          Determine the type of an expression
 UPDATED()       Determine whether a GET changed during a READ
 UPPER()         Convert lowercase characters to uppercase
 USED()          Determine whether a database file is in USE
 VAL()           Convert a character number to numeric type
 VALTYPE()       Determine the data type returned by an expression
 VERSION()       Returns CA-Clipper version
 WORD()*         Convert CALL command numeric parameters from double to int
 YEAR()          Convert a date value to the year as a numeric value

C5_ATAIL

 ATAIL()
 Return the highest numbered element of an array
------------------------------------------------------------------------------
 Syntax

     ATAIL(<aArray>) --> Element

 Arguments

     <aArray> is the array.

 Returns

     ATAIL() returns either a value or a reference to an array or object.
     The array is not changed.

 Description

     ATAIL() is an array function that returns the highest numbered element
     of an array.  It can be used in applications as shorthand for
     <aArray>[LEN(<aArray>)] when you need to obtain the last element of an
     array.

 Examples

     .  The following example creates a literal array and returns that
        last element of the array:

        aArray := {"a", "b", "c", "d"}
        ? ATAIL(aArray)                     // Result: d

 Files   Library is CLIPPER.LIB.

See Also: LEN()



C5_AT

 AT()
 Return the position of a substring within a character string
------------------------------------------------------------------------------
 Syntax

     AT(<cSearch>, <cTarget>) --> nPosition

 Arguments

     <cSearch> is the character substring to be searched for.

     <cTarget> is the character string to be searched.

 Returns

     AT() returns the position of the first instance of <cSearch> within
     <cTarget> as an integer numeric value.  If <cSearch> is not found, AT()
     returns zero.

 Description

     AT() is a character function used to determine the position of the first
     occurrence of a character substring within another string.  If you only
     need to know whether a substring exists within another string, use the $
     operator.  To find the last instance of a substring within a string, use
     RAT().

 Examples

     .  These examples show typical use of AT():

        ? AT("a", "abcde")                  // Result: 1
        ? AT("bcd", "abcde")                // Result: 2
        ? AT("a", "bcde")                   // Result: 0

     .  This example splits a character string based on the position
        of a comma within the target string:

        cTarget := "Langtree, Lilly"
        ? SUBSTR(cTarget, 1, AT(",", cTarget) - 1)
        // Result: Langtree

        ? SUBSTR(cTarget, AT(",", cTarget) + 2)
        // Result: Lilly

 Files   Library is CLIPPER.LIB.

See Also: RAT() STRTRAN() SUBSTR()

 

C5_ASORT

 ASORT()
 Sort an array
------------------------------------------------------------------------------
 Syntax

     ASORT(<aTarget>, [<nStart>],
        [<nCount>], [<bOrder>]) --> aTarget

 Arguments

     <aTarget> is the array to be sorted.

     <nStart> is the first element of the sort.  If not specified, the
     default starting position is one.

     <nCount> is the number of elements to be sorted.  If not specified,
     all elements in the array beginning with the starting element are
     sorted.

     <bOrder> is an optional code block used to determine sorting order.
     If not specified, the default order is ascending.

 Returns

     ASORT() returns a reference to the <aTarget> array.

 Description

     ASORT() is an array function that sorts all or part of an array
     containing elements of a single data type.  Data types that can be
     sorted include character, date, logical, and numeric.

     If the <bOrder> argument is not specified, the default order is
     ascending.  Elements with low values are sorted toward the top of the
     array (first element), while elements with high values are sorted toward
     the bottom of the array (last element).

     If the <bOrder> block argument is specified, it is used to determine the
     sorting order.  Each time the block is evaluated, two elements from the
     target array are passed as block parameters.  The block must return true
     (.T.) if the elements are in sorted order.  This facility can be used to
     create a descending or dictionary order sort.  See the examples below.

     When sorted, character strings are ordered in ASCII sequence; logical
     values are sorted with false (.F.) as the low value; date values are
     sorted chronologically; and numeric values are sorted by magnitude.

 Notes

     .  ASORT() is only guaranteed to produce sorted output (as
        defined by the block), not to preserve any existing natural order in
        the process.

     .  Because Clipper implements multidimensional arrays by
        nesting subarrays within other arrays, ASORT() will not directly sort
        a multidimensional array.  To sort a nested array, you must supply a
        code block which properly handles the subarrays.

 Examples

     .  This example creates an array of five unsorted elements, sorts
        the array in ascending order, then sorts the array in descending
        order using a code block:

        aArray := { 3, 5, 1, 2, 4 }
        ASORT(aArray)
        // Result: { 1, 2, 3, 4, 5 }

        ASORT(aArray,,, { |x, y| x > y })
        // Result: { 5, 4, 3, 2, 1 }

     .  This example sorts an array of character strings in ascending
        order, independent of case.  It does this by using a code block that
        converts the elements to uppercase before they are compared:

        aArray := { "Fred", Kate", "ALVIN", "friend" }
        ASORT(aArray,,, { |x, y| UPPER(x) < UPPER(y) })

     .  This example sorts a nested array using the second element of
        each subarray:

        aKids := { {"Mary", 14}, {"Joe", 23}, {"Art", 16} }
        aSortKids := ASORT(aKids,,, { |x, y| x[2] < y[2] })

        Result:

        { {"Mary", 14}, {"Art", 16}, {"Joe", 23} }

 Files   Library is EXTEND.LIB.

See Also: ASCAN() EVAL() SORT



C5_ASIZE

 ASIZE()
 Grow or shrink an array
------------------------------------------------------------------------------
 Syntax

     ASIZE(<aTarget>, <nLength>) --> aTarget

 Arguments

     <aTarget> is the array to grow or shrink.

     <nLength> is the new size of the array.

 Returns

     ASIZE() returns a reference to the target array, <aTarget>.

 Description

     ASIZE() is an array function that changes the actual length of the
     <aTarget> array.  The array is shortened or lengthened to match the
     specified length.  If the array is shortened, elements at the end of the
     array are lost.  If the array is lengthened, new elements are added to
     the end of the array and assigned NIL.

     ASIZE() is similar to AADD() which adds a single new element to the end
     of an array and optionally assigns a new value at the same time.  Note
     that ASIZE() is different from AINS() and ADEL(), which do not actually
     change the array's length.

     Note:  ASIZE() only supports single-dimensional arrays.

 Examples

     .  These examples demonstrate adding new elements and deleting
        existing elements:

        aArray := { 1 }          // Result: aArray is { 1 }
        ASIZE(aArray, 3)         // Result: aArray is { 1, NIL, NIL }
        ASIZE(aArray, 1)         // Result: aArray is { 1 }

 Files   Library is CLIPPER.LIB.

See Also: AADD() ADEL() AFILL() AINS()

 

C5_ASCAN

 ASCAN()
 Scan an array for a value or until a block returns true (.T.)
------------------------------------------------------------------------------
 Syntax

     ASCAN(<aTarget>, <expSearch>,
        [<nStart>], [<nCount>]) --> nStoppedAt

 Arguments

     <aTarget> is the array to be scanned.

     <expSearch> is either a simple value to scan for, or a code block.
     If <expSearch> is a simple value it can be character, date, logical, or
     numeric type.

     <nStart> is the starting element of the scan.  If this argument is
     not specified, the default starting position is one.

     <nCount> is the number of elements to scan from the starting
     position.  If this argument is not specified, all elements from the
     starting element to the end of the array are scanned.

 Returns

     ASCAN() returns a numeric value representing the array position of the
     last element scanned.  If <expSearch> is a simple value, ASCAN() returns
     the position of the first matching element, or zero if a match is not
     found.  If <expSearch> is a code block, ASCAN() returns the position of
     the element where the block returned true (.T.).

 Description

     ASCAN() is an array function that scans an array for a specified value
     and operates like SEEK when searching for a simple value.  The
     <expSearch> value is compared to the target array element beginning with
     the leftmost character in the target element and proceeding until there
     are no more characters left in <expSearch>.  If there is no match,
     ASCAN() proceeds to the next element in the array.

     Since ASCAN() uses the equal operator (=) for comparisons, it is
     sensitive to the status of EXACT.  If EXACT is ON, the target array
     element must be exactly equal to the result of <expSearch> to match.

     If the <expSearch> argument is a code block, ASCAN() scans the <aTarget>
     array executing the block for each element accessed.  As each element is
     encountered, ASCAN() passes the element's value as an argument to the
     code block, and then performs an EVAL() on the block.  The scanning
     operation stops when the code block returns true (.T.), or ASCAN()
     reaches the last element in the array.

 Examples

     .  This example demonstrates scanning a three-element array using
        simple values and a code block as search criteria.  The code block
        criteria shows how to perform a case-insensitive search:

        aArray := { "Tom", "Mary", "Sue" }
        ? ASCAN(aArray, "Mary")               // Result: 2
        ? ASCAN(aArray, "mary")               // Result: 0
        //
        ? ASCAN(aArray, { |x| UPPER(x) ;
              == "MARY" })                    // Result: 2

     .  This example demonstrates scanning for multiple instances of a
        search argument after a match is found:

        LOCAL aArray := { "Tom", "Mary", "Sue",;
                           "Mary" }, nStart := 1
        //
        // Get last array element position
        nAtEnd := LEN(aArray)
        DO WHILE (nPos := ASCAN(aArray, "Mary", ;
                     nStart)) > 0
           ? nPos, aArray[nPos]
           //
           // Get new starting position and test
           // boundary condition
           IF (nStart := ++nPos) > nAtEnd
              EXIT
           ENDIF
        ENDDO

     .  This example scans a two-dimensional array using a code block.
        Note that the parameter aVal in the code block is an array:

        LOCAL aArr:={}
        CLS
        AADD(aArr,{"one","two"})
        AADD(aArr,{"three","four"})
        AADD(aArr,{"five","six"})
        ? ASCAN(aArr, {|aVal| aVal[2] == "four"})         // Returns 2

 Files   Library is CLIPPER.LIB.

See Also: AEVAL() EVAL()

 

C5_ASC

 ASC()
 Convert a character to its ASCII value
------------------------------------------------------------------------------
 Syntax

     ASC(<cExp>) --> nCode

 Arguments

     <cExp> is the character expression to be converted to a number.

 Returns

     ASC() returns an integer numeric value in the range of zero to 255,
     representing the ASCII value of <cExp>.

 Description

     ASC() is a character conversion function that returns the ASCII value of the
     leftmost character in a character string.  ASC() is used primarily on
     expressions requiring numeric calculations on the ASCII value of a
     character.  CHR() and ASC() are inverse functions.

 Examples

     .  These examples illustrate various results of ASC():

        ? ASC("A")                     // Result: 65
        ? ASC("Apple")                 // Result: 65
        ? ASC("a")                     // Result: 97
        ? ASC("Z") - ASC("A")          // Result: 25
        ? ASC("")                      // Result: 0

 Files   Library is CLIPPER.LIB.

See Also: CHR() INKEY() STR() VAL()