You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 39 Next »

PARSE# returns a Telitab set parsed from a document

Syntax

PARSE#(Document$,[InpVar])

Arguments

  • Document$ is a string value containing either a Telitab set or a (set of) value(s);
  • InpVar are optional parameters or objects that should be computerd prior to the parsing.

Remarks

  1. The parsing recipe should be included in the data slot of the expression in which the PARSE#() function is used.
  2. If the data slot the relation does not contain any filter data, the program seeks the filter in the data slot of parameter Document$.
  3. The parse scripts are best explained by the examples below. Their are however several issues to take into account:
    1. A parse script starts with @FILTER and ends with @ENDFILTER;
    2. A list value is identified in the script by @LIST(InpVar), connecting the parsed value or string to InpVar (the parameter you want to connect the parsed information to), followed by the exact text part to identify the information including the indicators on the possitions of the value or string to be parsed (see 3. to 5. below);
    3. For parsing a value use "vv" (without the quotes);
    4. For parsing a string value use "ss";
    5. (version 2.47.2 and later) for parsing any value or string values including spaces, use "xx";
    6. Please note that a minimum of two characters for "v" and "s" are required in the filter;
    7. A table is identified in the script by @TABLE(InpVar), connecting the parsed values and/or strings to InpVar (the parameters you want to connect the parsed table to), followed by the exact sequence of indicators on the possitions of the values or strings to be parsed as table (see 3. to 5. above). Note that, although you might only want to use one collumn out of a table, you need to give the indicators for all values in the table. Otherwise Quaestor will not be able to recognise the connection between the specified script and the data;
    8. Moreover, realise when using "ss" or "vv" Quaestor expects a full table with values. When values in the table are missing, the whole row will be ignored. To avoid this, you can use "aa" instead. When using "aa" all missing date is assumed to be pending.
    9. Please make sure that @LIST() and @TABLE() are directly followed by a CrLf (an "enter").
    10. Use @TELITAB(InpVar) and @ENDTELITAB(InpVar) to create a separate TeLiTab (or Object) connected to InpVar (the parameter/object you want to connect the parsed set of information to), in combination with @LIST() and @TABLE() to parse the information for this TeLiTab;
    11. @FILTER can included conditions (see also the example below). Syntax: @FILTER(Condition), with Condition one or more expressions including parameters seperated by comma's; Please be aware that both the parameters an their determined values should be available (so include them to your function syntax).
  4. In some cases, it might be necessary to prepare and modify the document in order to comply with the rules above. In almost all cases this is possible by means of smart use of text manipulation functions like REPLINS$, PARAGRAPH$ and SECTION$ (see also String document functions ). By means of PARAGRAPH$ and SECTION$ you can select specific areas out of a document to make sure that an unique filter can be created for that part. REPLINS$ can be used to remove things like CrLf's ("enters"), spaces, part of names, etc.).

Examples

First example

Let  contain the following data.

And there is a relation

ParseDocument# = PARSE#(Document$)

With the following information in the data slot.

Explanation

opens object "OpenWater":

Then 

makes a single Telitab value of parameter "TestNr" on the basis of the filter definition: 

And then 

creates a table header: 

and the filter definition: 

seeks lines in the source document that are containing values in ALL cells corresponding with the locations marked by v's and are added to the parsed result. 
And finally the object is closest using:

Creating

The combined result is:

   

Second example

Assume the following document to be parsed:

    

You see that note CARE behind the data. The only way to parse this data is to use the "aa" mask:

Would you have used the "ss" mask instead of the "aa" mask the result would be:

With "aa" it will be:

In which -999999 stands for PENDING values.

Troubleshoot/Tips & Tricks

  1. Things can very easily go wrong when you are parsing:
    1. The format of the text in the filter has to be exactly the same as that of the text in the original document. Therefore, always use Courier as font in your text editor in order to have non-scalable characters and thus being able to align spaces. 
    2. The vv's and ss's have to be exactly in the right positions, otherwise the function doesn't work.
  2. It is a good idea to copy the original text into the data slot of your PARSE# relation when making a filter. In this way you have guidance while placing everything in the right position.
    Here is an example. The table is pasted into the dataslot and the vv's are written underneath to place them in the right position:

  3. Non-Telitab parsing. 
    For the above source document using the filter: 



    the result will be: 

    "37816"

    and with 



    the result: 



    is obtained 

  4. Use of conditional Filter
    A Relation or parameter can contain a set of conditional filters: 



    this means:

     means: "If METH2D3D=1 AND RE="T" then apply this filter as closed by @ENDFILTER" for the first @FILTER(Condition) of which condition = True is applied. 


 

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

  • No labels