LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

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

 

0 Kudos
Message 1 of 11
(3,869 Views)

Tell us what you're trying to do instead of how you're trying to do it.  There's probably a better way.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 11
(3,858 Views)

 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>   ---'


0 Kudos
Message 3 of 11
(3,856 Views)

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

Matt J | National Instruments | CLA
0 Kudos
Message 4 of 11
(3,850 Views)

I don't even think it needs to be that complicated.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 5 of 11
(3,847 Views)

It looks like he's just trying to split a tring in to lines and he's trying to do it using tokens.

 

Spreadsheet string to array.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 6 of 11
(3,839 Views)

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.

 

0 Kudos
Message 7 of 11
(3,779 Views)

@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.  😉

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 8 of 11
(3,767 Views)

Spreadsheet string to array.

 

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>   ---'


0 Kudos
Message 9 of 11
(3,763 Views)

Sounds good. I will try that and see!

0 Kudos
Message 10 of 11
(3,747 Views)