Xbasic
replace_placeholders_with_argument_values Function
Syntax
s Result = replace_placeholders_with_argument_values(C string ,P args [,L flagCorrectBackTicks ])
Arguments
- string
String with placeholders
- args
Argument structure with replacement values
- flagCorrectBackTicks
Logical
Description
Replaces placeholders (enclosed in curly parens, e.g. {arg1}, {arg2}) in a string with values in a SQL::Arguments object.
Example
dim args as sql::arguments args.add("arg1","selwyn") args.add("arg2",now()) args.add("arg3",23) txt = "hello {arg1}, the time is now {arg2} and the day is {arg3}" txt2 = replace_placeholders_with_argument_values(txt,args) ?txt2 = "hello selwyn, the time is now 01/25/2011 11:00:03 77 am and the day is 23"
See Also
- There are several other ways to process templates:
- The replace_variables_in_string Function substitutes the values of dot variables in a string
- e.g. "p.firstname" becomes "Jim"
- The evaluate_string Function replaces placeholders in a string with variable values and returns a transformed string.
- The compilestringtemplate Function is much more efficient than the evaluate_string Function when used inside a loop.
- The replace_arguments_in_string Function takes a string that contains SQL::Arguments in it (e.g. ":Arg1"
- as opposed to curly brackets) and replaces the arguments with actual values.