Results 1 to 9 of 9

Thread: TReplaceFlags ?

  1. #1
    Join Date
    Apr 2007
    Location
    Colchester, UK
    Posts
    1,220
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default TReplaceFlags ?

    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?

  2. #2
    Join Date
    Oct 2009
    Location
    Stockton, CA
    Posts
    2,040
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    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)
    Quote Originally Posted by #srl
    10:45 < Toter> daphil when can get sex anyday I want
    10:45 < Toter> he is always on #SRL
    "A programmer is just a tool which converts caffeine into code"

  3. #3
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    ^That, or do [] if you don't know what does what
    Replace(..... []);

  4. #4
    Join Date
    Feb 2007
    Location
    Het ademt zwaar en moedeloos vannacht.
    Posts
    7,211
    Mentioned
    26 Post(s)
    Quoted
    72 Post(s)

    Default

    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!.

  5. #5
    Join Date
    Apr 2007
    Location
    Colchester, UK
    Posts
    1,220
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    hmmm, i googled it before posting and found that but when i tried it didnt work, must have typed it wrong.

    thanks for answers and will try later

  6. #6
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    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).
    Hup Holland Hup!

  7. #7
    Join Date
    Apr 2007
    Location
    Colchester, UK
    Posts
    1,220
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    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.

  8. #8
    Join Date
    Oct 2006
    Posts
    1,190
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Remove the var text and it should work



  9. #9
    Join Date
    Apr 2007
    Location
    Colchester, UK
    Posts
    1,220
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    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.

    Simba Code:
    after:= Replace(text, 'test', 'Character');
    works fine, no need for the Flags

    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •