Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.



SECTION$ returns SECTION$ returns a section from a document starting and ending with lines containing specific strings


Syntax

SECTION$(Document$, PageHeader$, PageEnd$, [AddLines%=>0])

Arguments

  • Document$ is

    Document$  is a string containing the source document.

  • PageHeader$ is

    PageHeader$  is a sub string

    of Document$ which

    of Document$  which indicates the first line of the section.

  • PageEnd$ is

    PageEnd$  is a sub string

    of Document$ that

    of Document$  that indicates the end of the section.
    The result starts with the first line

    of Document$ containing PageHeader$ and

    of Document$  containing PageHeader$ and ends with the line just before the line containing PageEnd$.

  • AddLines% is

    AddLines%  is an optional value, containing the number of lines to be added at the end of the section. E.g. when

    AddLines%

     AddLines%=1 , also the line

    containing PageEnd$ is

    containing PageEnd$  is included.

Remarks

  1. If PageHeader$="NullString", the function returns "NullString".
  2. If PageHeader$ is not found, the function also returns "NullString".
  3. If PageEnd$="NullString", the function returns all text from Document starting with PageHeader$.
  4. If PageEnd$ is not found, the function also returns all text from Document starting with PageHeader$.
  5. The last line of the result returned by SECTION$() is always terminated by a CrLf CrLf (Carriage Return + LineFeed: Chr$ Chr$(13)+Chr$(10) ). Multiple repeating CrLfrepeating CrLf's at the end of an extracted section are removed as well as trailing strings from each line in that result.
  6. One can also use the PARAGRAPH$() function the PARAGRAPH$ function to return a section of a document.

...

Assuming a document with the following text:

"Turning and turning in the widening gyre 
The falcon cannot hear the falconer; 
Things fall apart; the centre cannot hold; 
Mere anarchy is loosed upon the world 
The blood-dimmed tide is loosed, and everywhere 
The ceremony of innocence is drowned; 
The best lack all conviction, while the worst 
Are full of passionate intensity"

then 
SECTION$(Document$, "fall apart", "ceremony")


returns
"Things fall apart; the centre cannot hold; 
Mere anarchy is loosed upon the world 
The blood-dimmed tide is loosed, and everywhere 
"


SECTION$(Document$, "fall apart", "Ceremony")

returns
"Things fall apart; the centre cannot hold; 
Mere anarchy is loosed upon the world 
The blood-dimmed tide is loosed, and everywhere 
The ceremony of innocence is drowned; 
The best lack all conviction, while the worst 
Are full of passionate intensity 
"

Because "Ceremony" does not occur in Document$. Note, the function is case sensitive.


SECTION$(Document$, "falls apart", "ceremony")

returns

"NullString"

since "falls apart" is not present in Document$.


SECTION$(Document$, "fall apart", "ceremony", 2)

returns
"Things fall apart; the centre cannot hold; 
Mere anarchy is loosed upon the world 
The blood-dimmed tide is loosed, and everywhere 
The ceremony of innocence is drowned; 
The best lack all conviction, while the worst 


"

Two more lines are included.


 

Quick links: Function Functions overview | Attribute overview | Constants overview | Dimensions overview