SP_BLDARR

BLDARR()

  Short:
  ------
  BLDARR() Builds an array from a delimited string

  Returns:
  --------
  Nothing

  Syntax:
  -------
  BLDARR(aTarget,nCount,cDelimited)

  Description:
  ------------
  Fills in the elements of an existing array <aTarget>
  with <nCount> character values extracted from a delimited string
  <cDelimited> of the form "Garry:Wyn:Ralph:Ed". The colon [:] is
  the delimiter. The first parameter is an array of any length. It
  will be sized to fit.

  Examples:
  ---------
   aLunch := array(3)
   BLDARR(aLunch,3,"Pizza:Chicken:Burgers")
       // =>  {"Pizza","Chicken","Burgers"}

  Notes:
  -------
  Array must be declared prior to calling.
  Of course, in Clipper 5.01 you can also use:
  myarray := {"Pizza","Chicken","Burgers"},
  and this function is mainly here for compatibility.

  Source:
  -------
  S_BLDAR.PRG

 

{ } Literal array and code block delimiters

 


 { }
 Literal array and code block delimiters         (Special)
------------------------------------------------------------------------------
 Syntax

     { <exp list> }                 (literal array)
     { |<param list>| <exp list> }  (code block definition)

 Operands

     <exp list> is a list of expressions of any type.  If the item is a
     literal array definition, it can contain another literal array
     definition.

     <param list> is a list of variables to receive parameters passed to
     a code block from an invocation of the EVAL() function.  The parameter
     list is comma-separated and must be enclosed by vertical bars (||).
     Variables specified in this list are declared local to the code block
     and are visible only within the code block definition.

 Description

     Curly braces ({}) delimit references to literal arrays or code blocks.
     If the reference is a literal array, you can use them to create an array
     in either an assignment or a variable declaration statement.  If the
     reference is a variable declaration, the array can contain expressions
     of any kind as elements, unless STATIC is the declaration statement.  In
     this case, the literal array can only contain constant values.

 Examples

     .  This example uses literal arrays in declaration statements to
        create a variable and initialize it with an array reference:

        LOCAL aPerson := { "Name", "Address", DATE() }
        STATIC aNumList := { 1, 2, 3, 4, 5, 6, 7, 8 }

     .  This example creates a multidimensional literal array:

        aMulti := { {1, 2, 3}, {"A", "B", "C"} }

     .  This example uses curly braces to formulate a simple code
        block with a single parameter:

        LOCAL bSayBlock
        bSayBlock := { |x| QOUT(x) }
        EVAL(bSayBlock, 10)               // Result: 10

See Also: EVAL() LOCAL PRIVATE PUBLIC STATIC

Harbour New Data types

Data type & Syntax extensions in Harbour

In addition to Clipper’s scalar ( Character, Number, Date, Logical, MEMO, Nil ) and complex ( array, CodeBlock )  data types; Harbour has extended data types: pointer as scalar and object and hach as complex type.

For standard data types please refer here and/or here.

In database files (tables) data types of fields are predefined in structure of table.

For extended field types please refer here.

For data items other than fields (such as variables and manifest constants); in general, type of data  determined automatically by system, when assigning a value. The first basic way of this, is assigning a “literal” value.

For a working sample about constants please refer here.

cString := "This is a string" // A character string enclosed by a string delimiter
nNumber := 123.45 // A numeric value combined digits, decimal point and a sign ( + / - )
lTrue   := .T. // A T (tYy) or F (fNn) letter enclosed by two periods (.)
aArray  := {} // Arrays can be assigned literally by enclosed with curly brace

In addition to this basic literal value notations, Harbour has also extended notations:

– Data Types determined by special prefixs

— 0x… : Hexadecimal constant

  nNumber := 0x0A  // 0x prefix implies the string as Hexadecimal String  
                   // and type of resulting value become as Numeric (N) 
  ? nNumber, VALTYPE( nNumber ) // 10 N

— 0d… date constant

    dDate_1 := 0d20121225  // 0d prefix implies the string a date string 
                           // ( instead of using CTOD() )
                           // and type of resulting value become as Date (D) 
    ? dDate_1, VALTYPE( dDate_1 ) // 25.12.2012 D

– Special literal string formats

— d”…” : Date constant

dDate_2 := d"2012-12-26" ? dDate_2, VALTYPE( dDate_2 ) // 26.12.2012 D

— t”…” : Time constant

tTime_1 := dDate_2 + t”01:31:06″

? tTime_1, VALTYPE( tTime_1 ) // 26.12.2012 01:31:06.000 T

— e”…” : Escape sequences

Escape sequences are used to define certain special characters within string literals.

( Prefix by “\” escape sequence codes within that string )

The following escape sequences are available in C and C++ language :

Escape
sequence Description            Representation

   '     single quote          byte 0x27
   "     double quote          byte 0x22
   ?     question mark         byte 0x3f
         backslash             byte 0x5c

         null character        byte 0x00
   a     audible bell          byte 0x07
   b     backspace             byte 0x08
   f     form feed - new page  byte 0x0c
   n     line feed - new line  byte 0x0a
   r     carriage return       byte 0x0d
   t     horizontal tab        byte 0x09
   v     vertical tab          byte 0x0b

   nnn   arbitrary octal value byte nnn
   xnn   arbitrary hexadecimal value byte nn

   unnnn arbitrary Unicode value.
          May result in several characters. code point U+nnnn
   Unnnnnnnn arbitrary Unicode value.
           May result in several characters. code point U+nnnnnnnn

Note that all sequences not available in Harbour.

For the new complex data type Hash, there is a literally assigning way :

hHash := { => }    // => sign indicates the hash

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

PROCEDURE Main()
SET CENT ON
SET DATE GERM
CLS

* Data Types determined by special prefixs

** 0x... : Hexadecimal constant

nNumber := 0x0A // 0x prefix implies the string as Hexadecimal String 
// and type of resulting value become as Numeric(D)
? nNumber, VALTYPE( nNumber ) // 10 N
** 0d... date constant 

 dDate_1 := 0d20121225 // 0d prefix implies the string a date string 
                       // ( instead of using CTOD() )
                       // and type of resulting value become as Date (D) 

? dDate_1, VALTYPE( dDate_1 ) // 25.12.2012 D
* Special literal string formats
** d"..." : Date constant
dDate_2 := d"2012-12-26"
? dDate_2, VALTYPE( dDate_2 ) // 26.12.2012 D 

** t"..." : Time constant
tTime_1 := dDate_2 + t"01:31:06"
? tTime_1, VALTYPE( tTime_1 ) // 26.12.2012 01:31:06.000 T

** e"..." : Escape sequences 

? e"This is\na string\nformatted by\nEscape sequences \x21

/* The result : 
This is
a string
formatted by
Escape sequences !
*/
@ MAXROW(), 0 WAIT "EOF DTS_Exts.prg" 
RETURN // DTS_Exts.Main() 

*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ DTS_Exts

General Terms

ASCII :

An acronym for the American Standard Code for Information Interchange, the agreed upon standard for representing characters (alphabetic, symbolic, etc.) in the memory of the computer.

Binary :

The numerical base upon which computer programs are modeled. Also referred to as base 2, it is a mathematical way of representing the electrical circuitry upon which computers operate. A 0 represents an off state, and a 1 indicates an on state. A combination of eight ons and offs are used to express bytes of program or data in memory.

See Also: Byte

Buffer :

A temporary data storage location in memory. As an example, a disk input-output buffer is an area of memory that stores data read from the disk to temporary locations while processing it.

Byte :

Eight bits of data, the smallest unit of information stored in the computer’s memory. As an example, one byte is required to represent one ASCII character.

Character :

A letter, digit, punctuation mark, or special symbol stored and processed by the computer.

See Also: ASCII String

Delimiter :

A character or other symbol that marks a boundary.

Destination :

The work area, file, or device to which data is sent.

Device :

Either an actual physical component of the computer system such as printer or a DOS handle that refers to it (e.g., PRN:), or a logical device that behaves and is addressed the same way as a physical device (e.g., a print spooler).

Disk :

A magnetic storage medium designed for long-term storage. Disks come in two varieties: hard disks (fast but fixed) or floppy disks (slow but removable). A disk can be partitioned into multiple volumes, each containing a tree-structured directory system that holds files accessible by programs.

See Also: Directory, File, Volume

Dynamic :

Used generically to refer to data or algorithms that change with time. Often used specifically to describe algorithms that automatically adjust to prevailing conditions.

Formfeed :

A special character (CHR(12)) that by convention causes most printers to move the printhead to the top of the next page.

See Also: Hard Carriage Return Linefeed

Hard Carriage Return :

An explicit carriage return character at the end of a line in a text file, as opposed to a soft carriage return that might be inserted into text by a program designed to handle word wrapping. A hard carriage return character is generated by the expression (CHR(13)) where a soft carriage return character is generated with the expression (CHR(141)).

Hexadecimal :

A representation of a value in base 16 rather than decimal which is base 10. Hexadecimal values are easily converted to and from binary (base 2) which is the form of data the computer actually uses. Hexadecimal values are represented by digits zero through nine and A through F for values between 10 and 15.

Extended Character Set :

The character set built into the ROM of the PC. This character set is a superset of ASCII, containing additional special characters (such as a line drawing character set) that may be used to enhance your program screens.

Linefeed :

A special character (CHR(10)) that by convention causes the cursor or printhead to move to the next line or to terminate a line in a text file. It is usually used in combination with a hard carriage return.

See Also: Formfeed, Hard Carriage Return

Port :

A designation for the hardware that allows the processor to communicate with peripheral devices.

Query :

A query is also a general term used when you want to interrogate a setting or an exported instance variable for its current value.

Queue :

A data structure of variable length where elements are added to one end and retrieved from the other. A queue is often described as first in, first out.

See Also: Print Spooler, Stack

Soft Carriage Return :

A carriage return that is introduced into text usually in order to implement some sort of wrap operation, as opposed to a Hard Carriage Return that was specifically entered into the text when it was created.

Stack :

A data structure of variable length whose elements are added and retrieved from the same end. A stack is often described as first in, last out.

See Also: Queue