Hey,
so i need to use TReplaceFlags but i dont have a clue how to declare them or what they are in simba.
its needed for Replace();
couldn't see anything in the documentation.
any help?
rfIgnoreCase, rfReplaceAll
Like Replace('blah', 'blah', [rfReplaceAll])
Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
Originally Posted by #srl
"A programmer is just a tool which converts caffeine into code"
^That, or do [] if you don't know what does what
Replace(..... []);
There are two replaceflags, rfReplaceAll or rfIgnoreCaps
Use them in an array.
Without rfReplaceAll it'll only replace the first instance.
Demo:
Simba Code:program new;
begin
writeln(replace('bOt rot tot kot vOt', 'ot', 'at', []));
writeln(replace('bOt rot tot kot vOt', 'ot', 'at', [rfReplaceAll]));
writeln(replace('bOt rot tot kot vOt', 'ot', 'at', [rfIgnoreCase]));
writeln(replace('bOt rot tot kot vOt', 'ot', 'at', [rfIgnoreCase, rfReplaceAll]));
end.
Pure coincidence that I asked this yesterday @ #SRL myself? =)
I made a new script, check it out!.
A little tip if you want to know more about a type: use code completion. Type TReplaceFlags and hit ctrl+space. You'll see that it says "TReplaceFlags: set of TReplaceFlag". Now do you the same for TReplaceFlag and you'll find that it's an enumeration of rfReplaceAll..rfIgnoreCase. If the enum follows the convention it has a certain prefix (in this case "rf"). Now type in rf and hit ctrl+space again to find all your possible options (make sure they have "(TReplaceFlag)" behind them).
Thanks for the pro tip, will help alot
edit:
doesnt work for me
Simba Code:procedure UpdateString;
var
text, after:String;
i:integer;
begin
Accounts:= OpenFile(Path + '1.xml' , False);
ReadFileString(Accounts, text, FileSize(accounts));
after:= replace(text, 'test', 'Character', [rfIgnoreCase]);
writeln(text);
writeln(after);
CloseFile(Accounts);
end;
i get [Error] (124:61): Invalid number of parameters at line 123;
which is the after:= replace(); section.
Last edited by Bobzilla69; 02-02-2011 at 10:19 AM.
but "Text" is the string to search in?
Simba Code:replace(Text:String;FindStr:String;ReplaceStr:String;Flags:TReplaceFlags):String;
is whats its asking for....
but i will try.
Edit:
Code Hint is wrong for replace.
works fine, no need for the FlagsSimba Code:after:= Replace(text, 'test', 'Character');
if you type Replace then Ctrl + Space it shows the correct variables needed
The code hint its showing is for ReplaceWrap();
Last edited by Bobzilla69; 02-02-2011 at 12:20 PM.
There are currently 1 users browsing this thread. (0 members and 1 guests)