06-30-2015 10:06 AM
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
06-30-2015 10:13 AM
Tell us what you're trying to do instead of how you're trying to do it. There's probably a better way.
06-30-2015 10:14 AM
Make sure your strings in your input array are in "/" notation (using the right click menu).
Once you do that, also try "/r" or "/r/n".
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
06-30-2015 10:15 AM
Can you give us an example of what a typical input string is for you and what you want the outcome to be? The KnowledgeBase article linked below gives a good introduction on how to use that function.
http://digital.ni.com/public.nsf/allkb/B9DB9CCCE998D375862569130063D6B9
06-30-2015 10:16 AM
I don't even think it needs to be that complicated.
06-30-2015 10:19 AM - edited 06-30-2015 10:19 AM
It looks like he's just trying to split a tring in to lines and he's trying to do it using tokens.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
06-30-2015 12:33 PM
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.
06-30-2015 12:36 PM - edited 06-30-2015 12:37 PM
@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. 😉
06-30-2015 12:37 PM - edited 06-30-2015 12:42 PM
This will result in an array of the different lines that you can then iterate through in a For loop or something.
To elaborate, the Scan String for Tokens VI is the most similar to "strtok", but iterating through the same string over and over isn't really the most efficient way to do it. The Spreadsheet String to Array VI uses a specific delimiter (that doesn't change from token to token) and parses the string in to an array that is split using that delimiter.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
06-30-2015 12:46 PM
Sounds good. I will try that and see!