How can I use the REPLACE function to replace {1}

okion

New Member
From a database i got a message. That massage contains a {1} string. Does anyone know how to replace the {1} value.
When i use: ASSIGN c_Text = REPLACE(c_Text, "{1}":U, "&2"). I get an error that parameter 2 must have a value...
 

j4n

Member
{1} is a preprocessor statement that gets replaced before a file is compiled.

include.i
Code:
DEF VAR thisIsSparta AS {1} NO-UNDO.
procedure1.p
Code:
{include.i "LOGICAL"}
thisIsSparta = false.
procedure2.p
Code:
{include.i "INTEGER"}
thisIsSparta = 0.
before compilation of procedure1.p and procedure2.p the preprocessor replaces the {1} with whatever you pass to the include. if you dont pass anything it stays empty.
 

GregTomkins

Active Member
Put a slash in front of the first { to escape it and cause it to be parsed like a normal character. eg:

REPLACE(c_Text, "\{1}":U, "&2")

This will work assuming that is literally what your REPLACE statement needs to look like, as opposed to the {1} expanding to some runtime value from the database.
 
Top