How I can delete an item …

How I can delete an item in an array ?

Short Answer : We have a special function : ADel()
Long Answer :

ADel() function may cause some confusions when documentation not read carefully:

This function deletes the element found at the given subscript position in the array.

All elements in the array below the given subscript position will move up one positionin the array.

 

Let’s try:

?
 aTest1 := { 'One', 'Two', "Tree",'Four' }
 aTest := ACLONE( aTest1 )
 ADel( aTest, 3 )
 ? LEN( aTest )
 AEVAL( aTest, { | c1 | QQOUT( c1, '' ) } ) 
 

Result :
4
One Two Four NIL
Length of array not changed, last item moved up and new last item became NIL.

 

?
 ASIZE( aTest, 3 )
 ? LEN( aTest )
 ?
 AEVAL( aTest, { | c1 | QQOUT( c1, '' ) } )

Result :
3
One Two Four
Length of array changed, last item (NIL) removed

We have another possibility: a new Harbour function:

?
 aTest1 := { 'One', 'Two', "Tree",'Four' }
 aTest := ACLONE( aTest1 )
 HB_ADel( aTest, 3 )
 ? LEN( aTest )
 ?
 AEVAL( aTest, { | c1 | QQOUT( c1, '' ) } )
 

Result :
4
One Two Four NIL
Length of array not changed, last item moved up and new last item became NIL.
Same as ADel()

And we have a third parameter : Shrink or not:

 ?
 aTest1 := { 'One', 'Two', "Tree",'Four' }
 aTest := ACLONE( aTest1 )
 HB_ADel( aTest, 3, .T. )
 AEVAL( aTest, { | c1 | QQOUT( c1, '' ) } )

That’s all !

 

How I can insert a new …

How I can insert  a new item to an array ?

Short answer : We have a special function : AIns()
Long Answer :

AIns() function may cause some confusions when documentation not read carefully:

This function inserts a NIL value in the array named <aArray> at the <nPos>th position.

All array elements starting with the <nPos>th position will be shifted down one subscript position in the array list and the last item in the array will be removed completely.

 

Let’s try:

 aTest := { 'One', 'Two', 'Four' }
 AIns( aTest, 3 ) 
 AEVAL( aTest, { | c1 | QQOUT( c1, '' ) } ) 
 

Result : One Two NIL: “Four” lost !

Since it’s NIL, we can assign a value to it:

 aTest := { 'One', 'Two', 'Four' }
 AIns( aTest, 3 )
 aTest[ 3 ] := "Three"
 AEVAL( aTest, { | c1 | QQOUT( c1, '' ) } ) 
 

Result : One Two Three: “Four” lost !

Before insert we can add a dummy item to end of array:

 aTest := { 'One', 'Two', 'Four' }
 AADD( aTest, NIL )
 AIns( aTest, 3 )
 aTest[ 3 ] := "Three"
 AEVAL( aTest, { | c1 | QQOUT( c1, '' ) } ) 
 

Result : One Two Three Four : OK
Or we can change size of array :

 aTest := { 'One', 'Two', 'Four' }
 ASIZE( aTest, 4 )
 AIns( aTest, 3 )
 aTest[ 3 ] := "Three"
 AEVAL( aTest, { | c1 | QQOUT( c1, '' ) } ) 
 

Result : One Two Three Four : OK

But wait; we have another possibility: a new Harbour function:

 aTest := { 'One', 'Two', 'Four' }
 HB_AIns( aTest, 3, "Three" )
 AEVAL( aTest, { | c1 | QQOUT( c1, '' ) } ) 

Result : One Two Three: “Four” lost !

And we have a fourth parameter : Grow or not:

 aTest := { 'One', 'Two', 'Four' }
 HB_AIns( aTest, 3, "Three", .T. )
 AEVAL( aTest, { | c1 | QQOUT( c1, '' ) } ) 
 

Result : One Two Three Four

That’s all !

SP_SL_WRAP

SL_WRAP()

  Short:
  ------
  SL_WRAP() Sets line wrapping on or off

  Returns:
  --------
  cCode => control string to send to the printer

  Syntax:
  -------
  SL_WRAP(lSet)

  Description:
  ------------
  Sets line wrapping on (.t.) or off (.f.) with <lSet>

  Examples:
  ---------
   ?SL_WRAP(.T.)  // set line wrapping on

  Notes:
  -------
  Does not send anything to the printer - instead
  returns a control string that you send to the printer. String can be
  sent with ? or ?? or  QOUT() or QQOUT().

  For HP and compatible(PCL) Laserjet printers.

  Source:
  -------
  S_HPLAS.PRG

 

SP_SL_VLINE

SL_VLINE()

  Short:
  ------
  SL_VLINE() Draws a vertical line from row,col to endrow,col

  Returns:
  --------
  cCode => control string to send to the printer

  Syntax:
  -------
  SL_VLINE(nTop,nLeft,nBottom,nRight,[cShade],[nDPIThick],[nLpi])

  Description:
  ------------
  Draws a vertical line from <nTop,nLeft> to <nBottom,nRight>. Based
  on rows and columns.

  [cShade] refers to the density of the line.

  The shading percentages are (default "100" - black) :

         "1 thru 2" = 2% shade
        "3 thru 10" = 10% shade
       "11 thru 20" = 20% shade
       "21 thru 35" = 30% shade
       "36 thru 55" = 45% shade
       "56 thru 80" = 70% shade
       "81 thru 99" = 90% shade
              "100" = 100% shade

  [nDPIThick] is the thickness in DotsPerInch of the
  line. Default is 2.

  [nLpi] is the lines per inch, and defaults to 6.

  Examples:
  ---------
   ??SL_VLINE(10,20,10,10,"50")  // draws a line 10,10 to 20,10 with
                                          // 50% shading

  Notes:
  -------
  Does not send anything to the printer - instead
  returns a control string that you send to the printer. String can be
  sent with ? or ?? or  QOUT() or QQOUT().

  For HP and compatible(PCL) Laserjet printers.

  Source:
  -------
  S_HPLAS.PRG

 

SP_SL_UNDEROFF

SL_UNDEROFF()

  Short:
  ------
  SL_UNDEROFF() Sets automatic text underlining off

  Returns:
  --------
  cCode => control string to send to the printer

  Syntax:
  -------
  SL_UNDEROFF()

  Description:
  ------------
  Sets automatic text underlining off

  Examples:
  ---------
   ?"Now I am "+SL_UNDER()+"REALLY"+SL_UNDEROFF()+" mad!"

  Notes:
  -------
  Does not send anything to the printer - instead
  returns a control string that you send to the printer. String can be
  sent with ? or ?? or  QOUT() or QQOUT().

  For HP and compatible(PCL) Laserjet printers.

  Source:
  -------
  S_HPLAS.PRG

 

SP_SL_UNDER

SL_UNDER()

  Short:
  ------
  SL_UNDER() Sets automatic text underlining on

  Returns:
  --------
  cCode => control string to send to the printer

  Syntax:
  -------
  SL_UNDER()

  Description:
  ------------
  Sets automatic text underlining on

  Examples:
  ---------
   ?"Now I am "+SL_UNDER()+"REALLY"+SL_UNDEROFF()+" mad!"

  Notes:
  -------
  Does not send anything to the printer - instead
  returns a control string that you send to the printer. String can be
  sent with ? or ?? or  QOUT() or QQOUT().

  For HP and compatible(PCL) Laserjet printers.

  Source:
  -------
  S_HPLAS.PRG

 

SP_SL_TOPMARG

SL_TOPMARG()

  Short:
  ------
  SL_TOPMARG() Designates the number of lines of top margin

  Returns:
  --------
  cCode => control string to send to the printer

  Syntax:
  -------
  SL_TOPMARG(nLines)

  Description:
  ------------
  Designates the number of lines of top margin <nLines>

  Examples:
  ---------
   ?SL_TOPMARG(3) // sets top margin to 3

  Notes:
  -------
  Does not send anything to the printer - instead
  returns a control string that you send to the printer. String can be
  sent with ? or ?? or  QOUT() or QQOUT().

  For HP and compatible(PCL) Laserjet printers.

  Source:
  -------
  S_HPLAS.PRG

 

SP_SL_SETLPI

SL_SETLPI()

  Short:
  ------
  SL_SETLPI() Sets the lines per inch for the laserjet

  Returns:
  --------
  cCode => control string to send to the printer

  Syntax:
  -------
  SL_SETLPI(nLPI)

  Description:
  ------------
  Sets the lines per inch for the laserjet to <nLpi>
  which  can be:

  1 - 1 line/inch
  2 - 2 line/inch
  3 - 3 line/inch
  4 - 4 line/inch
  6 - 6 line/inch
  8 - 8 line/inch
  12-12 line/inch
  16-16 line/inch
  24-24 line/inch
  48-48 line/inch

  Examples:
  ---------
   cCode := SL_SETLPI(6)     // sets LPI to 6 - the default

   ?cCode

  Notes:
  -------
  Does not send anything to the printer - instead
  returns a control string that you send to the printer. String can be
  sent with ? or ?? or  QOUT() or QQOUT().

  For HP and compatible(PCL) Laserjet printers.

  Source:
  -------
  S_HPLAS.PRG

 

SP_SL_SETCPI

SL_SETCPI()

  Short:
  ------
  SL_SETCPI() Sets characters per inch

  Returns:
  --------
  cCode => control string to send to the printer

  Syntax:
  -------
  SL_SETCPI(nCPI)

  Description:
  ------------
  Sets characters per inch to <nCpi>  - valid to 2
  decimal places. Current font must support this CPI.

  Examples:
  ---------
   ?SL_SETCPI(16.66)   // sets to compressed

   ?SL_SETCPI(12)     // sets to 12 cpi

   ?SL_SETCPI(10)     // sets to 10 cpi  (default)

  Notes:
  -------
  Does not send anything to the printer - instead
  returns a control string that you send to the printer. String can be
  sent with ? or ?? or  QOUT() or QQOUT().

  For HP and compatible(PCL) Laserjet printers.

  Source:
  -------
  S_HPLAS.PRG

 

SP_SL_RIGHTMARG

SL_RIGHTMARG()

  Short:
  ------
  SL_RIGHTMARG() Sets the right margin to the right edge of the
  specified column

  Returns:
  --------
  cCode => control string to send to the printer

  Syntax:
  -------
  SL_RIGHTMARG(nCol)

  Description:
  ------------
  Sets the right margin to the right edge of the
  specified column <nCol>

  Examples:
  ---------
   ?SL_RIGHTMARG(70) // sets right margin to 70

  Notes:
  -------
  Does not send anything to the printer - instead
  returns a control string that you send to the printer. String can be
  sent with ? or ?? or  QOUT() or QQOUT().

  For HP and compatible(PCL) Laserjet printers.

  Source:
  -------
  S_HPLAS.PRG