Jump to content
rscott9399

deleting a portion of a string not an array

Recommended Posts

I have tried repeatably to delete the last few letters from a specific array. 

I can not get it to work with the subset function nor the delete portion of array function. 

 

Any suggestions?

Share this post


Link to post
Share on other sites

Your post is a bit confusing as you're interchanging string and array terms. Cleaning that up and posting a bit of what you've tried would help people give better feedback. It sounds like you're using primitives that would do what you want, so it would be helpful to see how you are using them.

Share this post


Link to post
Share on other sites

I dunno. Your question is not clear, but let me take a shot. This example deletes the last 3 elements of an array of strings. Don't forget that array indexes start at 0, not 1.

Screen Shot 2019-06-21 at 2.57.54 PM.png

Share this post


Link to post
Share on other sites

Michael, technically what you write is only true for an input array of exactly 5 elements. If you really always want to remove the last three elements the OP needs to use an Array Length node, subtract the number of elements he wants to remove from this length and wire that to the offset. In that case you can leave the size input unwired because it will default to the rest of the array.

Share this post


Link to post
Share on other sites
14 hours ago, Rolf Kalbermatter said:

If you really always want to remove the last three elements the OP needs to use an Array Length node, subtract the number of elements he wants to remove from this length and wire that to the offset. In that case you can leave the size input unwired because it will default to the rest of the array.

That's too complicated.  Just wire the 3 to the Length and leave the Index unwired.  Delete From Array will default to deleting from the end.

  • Like 1

Share this post


Link to post
Share on other sites

The OP didn't clarify his requirements so we could all be wrong. But ya, all you guys say is true. - Thanks.

My intent was to start the conversation, not to provide the best solution. I just wanted to show how the delete from array works and to provide some visuals.

Share this post


Link to post
Share on other sites

Okay for the heck of it here is my interpretation.  I read that as OP trying to remove the last few characters from each string in an array.  (also I read "few" as 3).  Also snippets might not be working so attached is a VI in 2018.

Example_VI.png.48ad7231593e3dd1d5991455f4de8d04.png

Remove Strings Test.vi

Share this post


Link to post
Share on other sites

Join the conversation

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

Guest
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.