Is Scan String for Tokens documented correctly?

I attempted to parse the following string using " as the only delimiter (no operators):
this "is a test" for "you and me"
The first call produced: "this " w/o the quotes.
I expected "is a test" w/o the quotes.
The documentation says the function will return tokens "surrounded by" delimiters. If this is not a bug, I think the documentation should be improved.
W. Brown

Thank you for commenting on the Scan String for Tokens documentation. We will look into this issue and try to make the documentation more clear about how this function works.
We're constantly striving to improve the documentation, so any specific suggestions you have are welcome. In the future, please send any comments on National Instruments documentation to [email protected] so we can address your concerns in a timely matter.
Kelly Holmes
LabVIEW Documentation Team
Kelly H
LabVIEW Documentation
National Instruments

Similar Messages

  • VISA and Scan string for tokens

    Hi there,
    I am currently developing a piece of software which needs to take in data from an Arduino board via the serial port and parse the input accordingly.
    I have the 2 pieces of code working perfectly well separately, but I can not seem to figure out why they are not functioning properly together.
    Just now, the input is being retrieved fine and passed into the Scan string for tokens method, but it is not being split on the tokens, it is just outputting the string as a whole.
    The input is in the form of 1:0 2:0 3:1 etc. so I am trying to split it on any spaces found.  If I attach a string to the Scan strings for tokens it works fine, just not when I am attaching the data from the serial port to it.
    Any help would be appreciated.
    Attachments:
    input manipulation.vi ‏16 KB

    Hi,
    In the output which you are getting from the serial port, is there space between 1:0 and 2:0 and 3:1? If there is no space between them, then it wont be able to scan for tokens and will output the whole string. I don't have the hardware here and so don't know what exactly is the output which you are receiving. Try to see in the read buffer indicator whether the tokens are seperated by a space or not.
    I have attached your vi after adding a small part in it. If the problem is with the spacing then this will work fine for 1:0 2:0 3:1.
    Regards,
    Nitzz
    (Give kudos to good Answers , Mark it as a Solution if your problem is Solved) 
    Attachments:
    input manipulation.vi ‏18 KB

  • Scan string for tokens

    Can anyone help me out on how to detect a new line using the scan string for tokens function? I am using the "\n" delimiter but it is not working
     

    Syntyche wrote:
    I opened a text file and display it on string indicator. The following is an example of my text file
    START
    SETMASS 5
    WAIT 5s
    SETVELOCITY 10
    WAIT 3s
    END
    So what I want to do is to obtain the string line by line.
    I am thinking I can use scan string for tokens with delimeter \n.
    So if i put this in while loop, in the first iteration, I would want the ouput to be START
    Second iteration: SETMASS 5
    Third iteration WAIT 5s. and etc....
    In C programming i believe this can be done by using strtok. So i want to have a similar function.
    See James' post above, which is what I was hinting at when I said it could be less complicated.  And that's why I asked WHAT you were trying to do, instead of HOW.  In this latest post, you show WHAT you wanted to do, and doing that in the first place would have made the thread a lot shorter. 

  • "Scan String For Tokens" weird behaviour

    I am trying to carry out the simple task of getting a string with
    comma delimiters and produce a string_array with the values in between
    the commas; this would simplify calling the different parts of the
    string.
    Example:
    INPUT: this,is,an,example
    OUTPUT: this|is|an|example (this would be an array of strings)
    Using a while loop with the two VI "Scan String For Tokens" and
    "Insert to array" should be enough to carry this task. I started
    using a FOR loop as the number of tokens I´ll be using is fixed.
    However I wanted to make the subVI more general by allowing any
    #tokens in the input string and using the token index with a WHILE
    loop to do this. The "token index" output from the "Scan String For
    Tokens" is said to be use
    d in a while loop to process the whole
    string.
    However,I´m getting -1 as an output even if I´ve got more tokens left
    and the while loop therefore exits.
    What am I doing wrong?
    Should I use -2 as the comparison to decide whether I´m at hte end or
    not of the string?
    Cheers and TIA

    Check the offset for -1, not the token index. (See attached image). If course if this is a multiline string, the you also need /n etc as delimiter.
    If the string ends in a delimiter, you need to clip the last array element. I usually use "reshape array" with the output from [n] as input.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    ScanForTokens.gif ‏17 KB

  • Scan string for "returns"

    Hi,
    I have a multi lined string and want to put it as list into a listbox (i
    did it with a for loop and the "i"attached to the line index of the
    "pick line" vi) but now a have let my for loop know how many rounds it
    must do! How can scan a multi lined strings for "number of lines"?
    Regards Thijs

    Thijs,
    Use the "Spreadsheet String to Array" function (in string functions). Wire
    it as follows:
    format string: string constant containing "%s"
    spreadsheet string: your string
    array type: (empty) array string constant
    delimiter: string constant containing enter ("\n" with string in code
    display mode)
    The output "spreadsheet" is an array with strings that can be wired to the
    attribute node of the listbox.
    Important notice: \n is not the same as \r ! If your string comes from a
    ..txt file, this can cause unexpected results!
    Regards,
    Wiebe Walstra.
    AIR technical Automation.
    By the way, Thijs. If your in the Nederlands, maybe you'd like to visit our
    annual LabVIEW meeting, PierVIEW. This also applies to the rest of the
    group. Check out www.air.nl, and follo
    w PierVIEW 2001.
    AIR technical Automation
    www.air.nl
    "Thijs Boeree" wrote in message
    news:[email protected]..
    Hi,
    I have a multi lined string and want to put it as list into a listbox (i
    did it with a for loop and the "i"attached to the line index of the
    "pick line" vi) but now a have let my for loop know how many rounds it
    must do! How can scan a multi lined strings for "number of lines"?
    Regards Thijs

  • Scan string for computer user name

    Good morning NI Forums,
    I need direction on a file path scan. I'm trying to get to the user name on any system, primarily XP or 7. I'd like to compare the user name from the "Get System Directory" VI with a constant user name.This way I can pass that to a case structure and close LabVIEW if the computer is logged into the wrong user (there are network read/write permissions which is why I need to control where the program isrun from). Any suggestions for the format string constant or maybe a better mouse trap?
    I've attached my VI for reference.
    Thanks!
    Tyler C. | Certified LabVIEW Associate Developer
    Solved!
    Go to Solution.
    Attachments:
    Check Computer Name.vi ‏12 KB

    I don't have LV2011.
    Have you seen this Knowledgebase article?
    Programmatically Retrieving a Windows User Name in LabVIEW
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness

  • Scanning string for uppercase letters

    Hey guys just a simple question that i'm stuck on. im working on a program and i need to scan a string to see if it has uppercase letters. the only thing i know about that even seems helpful is isUppercase but im not sure how i'd use it. i'm basically generating a sentence form categories which are in uppercase and need to expand the sentence as long as there are categories left. id appreciate any help! Thanks!

         String  ts = "i Have a capital";
         boolean hc = false;
         for (int i=0; i < ts.length(); i++)
              if (Character.isUpperCase(ts.charAt(i)))
                   hc = true;
                   break;
         System.out.println(""+hc);

  • Scan String Token Problem with leading Tokens

    Hi, I'm using the scan string for token to read in a string of tokens that contain a leading "*" char in front of each string and terminates when the token index = -2. This works great if I have say *12345*1234 and so forth, but if there is bad data, say 1234 without the leading "*" in front, the token index return value is still -1 and it returns data which I read in thinking it found the "*". Maybe I shouldn't use the string for token function since it's probably just designed for ending tokens and not data with leading tokens. Is there a way to make this work properly or should I use another method to search for leading tokens in a string?
    Thanks.
    Solved!
    Go to Solution.

    Here.  Try this one.  It does the same thing and uses exposed functions.
    The string functions look for something to mark the end of a string.  All languages that I know of do this.  So, like I said, remove the first element.  I recommend the Subarray function with the index set to 1 and length unwired.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines
    Attachments:
    Parse Message.png ‏10 KB

  • String of letters to 1-D Array of strings for spreadsheet

    What I would like to do is be able to take this string as it is the A's and B's that are being generated as the program runs,
    I would like to take this string and get it into file in delimited tabs just as the numbers are. If there is a created 1-D array of
    strings that works, but that is controlled on the front panel, I would like to create this from data that is comming in. In other words
    I am stuck on how to create a 1-D array of Sting from the string value comming in. I want to do this so that I can get all the different
    values A's or B's into the different tab fields. As it is they are comming all up in the first column and not "tabbing" Please see the
    attached file in the rows 5 an
    d 7.
    Thanks,
    Brian
    Attachments:
    Array_of_strings_to_spreadsheet2.vi ‏28 KB
    Turn_data1.xls ‏1 KB

    Brian
    You need to convert your string to contain single tabs as separator. The problem is that your string is "dirty", i.e. it contains a variable amount of spaces to seperate the items. If you strictly had single space separators, you could just replace all spaces with tabs.
    "Scan string for tokens" by default does not allow empty tokens, thus takes care of the multiple spaces.
    The attached simplified code assumes a fixed number of items (12), if this is a variable, you need to use a while loop and sense the end of the input string. Let me know if this is clear.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    StringToArrayofstringsToSpreadsheetstring.vi ‏21 KB

  • Labview novice with a question about scanning strings

    Hello, I'm a research assistant tasked with taking data received via TCP-IP and plotting it. I've had a couple of problems, probably because I've never used Labview before.
    The data is sent in sets of six values separated using semicolons as delimiters, for example
    "0.086842;0.00020341;0.00039838;-0.14057;-0.12614;​-0.1327;" is one such data set
    Receiving these strings through TCP connection is working just fine, however I just noticed that after passing a string such as my example into a 'Scan String for Tokens' block, the negative signs are dropped from the latter three values. I assumed it has something with setting '-' as an operator, but simply wiring negative sign in as an operator didn't change anything. I know there has to be a way to retain my negative signs, but I can't figure it.

    Is this what you need?
    Attachments:
    SNAG-002.jpg ‏91 KB
    SNAG-003.jpg ‏20 KB

  • JAXB unmarshalling error for " " token as part of xsd:string type element

    JAXB unmarshalling error for "<" token as part of xsd:string type element
    We are getting a JAXB unmarshalling error:
    while processing the following <condition> tag which is of type xsd:string
    <condition> x < 100 </condition>
    The error is probably happening due to "<" token as a part of string type.
    xml.bind.JAXBException: Unexpected error in Unmarshalling
    at oracle.xml.jaxb.JaxbUnmarshaller.unmarshal(JaxbUnmarshaller.java:224)
    Any ideas how to resolve this issue?
    Note
    <condition> x > 100 </condition> is getting unmarshalled successfully by JAXB unmarshaller.
    Thanks

    Hi,
    Did you tried to put & lt; (without space) instead of < ?
    Best Regards,
    Paweł

  • ScanFile with scanning string modifier %s[in]

    For skipping over non-numeric characters by reading ASCII files I used to write, e.g.
    ScanFile (fhandle, "%s[i8]>%f", &x);
    This method works well with CVI 5.0 to 8.11 but no more with CVI 2009 and 2010.  I have modified my old code using other scanning string modifiers:  
    ScanFile (fhandle, "%s>%s[dt#]%f", &x);    or  
    ScanFile (fhandle, "%s>R1= %f", &x);
    The first one does not work with a string like “R1=200”.  The second requires the exact string and is more inconvenient.  Although the modified code works well now with CVI 2009, I would like to know why the scanning string modifier [in] does not work with CVI 2009 and 2010. Is there something wrong in my code, is it a feature of the new versions of CVI or is it a bug? How about CVI 2013?    

    Thank you very much for your reply.
    I would not use "%s[i8]>%f" to read the number 200 in string "R1=200".  I just wanted to take this string as an example to say that I couldn't simply change all of  "%s[in]>%f"s  in my code to  “%s>%s[dt#]%f"s, somewhere I had to use a quite inconvenient "%s>R1= %f". Therefore I do hope that "%s[in]>%f" works by a new version of CVI.
    In my code I use a lot of Scan (string, "%s[in]>%f", &x) and all of them work always correctly, also with CVI 2009-2010. But none of ScanFile (fhandle, "%s[in]>%f", &x) works with my CVI 2009, they work only with earlier versions.. That’s very strange to me as I couldn't find in the documentation/Help of CVI 2009-2010 a description that "%s[in]>%f" should not be used with the ScanFile function,
    My further tests showed that this problem seems to be related to CVI Run-time.  By reading the same ASCII file, the same executable created by CVI 8.11 works with CVI Run-time 8.1 but does not with Run-time versions 9.0 to 10.0.1.419.

  • Using Strings and tokens . . .

    Hello,
    I was wondering if anyone could help me out with this problem(s). I'm designing a java program that (when a statement is typed in by a user) (1) tells you if it's a sentence, question, or exclamation, (2) it gives you the total amount of words in the statement, (3) tells you the longest word in the statement, (4)and also outputs the number of words that contain 1-3 characters. So far, i've been able to figure out how to do (1) and (2), but I'm really stuck on (3) and (4). Could someone please take a look at my program and tell me what I'm doing wrong. Thanks, Ana : )
    // ProgramTwo.java Author: Ana
    // Program Two. Demonstrates the use of strings and tokens.
    import java.util.Scanner;
    import java.io.*;
    import java.util.StringTokenizer;
    public class ProgramTwo
    // Prints a string and various mutations of it.
    public static void main (String[] args)
    Scanner scan = new Scanner (System.in);
    System.out.print("Enter a statement >");
    String myString = scan.nextLine();
    String oneWord;
    if (myString.endsWith("!"))
    System.out.println("Your statement ends with an exclamation.");
    else
    if (myString.endsWith("."))
    System.out.println("Your statement is a sentence.");
    else
    System.out.println("Your statement is a question.");
    StringTokenizer st = new StringTokenizer(myString);
    System.out.println("There are " + st.countTokens() +
                   " word(s) in your statement.");
    st = new StringTokenizer(myString);
    while (st.hasMoreTokens())
    oneWord = st.nextToken();
    if (oneWord.length() <= 3)
    System.out.println(oneWord); //supposed to determine the number of words that contain up to three
    //characters
    String longestWord = "";
    while (st.hasMoreTokens())
    String w = st.nextToken();
    if (w.length() > longestWord.length())
    longestWord = w;
    System.out.print(longestWord); // It's supposed to determine the longest word in the statement
    }

    Hey Guys,
    I just wanted to thank all of you who responded to my message. With your help, I was able to figure out a bunch of other stuff. ChuckBing, I replaced some parts like you said and it worked like a charm! KPSeal, you brought up a good point, I doubled checked with my instructor and he said it was Ok for me to leave that part as is. Lutha, thanks for your input. I was just wondering, is Python similar to Java? I've never heard of it before, then again I've never heard of Java until a couple of months ago : ) Anyways, thanks again!! Ana : )
    By the way, here's how my program came out.
    // ProgramTwo.java Author: Ana
    // Program Two. Demonstrates the use of strings and tokens.
    import java.util.Scanner;
    import java.io.*;
    import java.util.StringTokenizer;
    public class ProgramTwo
    // Prints and groups various word types and amounts.
    public static void main (String[] args)
    Scanner scan = new Scanner (System.in);
    System.out.print("Enter a statement >");
    String myString = scan.nextLine();
    String oneWord;
    if (myString.endsWith("!"))
    System.out.println("Your statement ends with an exclamation.");
    else
    if (myString.endsWith("."))
    System.out.println("Your statement is a sentence.");
    else
    System.out.println("Your statement is a question.");
    StringTokenizer st = new StringTokenizer(myString);
    System.out.println("There are " + st.countTokens() +
                   " word(s) in your statement.");
    int shortWordCount = 0;
    int medWordCount = 0;
    int longWordCount = 0;
    String longestWord = "";
    String shortestWord = "";
    while (st.hasMoreTokens())
    oneWord = st.nextToken();
    if (oneWord.length() <= 3)
    shortWordCount++;
    if (oneWord.length() >= 4 && (oneWord.length() <= 6))
    medWordCount++;
    if (oneWord.length() >= 7)
    longWordCount++;
    if (oneWord.length() > longestWord.length())
    longestWord = oneWord;
    if (oneWord.length() < shortestWord.length())
    shortestWord = oneWord;
    System.out.println("The shortest word is " + shortestWord + ".");
    System.out.println("The longest word is " + longestWord + ".");
    System.out.println("There are " + shortWordCount + " short words.");
    System.out.println("There are " + medWordCount + " medium words.");
    System.out.println("There are " + longWordCount + " long words.");

  • JRE Uninstall string for v7 all the same - but do not work

    We have multiple Windows 7 machines running v7u1 thru v7u10.
    I found the uninstall string and was able to run MsiExec.exe /X{26A24AE4-039D-4CA4-87B4-2F83217010FF} on my own machine to remove the software successfully.
    In looking at u6,u7,u9 and u11 installations, I noticed the Uninstall Strings are exactly the same. But when ran on those machines, the system states "This action is only valid for products that are currently installed".
    However, I can remove the version from the Control Panel.
    So what are the correct uninstall strings for v7u1 thru v7u11?

    All of our users are local admins and tend to install whatever. This leads to a messy environment and we don't always know which version of Java is installed. So, to address that, I created a small script that scours 'HKLM\software\microsoft\windows\currentversion\uninstall' for Java entries, reads the uninstall string then runs the reported uninstall string. The assumption here is that the uninstall string will be an MSI command. (All the machines & versions of Java used the same format.)
    This is a Windows 7 Enterprise (32-bit) environment, but the script also works on 64-bit installations of Windows 7 Enterprise.
    I've tested this with 7u11 and went as far back as 6u21. It should work with just about any version that uses MSI for uninstalling.
    @echo off
    setlocal enabledelayedexpansion
    echo. & echo Checking for Obsolete Versions of Java...
    for /f "usebackq tokens=*" %%a in (`reg query HKLM\software\microsoft\windows\currentversion\uninstall`) do (
         rem echo a is %%a
         for /f "usebackq tokens=2*" %%b in (`reg query "%%a" /v DisplayName 2^>nul ^| find /i "java"`) do (
              rem echo b is %%b
              rem echo c is %%c
              for /f "usebackq tokens=3,4" %%d in (`reg query "%%a" /v UninstallString 2^>nul`) do (
                   echo.     Removing %%c
                   rem echo d is %%d
                   rem echo e is %%e
                   set uninstallcmd=%%e
                   set uninstallcmd=!uninstallcmd:^/I=^/X!
                   rem %%d %%e /qb-
                   %%d !uninstallcmd! /qb-
    :end
    endlocal
    Standard Dislaimer:*
    Neither I nor the respective owners and/or maintainers of Oracle make representations about the suitability of this software for any purpose. This material is provided "as is", with absolutely no warranty of the attached items whatsoever, whether express, implied, or statutory, including, but not limited to, any warranty of merchantability or fitness for a particular purpose or any warranty that the contents of the item will be error-free. Any use is at your own risk. Blah blah blah.

  • Thunderbird fails to send email when "Scan email for junk mail" option is checked in Server Admin

    I have 2 clients that need to send mail through my server, one Mac and one Windows. The Mac uses apple mail and the Windows machine uses Thunderbird.
    Apple Mail will send fine, it is set up for "Use Default ports 25, 465, 587" and "Use SSL" and "Authentication: MD5 Challenge-response".
    Thunderbird refuses to send and I don't even see any errors showing up in the Console on the OS X server under smtpd entries.
    If I uncheck the "Scan email for junk mail" option on the server, then Thunderbird will send fine.
    Thunderbird is set up as: "smtp port 587 (default)" "connection security: STARTTLS" "Authentication method: Encrypted Password"
    May or may not be relevant: I use virtual domains as well as aliases.
    Server: Mac OS X Server version 10.5.8

    Solved it, looks like maybe the smtpd settings for sasl authentication may not have been correct. I followed everything in http://osx.topicdesk.com/content/view/38/41/ the "Frontline Spam Defense for OS X server" guide and now can send mail just fine from Thunderbird Winodws and from Apple Mail.

Maybe you are looking for

  • How can I fix this recurring horizontal gap in a scrolling frame?

    I'm having trouble with scrolling content in a text frame. When I view the folio on the iPad, there's a white line that appears at intervals exactly spaced to the height of the frame. So if my frame is 700 pixels high, there's a white line that spans

  • Mac address - mac mini

    does anyone know how to find the mac address[not ip address] for a mac mini? i need its mac address to connect to a network?

  • Email Setting

    I have an issue with my BB curve 9300. When I first bought it, I was able to setup my mail (hotmail) successfully. Then I decided to add another email (Yahoo mail) but it is prompting Username and password for email setting. Ever since,  I have been

  • Sounblaster live driver prob

    Hi, I installed my soundblaster li've on windows xp, but it doesn't work properly: Actually it works when it wants... this morning i was listening music, the sound was perfect for 0 minutes but after i could hear unpleasant scratch sounds periodicall

  • Need advice:8800 Arte Spoilt in less than 1 week

    Can any one pls advice me what should i do as my new 8800 Arte mic not working 2 day after i bought it on 23rd Dec 2007.As the service center in singapore disagreed to change me a set but only change my PCB leaving me having a S$1888 phone with diffe