Jump to content
News about the LabVIEW Wiki! Read more... ×
Sign in to follow this  
Wouter

SliceString Revised

Recommended Posts

VI Name:

SliceString

Total VIs:

2

Description:

The slice string should in my opinion by revised. Currently it is not doing as the name implies it thus. Because it only fetches the subset of a string, which can already be done by the "string subset" function in LabVIEW, the only thing it really does is calculating the length. Because one gives 2 indices, i:j, then length is j-i.

My two VI's are different. They accept a array of indices and then slice them on those places and index the results in a array of strings. Further the other VI accepts a numeric input and then slices the string after each repetition. The end VI should be polymorfic. (The slice string by reptition is in fact the same as the StringToChar function.

Note:

-

Blockdiagram:

Slice string by indices

gallery_17774_56_21691.png

Slice string by repitition

gallery_17774_56_6448.png

What are you thoughts on this VI?


  • Would you like to see such a function in OpenG?

  • Can you optimize the code?

  • In which package should it be included?

  • Should it be rejected?

ps. the snippts are in 2011, the VI's in 2009

SliceStringByIndices.vi

SliceStringByRepetition.vi

Share this post


Link to post
Share on other sites

The slice string should in my opinion by revised. Currently it is not doing as the name implies it thus. Because it only fetches the subset of a string, which can already be done by the "string subset" function in LabVIEW, the only thing it really does is calculating the length. Because one gives 2 indices, i:j, then length is j-i.

I am unaware of the history of the OpenG Slice String VI (maybe someone else could comment) but you can see from the Context Help that is has Python origins.

Additionally, I know other languages, e.g js, has both a slice and substring function too.

And whilst you are correct that the end result could be obtained using either function (e.g. use either function to get 'BC' from 'ABCD') - each function has it's differences (and preferred use cases). E.g. Slice string accepts negative numbers to index backward from the end of the string etc...

However both work on Strings as opposed to String Arrays (as per your proposal) so (aside from the above) I think it would be better suggesting a new VI as opposed to revising and replacing the existing Slice String VI.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

By using this site, you agree to our Terms of Use.