<?xml version="1.0" encoding="utf-8"?>
<ManualTopic ID="/baanerp/da/onlinemanual/000049" xml:lang="en">
	<Header>
		<Title xmlns:HTML="http://www.w3.org/TR/REC-html40">dadlldate-line</Title>
	</Header>
	<GeneralSection><GeneralSection><SectionTitle>DLL Usage Description</SectionTitle>
			<Paragraph class="Default">Library: dadlldataline</Paragraph>
			<List><ListIntro>This library contains the following functions:</ListIntro>
				<ListItem>scan.sepa : scan a dataline in separator format</ListItem>
				<ListItem>scan.fix : scan a dataline in fixed length format</ListItem>
				<ListItem>concat.sepa: print a dataline in separator format (will not be implemented)</ListItem>
				<ListItem>concat.fix : print a dataline in fixed length format (not yet implemented)</ListItem>
			</List>
		</GeneralSection>
		<GeneralSection><SectionTitle>DLL Prototypes</SectionTitle>
			<Formula space-and-orientation="indented-estimated"><Paragraph class="Default">
function extern concat.fix(
                ref string dataline(),
                long offset,
                const long spos(,),
                const long leng(,),
                long index, ... )

pre   : let variable part of argument list be arg1, ..., argn (n &gt;= 0)
        let the types of these arguments be typei (1 &lt;= i &lt;= n)

space reserved for dataline is long enough to contain result
AND offset &gt;= 1
AND length_of_array(spos) &gt;= n
AND length_of_array(leng) &gt;= n
AND FORALL i: 1 &lt;= i &lt;= length_of_array(spos) : spos(i) &gt;= 1
AND FORALL i: 1 &lt;= i &lt;= length_of_array(leng) : leng(i) &gt;= 0

post  : FORALL i: 1 &lt;= i &lt;= n:
        - dataline(offset+spos(i)-1; leng(i)) =
          ( typei = string ? argi : str$(argi) )
desc  : This is a rather operational description and certainly not
        formally correct. Problems:
        - overlapping arguments: if for some arguments the place where
          they should come in the result string do overlap the above
          statement should hold for at least one of these arguments.
          So it is not defined in what order the arguments should be
          placed into the string.
        - if len(argi) &gt; leng(i) (typei = string) then argi should be
          truncated.

        if len(str$(argi)) &gt; leng(i) (typei = numeric) then
        str$(argi) should be truncated (and hopefully its only
        loosing precision).

function extern long scan.fix(
                const string dataline(),
                ref long offset,
                const long spos(,),
                const long leng(,),
                long index,
                long llen, ... )

pre   : let variable part of argument list be arg1, ..., argn (n &gt;= 0)
        let the types of these arguments be typei (1 &lt;= i &lt;= n)

        offset &gt;= 1
        AND length_of_array(spos) = length_of_array(leng) &gt;= n
        AND FORALL i: 1 &lt;= i &lt;= n : spos(i) &gt;= 0
        AND FORALL i: 1 &lt;= i &lt;= n : leng(i) &gt;= 0
        AND FORALL i: 1 &lt;= i &lt;= n : spos(i) = 0 =&gt; leng(i) = 0
        AND llen = MAX j: 1 &lt;= j &lt;= n : spos(j) + leng(j) - 1
        return: len(line) &gt;= offset + llen - 1
        or (len(line) &gt;= offset + spos(n) - 1 and typen = string)

post  : ret ==&gt;
        FORALL i: 1 &lt;= i &lt;= n and spos(i) &gt; 0:
           typei = string ==&gt; argi = dataline(offset+spos(i)-1;leng(i))
           typei = double ==&gt; argi = val(  ,, )
           typei = long   ==&gt; argi = lval( ,, )

        AND FORALL i: 1 &lt;= i &lt;= n and spos(i) = 0: argi = old(argi)
        AND offset = old(offset) + llen
        desc: In contrast to the function concat.fix this function
        does not have problems with overlapping fields.
        Note that fields that have an spos of 0 may not be changed,
        nor emptied (this is to skip multiline fields).

function extern long scan.sepa(
                const string dataline(),
                ref long offset,
                string sepa(1),
                string encl(1), ... )

pre   : let variable part of argument list be arg1, ..., argn (n &gt;= 0)
        let the types of these arguments be typei (1 &lt;= i &lt;= n)

        offset &gt;= 1
        AND len(sepa) = 1

return: The number of arguments that could be filled
 (thus 0 &lt;= retval &lt;= n)

post  : FORALL i: 1 &lt;= i &lt;= retval:
            typei = long   ==&gt; argi = lval(SUBSTR(i)) AND
            typei = double ==&gt; argi = val(SUBSTR(i)) AND
            typei = string and (encl =  "" or SUBSTR(i) = "")
                           ==&gt; argi = SUBSTR(i) AND
            typei = string and encl &lt;&gt; ""
                           ==&gt; argi = SUBSTR(2; len(SUBSTR(i)-2))

        offset = old(offset) + SEPA.OCC(retval) - 1

desc  : where SUBSTR(i) is defined as:
        dataline(offset+SEPA.OCC(i-1); SEPA.OCC(i)-SEPA.OCC(i-1)-1)
        (informally: the substring between the (i-1)th and the ith
         separator)

        and where SEPA.OCC is defined as:
        SEPA.OCC(0) = 0
        SEPA.OCC(1) = pos(dataline(offset), sepa)
        SEPA.OCC(n) = SEPA.OCC(n-1) +
                      pos(dataline(offset+SEPA.OCC(n-1)), sepa)
        (as long as this pos is positive and not considering separators
         occuring between enclosing characters)
        SEPA.OCC(m) = len(dataline) - offset + 2
        (otherwise)
        (informally: the ith occurence of the separator in
         dataline(offset) or the index just after the end of the
         string, if not existing)

        Thus this function splits dataline into substrings separated
        by the separator sepa. The substrings are assigned (if
        necessary using the conversion functions lval or val) to the
        arguments. The offset is placed behind the last substring
        scanned (or if this last substring is followed by a separator
        behind this separator).
        The return value indicates how many arguments could be scanned
        and thus will be limited by:
         - the number of variable arguments
         - the number of separators occuring in dataline (from
           position offset on)

        If encl &lt;&gt; "" string arguments must be either:
          - enclosed by the enclosing character encl
          - empty (ie 2 separators occur on subsequent positions)
        Note that it is possible that a string is scanned in several
        phases and thus, that offset should be just behind the
        separator after the nth argument (and not on it)
</Paragraph>
			</Formula>
		</GeneralSection>
	</GeneralSection>
	<RelatedTopics><SectionTitle>
                              Related topics
                           </SectionTitle>
		<RelTopic><Link href="/baanerp/da/onlinemanual/000102" role="manual">Libraries</Link>
		</RelTopic>
	</RelatedTopics>
</ManualTopic>
