Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Retrieving Text

  1. #1

    Retrieving Text


    I need to search for a text from a file and then display the contents of the same found in that particular line...

    I have retrieved the text from the file and also i was able to get the line number where the text is displayed...now along with the text there are some other values too in the same line..now I want to retrieve all the values displayed in that line where my text resides...How to achieve this??

  2. #2

    Re: Retrieving Text

    Use FileReadLine

  3. #3

    Re: Retrieving Text

    I do have filereadline in my code and I was able to retrieve the text from the file...what i want to do is retrieve the other values in the same line where my searched text resides...below is my code

    [ ] HANDLE hfile
    [ ] BOOLEAN bDidRead
    [ ] STRING sLine
    [ ]
    [ ] hfile = FileOpen(path,FM_READ) // Read the log file
    [ ] bDidRead =FileReadLine(hfile,sLine) // Read the Log File Line by Line and store the same into an variable sLine
    [ ]
    [ ] STRING rel
    [ ]
    [-] while (FileReadLine (hfile, sLine))
    [ ] rel = GetField(sLine, ' ',2)
    [ ]
    [-] if (rel==searchterm)
    [ ] print("found")
    [-] else
    [ ] print(rel)
    [ ] print("not found")

  4. #4

    Re: Retrieving Text

    convert the file into list of strings, so u will get both string as well as line number.

    UBB CodeTM

  5. #5

    Re: Retrieving Text

    Where you find the searchtext in the while loop, also keep a variable that stores the whole Line text.
    I dont know if this is what you want 'cause I cant get what you mean by "other values in the same line"

  6. #6

    Re: Retrieving Text

    The file has text in the foll format

    This version is aligned with CPU build from June 08, 2004.

    First release to system test for HMI build 1.

    soo each line would have one sentence with one word or more than one word..some lines may not contain any text at all...and this file does not have any de-limiter.. Now in the above example.. i want to extract the which is coming after the word Release...this number is nothing but the version...i'm able to retrieve the text Release from the file but i'm not able to get the number that comes next to it..

    Hope now the prob is clear for u to help me out!

  7. #7

    Re: Retrieving Text

    That space you have in the GetField function might be a tab character.

    Try GetField(sLine, "{Chr(7)}",2)


  8. #8

    Re: Retrieving Text

    Mr. Miller...tab is Chr(9). Tsk tsk tsk. <grin>

    Just as a general tip, a couple of constants I always include for ease of use:

    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;"> [ ] const TAB = Chr(9)
    [ ] const CR = Chr(13)
    [ ] const LF = Chr(10)
    [ ] const CRLF = CR + LF
    </pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">- Dave
    A concerned Borland customer, a fly in the ointment, a wrench in the works.

  9. #9

    Re: Retrieving Text


    Thnx for the suggestions but nothing seems to work for me...

    Can someone give me an solution?

  10. #10

    Re: Retrieving Text

    Hi silkascent,
    I have a feeling John is right.
    It is a problem with the delimiter.
    But if it is not working with that,
    You now have the whole line string in the sLine variable.
    Now if all you need to do is match the content of the file line with a particular value,try using :
    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">
    if MatchStr(&quot;*{searchterm}*&quot;,sLine,)
    print(&quot;not found&quot
    </pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">Hope this will help.


Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
BetaSoft Inc.
All times are GMT -8. The time now is 07:43 PM.

Copyright BetaSoft Inc.