How to continously read for a string or word in a file?

Hi
I have been trying for a while now to search for a word that is being written to a file.
I was wondering if anyone can get me over this hump?
What I am doing is reading from the serial port to a file (example file called test), and while this is being done I want to search for the word "passed" or the phrase "test passed"
Once I fine this word or phrase, I can stop the test
I cannot figure out how to search the file, I used the scan file VI and the search/ replace VI etc with no luck!
Your suggestions is appreciated

It's always best to post your code so others can see the work you've done.  Suggestions will be more effective that way.
So your reading from a serial port to a file?  What do you mean by this?  Are you reading from the serial port and writing the data to a file?  It's the file you want to read, isn't it?  If I had your code I could answer my own questions  
Why don't you just monitor the incoming data stream from the serial port for "passed."
But to read from a file and search for a string, Smercurio is correct.  Match Pattern will do what you need (You can use this same function for ASCII serial data as well).
Reese, (former CLAD, future CLD)
Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home

Similar Messages

  • How do i search for a string in a txt file using java??

    How do i search for a string in a txt file using java??
    could you please help thanks
    J

    Regular expressinos work just fine, especially when
    searching for patterns. But they seem to be impying
    it's a specific group of characters they're looking
    for, and indexOf() is much faster than a regex.If he's reading from a file, the I/O time will likely swamp any performance hit that regex introduces. I think contains() (or indexOf() if he's not on 5.0 yet) is preferable to regex just because it's simpler. (And in the case of contains(), the name makes for a very clear, direct mapping between your intent and the code that realizes it.)

  • Search for a String in a list of files

    Could anyone please send me a java sample code which searches for a string from a list of files and returns me the filename and the line in which the Search String was found ?
    Thanks in advance
    RR

    Simple solution would be -
    1. Traverse a directory for each file.
    2. Read each file using Buffered Reader.
    3. Use readLine() method to read a line.
    4. Use String.indexOf to see if the data which you are looking for is there in the line or not.
    5. If its there then store the line number and file name.
    6. When the loop will end you will have list of file name and line number where the data which you are looking for is present.

  • How do I read two dimentional string object in C through JNI

    HI,
    I am new to JNI and Java as well. I want to read two dimentional string object passed by java to a native method written in C/C++. Say for example I have declared a two dimentional string object as below:
    In Java
    class InstanceFieldAccess {
    private String [][] originalAddress = new String[][13];
    private static native String [] accessField(String [][] referenceAddress);
    public static void main(String args[]) {
    /// Java code to get the string object and pass the string object to native method
    new InstanceFieldAccess ().accessField(referenceAddress);
    static {
    System.loadLibrary("ReadStr");
    In C/C++
    I want to read the passed two dimentional string array in C/C++ native code and do the further processing and pass the string
    back to Java class.
    Could anybody tell me how to write the corresponding C/C++ native method.
    Thanks in Advance.
    Pramod.

    i got it thanks.

  • How can I search for a string like a partial IP address in the global search

    When searching for a string like "10.255." the global search finds messages containing "255" or "10" and both.
    This happens no matter whether quotation is used or not.
    When quotation is used it probably will match on the given order as well, but beeing in the timezone '+0100' the string "10" is always found first (in the email headers...).
    Is there a way to tell the global search not to use '.' or any other character as whitespace?

    When searching for a string like "10.255." the global search finds messages containing "255" or "10" and both.
    This happens no matter whether quotation is used or not.
    When quotation is used it probably will match on the given order as well, but beeing in the timezone '+0100' the string "10" is always found first (in the email headers...).
    Is there a way to tell the global search not to use '.' or any other character as whitespace?

  • How do I search for a string in the Text tab of the Layers panel

    I have a world map with a text layer for country names.  I hide the country names as needed by clicking on the 'eye' icon for Toggle Visibility in the Layers panel.  I've inadvertently hidden one name and I need to know how to find it in the Text panel so I can make it visible again.  How do I seatrch for a name in the Text panel?

    Just in case there is an unlocked and visible object close to the hidden one in the stacking order, you may select that object right on the artboard and then go to the Layers palette menu and take the Locate Object command.
    Of course, this would be just one possible workaround to locate the hidden objects a bit easier.

  • How can we read some bytes from every line of the file

    How can we read some bytes from the every line of the file moving on to the next line
    without using the read line

    Actualiy readLine() takes more execution time
    for reading a part of line if we can do so without
    readLine() we can save some time...Well, if you knew, beforehand, the length of each line, you could use RandomAccessFile and its seek method, but, since you don't, you would have to read the rest of the line character-by-character, checking to see if it is a newline, in order to place the "cursor" at the beginning of the next line in order to read the next few characters you want.
    So, as you can see, you will need to read the entire line anyway (and if you do it yourself you also have to do the checking yourself considering all three possible end-of-line sequences), so you just as well use readLine().
    Some people may suggest Scanner and it's nextLine() method, but that also needs to read the rest of line (as evidenced by the fact that it returns it), so that is no different than the readLine() (or read it yourself) solution.

  • How can I read an XML string that's not from an XML file?

    I've got a script I'm trying to setup that communicates over a socket to retrieve different directions from a custom built Java program.  The Java program listens to requests from the Adobe scripting engine (in my case it's a Photoshop script) on a socket and immediately responds with the next set of directions.  These directions are currently in XML format.  The issue I'm having is that I can't parse the XML data since it's entered into a new XML object from a string rather than being read from a file.  Even without the socket code, you can see the issue by doing the following:
    var xml = new XML("<test><data>hey!</data></test>");
    alert(xml.test.data);
    alert(xml);
    The first alert "should" return "hey!" (without quotes, of course), but it doesn't, while the second alert returns what you would expect it to:
    <test>
        <data>hey!</data>
    </test>
    It works fine if read from an XML file, but from a string, like shown above, it just presents an empty alert box when attempting to access "xml.test.data".  Any ideas on how to fix this issue?  Can it be fixed?  Has it been fixed in newer versions (I'm currently using CS4)?
    Thanks in advance for any help!

    Duh... found my error... I was attempting to access the data by referencing the created "root" element.  Since <test> is the very first element tag, it's setup as the root element, which you don't need to reference.  Changing the alert to alert(xml.data); fixed it.
    Now I just feel dumb, lol...

  • How can I search for a string, as an input parameter to a procedure?

    Hi all,
    I need to solve one scenario. In this the search string and search against columns, both are passed as input parameters to a procedure. till now i didn't face this situation.. can you please help me in this by giving some sample code...
    Thanks in advance.
    Regards,
    Ramu.

    Maybe something like this then?
    SQL> CREATE OR REPLACE PROCEDURE EMP_SEARCH
      2  (
      3          pColumnName     IN VARCHAR2
      4  ,       pSearchParam    IN VARCHAR2
      5  ,       pResult         OUT SYS_REFCURSOR
      6  )
      7  AS
      8  BEGIN
      9          IF UPPER(pColumnName) = 'ENAME' THEN
    10                  OPEN pResult FOR
    11                          SELECT  ENAME
    12                          FROM    SCOTT.EMP
    13                          WHERE   ENAME LIKE '%' || pSearchParam || '%';
    14          ELSIF UPPER(pColumnName) = 'JOB' THEN
    15                  OPEN pResult FOR
    16                          SELECT  ENAME
    17                          FROM    SCOTT.EMP
    18                          WHERE   JOB LIKE '%' || pSearchParam || '%';
    19          ELSIF UPPER(pColumnName) = 'DEPTNO' THEN
    20                  OPEN pResult FOR
    21                          SELECT  ENAME
    22                          FROM    SCOTT.EMP
    23                          WHERE   DEPTNO LIKE '%' || pSearchParam || '%'
    24          END IF;
    25  END;
    26  /
    SP2-0804: Procedure created with compilation warnings
    SQL> VAR C REFCURSOR
    SQL> EXEC EMP_SEARCH('ENAME','SMITH',:c);
    PL/SQL procedure successfully completed.
    SQL> PRINT c;
    ENAME
    SMITH
    SQL> EXEC EMP_SEARCH('JOB','MANAGER',:c);
    PL/SQL procedure successfully completed.
    SQL> print c;
    ENAME
    JONES
    BLAKE
    CLARK
    SQL> EXEC EMP_SEARCH('DEPTNO','30',:c);
    PL/SQL procedure successfully completed.
    SQL> print c
    ENAME
    ALLEN
    WARD
    MARTIN
    BLAKE
    TURNER
    JAMES
    6 rows selected.Be careful though. If you have a large amount of data this search could take a long time because Oracle will not choose an indexed path. If that's an issue you should investigate using Oracle Text.
    HTH!
    Edited by: Centinul on Apr 26, 2010 7:36 AM

  • How do I read the XML string using Http response/request?

    When my HTTP POST action is perform, the action will return me a XML string as shown in the link, https://www.neteller.com/gateway/netdirectv4.cfm?amount=150.00&net_account=458415554241&secure_id=896365&bank_acct_num=6789&currency=USD&merchant_id=1234&merch_transid=1102&merch_account=john123&custom_1=test123&custom_2=test123&custom_3=test123&test=1
    The above XML string will be send back by one of the payment gateway.
    How do I retrieve all the attribute name and value from the XML string so that it can be stored in my database?
    The XML string will be as shown below:
    <?xml version="1.0" encoding="ISO-8859-1"?><netdirect version="4.0">
              <approval>yes</approval>
              <amount>150.00</amount>
              <trans_id>403070</trans_id>
              <error>none</error>
              <fee>4.35</fee>
              <time>{ts '2006-06-23 06:14:19'}</time>
              <firstname>Test</firstname>
              <lastname>Test</lastname>
              <email>[email protected]</email>
              <custom_1>test123</custom_1>
              <custom_2>test123</custom_2>
              <custom_3>test123</custom_3>
              <dafee>0.00</dafee>
              <client_currency>USD</client_currency>
              <client_amount>150.00</client_amount>
              <merchant_currency>USD</merchant_currency>
              <merchant_amount>150.00</merchant_amount>
              <fxrate>1.0</fxrate>
              </netdirect>

    How about parsing the XML? Check out JAXP.
    http://java.sun.com/webservices/jaxp/index.jsp

  • How can I read only a line of text from a file, line by line using Scanner?

    Here's the code I currently have for a program that finds a keyword from numerous files and prints every line in every file that has that keyword. The keyword is indicated by the first parameter in a command line and the files are every parameter after that. Right now, with the code I have, the program will not print multiple lines of each file if they contain the keyword. I am trying to solve this problem by figuring out a way to have a loop continue until an \n EOL character is found. I am not sure how to do this though. Here's the portion of code that I would like to change to do this. I need to add a condition somewhere after in.hasNext() I think to stop when it it hits a /n.:
    while (in.hasNext()) {
                        count++;
                        String nextWord = in.next();
                        lineOfText.add(nextWord);
                        if (nextWord.equals(keyword)) {
                            flag = true;
    import java.util.Scanner;
    import java.io.IOException;
    import java.io.FileNotFoundException;
    import java.io.FileInputStream;
    import java.io.PrintWriter;
    import java.util.ArrayList;
    public class Find {
        static ArrayList<String> lineOfText = new ArrayList<String>();
        static boolean flag = false;
        public static void main(String args[]) {
                   run(args);
        public static void run(String args[]) {
            try {
                PrintWriter out = new PrintWriter("output.txt");
                String keyword = args[0];
                for (int i = 1; i < args.length; i++) {
                    Scanner in = new Scanner(new FileInputStream(args));
    int count = 0;
    while (in.hasNext()) {
    count++;
    String nextWord = in.next();
    lineOfText.add(nextWord);
    if (nextWord.equals(keyword)) {
    flag = true;
    if (flag == true) {
    System.out.print(args[i] + ": " );
    out.print(args[i] + ": " );
    for (String s : lineOfText) {
    System.out.print(s + " ");
    out.print(s + " ");
    System.out.print("\n");
    out.println(" ");
    lineOfText.clear();
    out.close();
    catch (FileNotFoundException e) {
    System.out.println("file not found!");
    catch (IOException e) {
    System.out.println(e);
    Thanks

    Well, I thought I had this program finished, then I realized I need to match the keyword anywhere in the file(including within a word) and print out each line that "contains" the keyword in each file. So, I need some way of testing to see if the keyword is a part of each word and then flag the line that contains the keyword. Is there some method to do this? Thanks
    Here's the code I have now:
    import java.util.Scanner;
    import java.io.IOException;
    import java.io.FileNotFoundException;
    import java.io.FileInputStream;
    import java.io.PrintWriter;
    public class Find {
        static String line = "";
        static boolean flag = false;
        static boolean flag2 = false;
        public static void main(String args[]) {
                    run(args);
        public static void run(String args[]) {
            try {
                PrintWriter out = new PrintWriter("output.txt");
                String keyword = args[0];
                System.out.print("Searching for the keyword: " + keyword);
                out.print("Searching for the keyword: " + keyword);
                System.out.print("  in files: ");
                out.print("  in files: ");
                for (int k = 1; k < args.length; k++)
                     System.out.print(args[k] + " ");
                     out.print(args[k] + " ");
                     System.out.println("\n");
                     out.println("");
                     out.println("");
                for (int i = 1; i < args.length; i++) {
                    Scanner in = new Scanner(new FileInputStream(args));
    while (in.hasNextLine()) {
    line = in.nextLine();
    String[] splitLine = line.split(" ");
    for (int j=0; j < splitLine.length; j++) {
    if (splitLine[j].equals(keyword) && flag2 == false) {
    flag = true;
    flag2 = true;
    System.out.print(args[i] + ": " + line + "\n");
    out.println(args[i] + ": " + line);
    flag2 = false;
    System.out.print("\n");
    out.println(" ");
    out.close();
    catch (FileNotFoundException e) {
    System.out.println("file not found!");
    catch (IOException e) {
    System.out.println(e);

  • Search for a string in word document using VBA

    Hi,
    I am new to VBA. My requirement is that VBA code should find the path in the word document., some of the paths are present in the word document.
    search criteria should start with \\\\ and end with .doc. Could anyone please help me out on how to provide the search criteria and is there any predefined methods present.
    Thanks in advance.
    Thanks,.

    Apologies, the line
    Do While .Execute(FindText:=.Text = "\\\\*.doc", MatchWildCards:=True)
    should read
    Do While .Execute(FindText:="\\\\*.doc", MatchWildCards:=True)
    It will however only work for the document body. If the string is in a different story range you will have to loop through those story ranges e.g.
    Sub FindIt()
    Dim wdApp As Object
    Dim wdDoc As Object
    Dim oRng As Object
    Dim bStarted As Boolean
    Dim i As Integer
        On Error Resume Next
        Set wdApp = GetObject(, "Word.Application")
        If Err Then
            Set wdApp = CreateObject("Word.Application")
            bStarted = True
        End If
        On Error GoTo 0
        ActiveWorkbook.Save
        Set wdDoc = wdApp.Documents.Open("C:\Path\DocumentName.docx")
        i = 1
        For Each oRng In wdDoc.StoryRanges
            With oRng.Find
                .MatchWildcards = True
                Do While .Execute(FindText:="\\\\*.doc")
                    Range("A" & i) = oRng.Text
                    oRng.Collapse 0
                    i = i + 1
                Loop
            End With
            If oRng.StoryType <> wdMainTextStory Then
                While Not (oRng.NextStoryRange Is Nothing)
                    Set oRng = oRng.NextStoryRange
                    With oRng.Find
                        .MatchWildcards = True
                        Do While .Execute(FindText:="\\\\*.doc")
                            Range("A" & i) = oRng.Text
                            oRng.Collapse 0
                            i = i + 1
                        Loop
                    End With
                Wend
            End If
        Next oRng
        wdDoc.Close 0
        If bStarted Then wdApp.Quit
        Set oRng = Nothing
        Set wdDoc = Nothing
        Set wdApp = Nothing
    End Sub
    Graham Mayor - Word MVP
    www.gmayor.com

  • How do I compensate for only one ADDT ' tNG_config.inc.php file with many Registration pages to build?

    My dynamic site has a lot of different languages funneled into one website, using various cookies, url params, php includes, etc. all to obtain similar info in different languages. Thank you David Powers.
    It is working really well and now I’ve come to the Registration section. Okay, so registration isn’t all that hard; I could do most of it with the standard Dreamweaver set of tools. Alas, I really like much of what ADDT has to offer with welcome email messages and activation and such.
    Here’s the setup: Obviously, with many different language people, I have many different databases for them. I did that becuase we’re expecting a big audience and I really don’t want to have all those different language names in the same table. Furthermore, these tables, whereby the students will login, will also contain a lot of information about their work so again, don’t want to have one massive table. I’ve divvied them up into tables by language and I’m using those tables to keep track of them and their work.
    I want to use ADDT’s User Registration Wizard and I have looked at all the neat stuff in the Control Panel/Login Settings.
    Here’s my situation: I notice that when I’m done with the configuring of one of the registration pages, I’m asked if I want to upload the tNG_config.inc.php page and that it has changed since the last upload. I saved a copy of the _config.inc.php and did a new registration form with the same info and when done, I compared the two _config.inc.php files. As one would guess, there is a small difference in the Connection string to the databases  $tNG_login_config["connexction"] = "connString_Ital_db".
    My problem is that I have 13 of these registration pages to do but ADDT only has the one tNG_config.inc.php. That’ll work great for the one with which it is associated, but the others will obviously break. I’ve looked through the code in the Registration pages, to find the ADDT link to the tNG_config.inc.php file hoping to rename it Italian, Spanish, etc, but the name of the file does not appear in the Registration page.  I realize that ADDT Control panel is designed for use on one site, and can then be used on others, with the changes etc. But my site seems a little unique since so many sites are actually in one.
    Has anyone whipped this problem before? I just don’t understand why there is no link in the head code of the Registration page to let me change it and to create more config files with different names. Thanks for you help!
    [Moved by moderator to appropriate forum]

    Hi Brian,
    I just tried to check all of ADDT´s "includes" files for any internal references (read: "require" or "require_once" statements) to the file "tNG_config.inc.php". So far I can only see this file referenced in the file "tNG.inc.php" (within the "$KT_tNG_uploadFileList1" array).
    So what could this mean ? Maybe you´ll have to make copies of the the original "tNG.inc.php" as well and save them as, say, "tNG.inc_ital.php" file plus make sure that these copies internally point to a different "tNG_config_ital.inc.php" file -- because it´s always the first mentioned file which gets referenced from e.g. an ADDT login page (see the "Load the tNG classes" - part)
    I want to use ADDT’s User Registration Wizard and I have looked at all the neat stuff in the Control Panel/Login Settings
    The Control Panel will always update the main "tNG_config.inc.php" file, so any further modifications will have to become manually applied to the custom files you´re creating.
    Cheers,
    Günter

  • HT4759 Can I place documents created with Microsoft Office for Mac, eg. WORD, or .pdf files be stored in iCloud?  If so, how can I put them there?

    Hi,
    I am trying to learn how to use iCloud, would like to hsve it my documents on it, which are mostly created in WORD (part of Microsoft Office Suite for Mac) or .pdf files.  I don'r see how to get them into iCloud.  Actually I don't see how to place anything at all in iCloud other than contacts, etc.  I am not seeing how it can be usedul to me.

    I should have been more clear. You have to buy the iWork programs from Apple. They are available in the App Store.
    Pages: http://www.apple.com/iwork/pages/
    Numbers: http://www.apple.com/iwork/numbers/
    $20 each.
    The iWork programs are integrated with iCloud and work fairly automatically with it. iCloud is only intended for specific purposes and is not intended for general purpose storage.
    Dropbox is though, and it's free.

  • How to create schema for Header and Footer with pipe delimiter file BPEL11g

    Hi all,
    I have issule creating Schema for Header and Footer with body file .The file format is Pipe delimiter.The following format below like is...
    Softeware Components:File Adapter(Read) 11g,
    1|1211|000|577|5444
    1|0000|57|6988|4554|sfdgh|5448|3333|ituu|44445|55546|544|788|7788
    1|0000|57|6988|4554|sfdgh|5448|3333|ituu|44445|55546|544|788|7788
    1|0000|57|6988|4554|sfdgh|5448|3333|ituu|44445|55546|544|788|7788
    1|0000|57|6988|4554|sfdgh|5448|3333|ituu|44445|55546|544|788|7788
    1|0000|57|6988|4554|sfdgh|5448|3333|ituu|44445|55546|544|788|7788
    1|0000|57|6988|4554|sfdgh|5448|3333|ituu|44445|55546|544|788|7788
    1|4544|000|yted
    I hope get the sollution for this from this Forum..Please help me out..Thankyou.

    You mean how many rows or columns..?
    If coloumns means 5 and rows only one(1).

Maybe you are looking for

  • Question on GR/IR clearing - T/code F.19 (Urgent)

    Dear Guru, I have some questions on GR/IR clearing GR and IR have been done for a PO. I run F.19 for GR/IR clearing. Next, I run a customised report to check whether the GR/IR for this PO has been cleared. However, the detail is still resides in tabl

  • Date field on Selection Screen

    Hi All, I need to create Date field (From and To) in the selection screen. The Date format should appear as YYYY-MM-DD. I have defined this requirement as below. select-options: s_date for sy-datum no-extension default sy-datum. Due to above line, da

  • Workgroup Manager doesn't show groups in drawer

    OSX Server 10.6.8 on an Xserve. Trying to migrate (manually) a 10.5 setup to a 10.6 system. I exported WM users, then imported them. On the surface all looks well. On the 10.6 system, viewing the list of users, I select a user, then the Groups tab. I

  • Local pkg upload - "Component's architecture is different from destination

    machine" is the Publish Status message I get when trying to upload an x86 package in the x86 channel. This happens with multiple packages that have been running on systems for months but UCE doesn't like any of them. Any ideas?

  • SKF  Cost center  copied over Profit center

    Guys, How can I copy the data introduced on the cost center side (either actual or planned:   KB31n , KP46), to the profit center side (7KE5, 9KE5)? I have both cost center assesment cycles (KSU5), and profit center assessment cycles (3KE5) and inten