Results 1 to 3 of 3

Thread: Text parsing

  1. #1
    Join Date
    Apr 2007
    Location
    England
    Posts
    83
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Text parsing

    I'm wanting to create a script which would break up all the characters in a string of text I input, and then check a wordlist in .txt format with the word, a new then and then a new word.

    What I need help with is detecting, in the text file, a new line.

    I'm not sure whether SCAR can detect a new line of text in a text file, or if i should start every new line with a character scar will detect, and one where it will know the text has ended.

    Any help would be useful.

  2. #2
    Join Date
    May 2006
    Posts
    1,230
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Detects a newline in a textfile and then writes it in the debug box. You can also just add it to an array of string if you want.

    SCAR Code:
    program New;
    var
      oDialog: TOpenDialog;
      i, a : integer;
      txtFile: Integer;
      TextFileLines : string;
      txtPath : string;
    begin
      //thx scar test files for half of this code.

      oDialog := TOpenDialog.Create(nil);
      oDialog.Filter := 'SCAR Scripts|*.scar|Text Files|*.txt|All Files|*.*';
      if oDialog.Execute then
        txtPath := oDialog.FileName;

      txtFile:= OpenFile(txtPath, False);
      if(txtFile > -1)then
      begin
        ReadFileString(txtFile, TextFileLines, FileSize(txtFile));
        CloseFile(txtFile);
      end;
      //I tried TStringList; didn't work well.
      ClearDebug;
      repeat
        i := pos(chr(13), TextFileLines);
        Writeln(Copy(TextFileLines, 1, i - 1));
        Delete(TextFileLines, 1, i);
      until pos(chr(13), TextFileLines) < 1
      Writeln(Copy(TextFileLines, 1, Length(TextFileLines)));
    end.

  3. #3
    Join Date
    Apr 2007
    Location
    England
    Posts
    83
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Grabbing or reading Text from a game text box
    By British in forum OSR Help
    Replies: 16
    Last Post: 02-27-2009, 08:02 AM
  2. Text help
    By Leech in forum OSR Help
    Replies: 2
    Last Post: 10-03-2008, 07:55 PM
  3. Getting text from text window?
    By Gone Fishing in forum OSR Help
    Replies: 8
    Last Post: 04-24-2008, 07:33 PM

Posting Permissions

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