Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 9 of 9
  1. #1
    Join Date
    Oct 2003
    Posts
    27

    Need help with text file

    I have a logfile and i want to remove blank lines in the logfile.So when i print the logfile, 2 logfiles print at one page(63 lines)somtimes a logfile is larger than 32 lines then only one logfile comes at one page............. i had made it with ams 4.0 but it takes 1 hour to remove the lines when i had 100 or 200 logfiles....the problem is with ams 5.0 ....i dont understand how to made this......
    Attached Files

  2. #2
    Join Date
    Dec 2003
    Location
    Location! Location!
    Posts
    6,137
    The link below contains possible solutions (at least in part) to what you are trying to accomplish in AMS 5.

    This should help get you on the right track, at the least.

    http://www.indigorose.com/forums/sho...ve+blank+lines
    Intrigued

  3. #3
    Join Date
    Oct 2003
    Posts
    27

    Huh?

    yes i have seen this example....but i i must search for a word and delete the next line......not delete all blank lines...........

  4. #4
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    Pretender, what words are you wanting to search for in the text file? By reading the text file into a table you can then go line by line through the table and remove the blank line after any line which contains the keyword you want to search for. If you have more than one keyword I would suggest using a table to define the keywords as part of your search.

    For example:
    Code:
    tFiles = Dialog.FileBrowse(true, "Browse", "AutoPlay\\Docs", "Text Files (*.txt)|*.txt|", "", "", false, true); 
    
    --you only need to check tFiles[1] for CANCEL
    if tFiles[1] ~= "CANCEL" then 
    
      --*************************************
      tFileContents = TextFile.ReadToTable(tFiles[1])     
      --*************************************
      --KeyWords = {"Alarm","Abort","Data log", "description", "machine no."};
      KeyWords = {"Data log", "description", "machine no."};
      for kwindex, keyword in KeyWords do
    
        for index, row in tFileContents do 
          if String.Find(row, keyword, 1, true) ~= -1 then
            Table.Remove(tFileContents, index + 1) 
          end 
        end
      end 
      --Build a variable that contains the tables content
      strFile=""
      for index, row in tFileContents do 
         strFile = strFile ..  row .. "\r\n"
      end
      Paragraph.SetText("Paragraph1", strFile)
    end
    Hope this helps. I have attached a sample project as well. You may want to add a line that check to make sure that the line you are removing is actually blank.

    Tigg
    Attached Files
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

  5. #5
    Join Date
    Dec 2003
    Location
    Location! Location!
    Posts
    6,137
    Thank you TJ for the assist... I was in the middle of formulating my reply, but it got busy at the 'shop'. I have some nicely colored Paragraph boxes though that were to be apart of my example solution, to show 'before' and 'after' snap shots. (grin)

    This objective is something I would like to accomplish myself! I am glad it was brought up.
    Intrigued

  6. #6
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    No Problem, Just thought I would pipe in where I could. I have done something similar to this with another project.

    Tigg
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

  7. #7
    Join Date
    Oct 2003
    Posts
    27

    Oops

    thanks for the help....this is the right way.......but i dont think that i can finish the poject.....its tooooooo complicate for me....every second logfile (at abort) i must delete one line as it is in the Logfile_print.txt.And and the big problem is that the logfiles can be larger than this in the sample then only one logfile can be printed at one page......

  8. #8
    Join Date
    Oct 2003
    Posts
    27

    Huh?

    I have an error messege......dont understand why......i have removed lines in every second logfile......and i checked if there is a long logfile but now i had an error messege.......can somone help???
    Attached Files

  9. #9
    Join Date
    Oct 2001
    Location
    Norway
    Posts
    939
    I started your app and got an error message at line 68, but I don’t think this is “true”. Why: There is a mismatch of if/for and end statement. My personal advice: Adjust your code with proper TAB indents after if and for. When you have a paragraph like this:

    if String.Find(row, keyword, 1, true) ~= -1 then
    index = index + 1
    Table.Remove(tFileContents, index)
    end

    Mark the two lines between if and end; press TAB. It’s easier to view the code when the lines are indented. I think the “end” at line 90 should be removed. Lines 91-137 are empty lines?

    You are looking for some keywords. But why “Abort” two times? Your code:
    KeyWords = {"Abort","Abort","description", "machine no."};

    You are deleting the NEXT line (index = index + 1). You will have en error when “next line” doesn’t exist. You should count the number of lines:
    RowCount = Table.Count(tFileContents);
    and add an if statement:
    Code:
    if index < RowCount then
           removed = Table.Remove(tFileContents, index)    
           --Debug.Print("Removed = "..removed..”\r\n”);   
    end
    Use the debug facilities. Start your code with:
    Debug.ShowWindow(true);
    Debug.SetTraceMode(true); --eventually
    and add Debug.Print() where appropriate.

    It should be easier to remove ALL blank lines instead of removing the line after "Abort","description", "machine no." But I’m not sure whether I have the correct understanding of what you want to achieve.

    I learned something new from your project: How to hide an object at design time.

    Good luck!

Similar Threads

  1. Writing Text to a File
    By Desmond in forum AutoPlay Media Studio 5.0 Examples
    Replies: 0
    Last Post: 09-22-2003, 02:02 PM
  2. Getting lines from a text file....
    By RobbyH in forum AutoPlay Media Studio 4.0
    Replies: 3
    Last Post: 03-03-2003, 10:53 AM
  3. HOWTO: "Hide" Externally Referenced Files
    By Support in forum AutoPlay Media Studio 4.0 Examples
    Replies: 0
    Last Post: 10-23-2002, 03:19 PM
  4. Text File Actions
    By csd214 in forum Setup Factory 6.0
    Replies: 0
    Last Post: 12-06-2001, 12:50 AM
  5. Replies: 0
    Last Post: 08-17-2000, 02:29 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