I would like to edit my code to replace all special characters. For example I am replacing the & character with ""&""
Here is my code:
trigger OnOpenPage();
var
ItInput: Text[50];
ItWhat: Text[50];
ItWhit: Text[50];
ItOutput: Text[50];
LiInputLen: Integer;
LiWhatLen: Integer;
LiFindFirst: Integer;
Aux: Label 'Juan & Jose & "Niño"';
Text001: Label '&';
Text002: Label '&';
begin
// La función TextReplace encuentra todas las ocurrencias de 'What' en la cadena 'Input' y las reemplaza con 'ltWith'
ItInput := Aux;
ItWhat := Text001;
ItWhit := Text002;
LiInputLen := STRLEN(ItInput);
LiWhatLen := STRLEN(ItWhat);
// Comprueba si ltInput y ltWhat no son cadenas vacías
If (LiInputLen > 0) and (LiWhatLen > 0) then begin
LiFindFirst := STRPOS(ItInput, ItWhat);
WHILE (LiFindFirst > 0) do begin
ItOutput := ItOutput + COPYSTR(ItInput, 1, liFindFirst - 1);
ItOutput := ItOutput + ItWhit;
ItInput := DELSTR(ItInput, 1, liFindFirst + liWhatLen - 1);
liFindFirst := STRPOS(ItInput, ItWhat);
end;
ItOutput := ItOutput + ItInput;
Message(ItOutput);
end else begin
ItOutput := ItInput;
end;
end;
This is the message I show:
Juan & Jose & "Niño
...But I would like to implement the following validations:
■ In the case of &, the sequence "&";
■ In the case of “, the sequence """;
■ In the case of <, the sequence "<";
■ In the case of >, the sequence ">";
■ In the case of ', the sequence "&apos";
Can someone help me here?
I'd appreciate it guys.