DeFormat function
Prototype: |
function DeFormat1(Data: String; Format: String; var r1: variant): integer; function DeFormat2(Data: String; Format: String; var r1, r2: variant): integer; ... function DeFormat10(Data: String; Format: String; var r1, r2, r3, r4, r5, r6, r7, r8, r9, r10: variant): integer; |
|
Description: |
An inverse operation to Format is the DeFormat function. It is used to retrieve values from a formatted string. There are several versions of this functions to be used depending on the number of values to be fetched from a string: Tip : The DeFormat function is extremely useful when parsing lines read from text files (see the Text file chapter).
|
|
Syntax: |
Deformat2(Datastring, Templatestring, outvar1, outvar2); |
|
Part |
Description |
|
Datastring Templatestring outvar1 .. outvarn |
source string to parse data from a template specifying the format of source data output variables to fetch values into |
|
Return value: |
Number of parameters successfully parsed. |
|
Example: var id, height: variant; begin if DeFormat2('ID=4, Height=15.23', 'ID=%d, Height=%f', id, height) = 2 then begin ShowMessage('id: ' + IntToStr(id) + #13#10 + 'height: ' + FloatToStr(height)); end else begin ShowError('Failed to parse string!'); end; end. |
||
The variable “ID” contains the value 4 and the variable “height” contains the value 15.23. The result value of the function is 2.
Output in Field-Map Data Collector:

See also:
Format; LZero; Delete; Trim; TrimLeft; TrimRight; SameText; StringReplace; DeFormat1-10; GetFieldCountFromString;GetFieldFromString; IndexOfField; SortNumericSequence
© 2024 IFER-Monitoring and Mapping Solutions