Jump to content

SliceString Revised


Wouter

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

Link to comment

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.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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