Re: Adding a string to string array's indexes with ruby; how
Posted: Wed Mar 11, 2020 7:54 pm
YesRJHollins wrote:Let me ask ... do you just enclose the whole thing into a new module, and then put that into the toolbox ?
DSP Robotics and FlowStone Graphical Programming Software Support and Forums
https://dsprobotics.com/support/
YesRJHollins wrote:Let me ask ... do you just enclose the whole thing into a new module, and then put that into the toolbox ?
Everyone's code earlier was great, but here is a simple module. I hope it helps.kortezzzz wrote:YesRJHollins wrote:Let me ask ... do you just enclose the whole thing into a new module, and then put that into the toolbox ?of course, I first name the enclosed module with my own key words, so whenever I need it, I can't do any mistakes. I'll find it. This may sound as a very primitive and non-elegant solution, but it works for me
Beautiful, Patrick!pshannon wrote: Everyone's code earlier was great, but here is a simple module. I hope it helps.
Open the module and a help file plus code is in there with a reference. Ruby is not my first language of choice, however, it is what we have for FS and it brings designs to the next level.
I love your attitude! You surely don't lack self-confidence, Mr Coolhackerpshannon wrote:Everyone's code earlier was great, but here is a simple module. I hope it helps.
Open the module and a help file plus code is in there with a reference. Ruby is not my first language of choice, however, it is what we have for FS and it brings designs to the next level.
Code: Select all
"text" << "newtext"Code: Select all
"text" + "newtext"Wow, I got the attention from the popular tula. I have read many of your posts and downloaded several examples from you. You know your code and FS very well. Thanks for the tip and I didn't know it made a difference in the ruby interpreter. I work in cyber security for the past 16 years and someone once called me "Coolhacker" and it stuck.tulamide wrote:I love your attitude! You surely don't lack self-confidence, Mr Coolhackerpshannon wrote:Everyone's code earlier was great, but here is a simple module. I hope it helps.
Open the module and a help file plus code is in there with a reference. Ruby is not my first language of choice, however, it is what we have for FS and it brings designs to the next level.![]()
I hope you don't mind, but there was a reason I usedand notCode: Select all
"text" << "newtext"It's a little trick to save some time. It adds up the longer the array is, so it's worth it. text + newtext tells Ruby to create a new string class with the combined text and newtext.Code: Select all
"text" + "newtext"
Whereas text << newtext tells Ruby to use the already existing class and just append newtext. That saves you the time and memory needed to create a class instance.
If you would change your module to do that as well, it will be a good tool for the toolbox.
I like that. You don't get such a nickname by accident!pshannon wrote:I work in cyber security for the past 16 years and someone once called me "Coolhacker" and it stuck.
We could use a lot more of your kind on the Ruby front. It seems lately there's only trog and I left to help. It can become a little too much at times. So, any other helping hand is welcome.pshannon wrote:It looked like someone really needed help with this.
I didn't spend enough time on your code, and that's why my tip didn't work as you would wish.pshannon wrote:I did try your suggestion for optimized code which is always welcomed. For some reason it kept adding more strings and produced unpredictable results. It did work well with the static arrays like you demonstrated, I wonder if the green string array outputs something different?