Skip to content

Commit

Permalink
Added REPLACE _ WITH _ FROM _ IN _, deprecated old REPLACE
Browse files Browse the repository at this point in the history
  • Loading branch information
xvxx committed Dec 3, 2022
1 parent c8ce150 commit 9c2141f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/text.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ will store
in `myTextVariable`.


## `REPLACE _ FROM _ WITH _ IN _`
## `REPLACE _ WITH _ FROM _ IN _`


The `REPLACE` statement finds and replaces every occurrence of some TEXT in a TEXT variable or value some other TEXT. The result is then stored in a TEXT variable.

**Syntax:**

```coffeescript
REPLACE <TEXT-VAR or TEXT> FROM <TEXT-VAR or TEXT> WITH <TEXT-VAR or TEXT> IN <TEXT-VAR>
REPLACE <TEXT-VAR or TEXT> WITH <TEXT-VAR or TEXT> FROM <TEXT-VAR or TEXT> IN <TEXT-VAR>
```

**Example:**
Expand Down
9 changes: 9 additions & 0 deletions src/aux/aux_compile_line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,15 @@ void compile_line(vector<string> &tokens, compiler_state &state)
return;
}

if (line_like("REPLACE $str-expr WITH $str-expr FROM $str-expr IN $str-var", tokens, state))
{
if (!in_procedure_section(state))
badcode("REPLACE statement outside PROCEDURE section", state.where);
// C++ Code
state.add_code(get_c_variable(state, tokens[7]) + " = str_replace(((chText)" + get_c_expression(state, tokens[5]) + ").str_rep(), ((chText)" + get_c_expression(state, tokens[1]) + ").str_rep(), ((chText)" + get_c_expression(state, tokens[3]) + ").str_rep());", state.where);
return;
}
//deprecated
if (line_like("REPLACE $str-expr FROM $str-expr WITH $str-expr IN $str-var", tokens, state))
{
if (!in_procedure_section(state))
Expand Down

0 comments on commit 9c2141f

Please sign in to comment.