Difference between revisions of "ALINES()"

From Lianjapedia
Jump to: navigation, search
m (1 revision)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
==Purpose==
 
==Purpose==
 
Function to fill an array with character strings that are separated with a newline or other specified parsing string
 
Function to fill an array with character strings that are separated with a newline or other specified parsing string
 
  
 
==Syntax==
 
==Syntax==
 
ALINES(<array>, <expC1> [<expN> [, <expC2>]])
 
ALINES(<array>, <expC1> [<expN> [, <expC2>]])
 
  
 
==See Also==
 
==See Also==
[[AADD()]], [[AAVERAGE()]], [[ABROWSE()]], [[ACHOICE()]], [[ACOL()]], [[ACOPY()]], [[ADEL()]], [[ADESC()]], [[ADIR()]], [[AELEMENT()]], [[AFIELDS()]], [[AFILL()]], [[AINS()]], [[ALEN()]], [[AMAX()]], [[AMIN()]], [[APPEND FROM ARRAY]], [[AROW()]], [[ARRAY()]], [[ASCAN()]], [[ASIZE()]], [[ASORT()]], [[ASTORE()]], [[ASTRING()]], [[ASUBSCRIPT()]], [[ASUM()]], [[COPY TO ARRAY]], [[DBEDIT()]], [[DECLARE]], [[DIMENSION]], [[FILETOSTR()]], [[GATHER]], [[IN_ARRAY()]], [[LOCAL]], [[MENU AT]], [[MENU BROWSE]], [[MENU FIELDS]], [[MENU FILES]], [[MENU FROM]], [[MENUITEM()]], [[PRIVATE]], [[PUBLIC]], [[RELEASE]], [[RESTORE]], [[SAVE]], [[SCATTER]]
+
[[AADD()]], [[AAVERAGE()]], [[ACOPY()]], [[ADEL()]], [[ADESC()]], [[ADIR()]], [[AELEMENT()]], [[AFIELDS()]], [[AFILL()]], [[AINS()]], [[ALEN()]], [[AMAX()]], [[AMIN()]], [[APPEND FROM ARRAY]], [[ARRAY()]], [[ASCAN()]], [[ASIZE()]], [[ASORT()]], [[ASTORE()]], [[ASTRING()]], [[ASUBSCRIPT()]], [[ASUM()]], [[COPY TO ARRAY]], [[DECLARE]], [[DIMENSION]], [[FILETOSTR()]], [[GATHER]], [[IN_ARRAY()]], [[LOCAL]], [[PRIVATE]], [[PUBLIC]], [[RELEASE]], [[RESTORE]], [[SAVE]], [[SCATTER]]
 
+
  
 
==Description==
 
==Description==
Line 19: Line 16:
  
  
{| class="wikitable"
+
{| class="wikitable" width="100%"
!Bit||Value (additive)||Description
+
!width="10%"|Bit||Value (additive)||Description
 
|-
 
|-
|0||1||Removes leading and trailing spaces from lines, or for memos and BLOBs, removes trailing zeroes (0) instead of spaces. This is the default.
+
|valign="top"|0||valign="top"|1||Removes leading and trailing spaces from lines, or for memos and BLOBs, removes trailing zeroes (0) instead of spaces. This is the default.
 
|-
 
|-
|1||2||Include the last element in the array even if the element is empty.
+
|valign="top"|1||valign="top"|2||Include the last element in the array even if the element is empty.
 
|-
 
|-
 
|2||4||Do not include empty elements in the array.
 
|2||4||Do not include empty elements in the array.
Line 32: Line 29:
 
|4||16||Include the parsing characters.
 
|4||16||Include the parsing characters.
 
|}
 
|}
 
 
  
 
==Example==
 
==Example==
Line 46: Line 41:
 
declare aNums[10]
 
declare aNums[10]
 
nelements = alines(aNums, "one, two, three", 0, ",")
 
nelements = alines(aNums, "one, two, three", 0, ",")
 
// Another Example
 
open database southwind
 
use example
 
menu fields select "+"
 
declare aMenu[512]
 
nelements = alines(aMenu, menuitem(), 0, "+")
 
 
</code>
 
</code>
  
 
==Products==
 
Recital, Recital Server
 
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Functions]]
 
[[Category:Functions]]
[[Category:Array Processing]]
 
 
[[Category:Array Processing Functions]]
 
[[Category:Array Processing Functions]]

Latest revision as of 12:10, 1 February 2013

Purpose

Function to fill an array with character strings that are separated with a newline or other specified parsing string

Syntax

ALINES(<array>, <expC1> [<expN> [, <expC2>]])

See Also

AADD(), AAVERAGE(), ACOPY(), ADEL(), ADESC(), ADIR(), AELEMENT(), AFIELDS(), AFILL(), AINS(), ALEN(), AMAX(), AMIN(), APPEND FROM ARRAY, ARRAY(), ASCAN(), ASIZE(), ASORT(), ASTORE(), ASTRING(), ASUBSCRIPT(), ASUM(), COPY TO ARRAY, DECLARE, DIMENSION, FILETOSTR(), GATHER, IN_ARRAY(), LOCAL, PRIVATE, PUBLIC, RELEASE, RESTORE, SAVE, SCATTER

Description

The ALINES() function fills the <array> with character strings from <expC1> which are separated by a newline. If the optional <expC2> is included, it specifies an alternative parsing string. This string of one or more characters is used to signify where the line should be broken instead of the newline character.

If the <array> does not already exist it will be created. The character strings are copied into the array elements until all the strings are copied. If the <array> is pre-declared, it will be automatically shortened to the number of elements stored in it. The ALINES() function returns the number of character strings copied into the array.

The <expN> is the sum of the required flags:


Bit Value (additive) Description
0 1 Removes leading and trailing spaces from lines, or for memos and BLOBs, removes trailing zeroes (0) instead of spaces. This is the default.
1 2 Include the last element in the array even if the element is empty.
2 4 Do not include empty elements in the array.
3 8 Case-insensitive parsing.
4 16 Include the parsing characters.

Example

// ali.prg - 4 lines
cVar=filetostr("ali.prg")
nVar = alines(aVar, cVar)
echo "Program has " + ltrim(str(nVar)) + " lines\n"
 
 
// Another Example
declare aNums[10]
nelements = alines(aNums, "one, two, three", 0, ",")