Page 1 of 1

Some help with Trog's Super Text Box

PostPosted: Fri Sep 03, 2021 8:45 pm
by billv
Hi..Greetings from Down Under :D
I need some help. My ruby skills aren't good enough.
Trog has explained the code really well in this schematic, but I can't work it out :?
All I need is Sort 'trigger" for the QTY Column.The problem is how to make all the rows
sort the same way according to the values in the QTY Column... :?:
Super Text Box Problem.fsm
(11.72 KiB) Downloaded 607 times

Re: Some help with Trog's Super Text Box

PostPosted: Sat Sep 04, 2021 1:00 pm
by tulamide
I'm not sure I understood. Anyway, here's an external trigger, that sorts based on qty. The first time it's sorting low to high, the second time high to low.

If you wanted to know the general technique, it's :sort_by! of the array class.
Code: Select all
array = [
["John", "Doe", 20],
["Jane", "Doe", 18],
["Annie", "Thing", 34]
]
array.sort_by! { |obj| obj[2] }
##sorts the array of arrays based on the contents of their third items, here the age number##

Re: Some help with Trog's Super Text Box

PostPosted: Sat Sep 04, 2021 9:03 pm
by billv
:D Awesome..works perfect..thanks tulamide :)

Re: Some help with Trog's Super Text Box

PostPosted: Sun Sep 05, 2021 9:20 pm
by tulamide
billv wrote::D Awesome..works perfect..thanks tulamide :)

You're welcome :D

I just want to take the opportunity to point out, that this was only possible, because Trog, although having a large code base, has it structured very well, so that I could relatively easy follow his thoughts and layout of the code. That was even more important than the documentation!

Most people neglect that. Please don't. At one point sooner or later, you will need help with your own code. Make sure it is easily readable (for someone who knows Ruby). Stick to the conventions and styles, the Ruby community agreed on, and it will be so much easier to help you.

https://rubystyle.guide/