Xbasic

template_to_expression Function

Syntax

C TEMPLATE_TO_EXPRESSION(template as c , general_rules as c , specific_rules as c [, taggedStrings as l [, concatFunction as l [, trimConcat as l [, supportIf as l]]]])

Arguments

templateCharacter

Template string

general_rulesCharacter

Rules string, cr-lf delimited

specific_rulesCharacter

Rules string, cr-lf delimited

taggedStringsLogical

Are the strings tagged

concatFunctionLogical

Concatenate

trimConcatLogical

Trim

supportIfLogical

Support IF statements in the template

Returns

resultCharacter

Returns the output expression.

Description

From a template, following cr-lf delimited rules, convert to expression.

Example

? template_to_expression("{firstname} {lastname}","{e}=(e)","",.f.,.f.,.t.)
= (firstname)-" "+(lastname)

? template_to_expression("embedded if {if .t.}hello{else}bye{endif} example","{e}=(e)","",.f.,.f.,.f.,.t.)
= "embedded if "+if(.t.,"hello","bye")+" example"

? template_to_expression("embedded elseif {if .f.}hello{elseif .t.}try{else}bye{endif} example","{e}=(e)","",.f.,.f.,.f.,.t.)
= "embedded elseif "+case(.f.,"hello",.t.,"try",.t.,"bye")+" example"