Page 5 of 5

Re: two things array/ruby related

Posted: Sun Nov 03, 2013 5:23 am
by trogluddite
Here's a first attempt at a more modular approach...
2D Arrays 001.fsm
(3.38 KiB) Downloaded 820 times

There's a new Ruby class "Array2D" hidden away inside a small module, but I've tried to make it so that it can be "talked to" with relatively simple commands, and won't need fiddling with.
The main "mothership" module needs a lot of work still - green String/Array inputs etc. with "set row", "insert column" etc. triggers to make it like the green Array prim's. But the code in the little "breakout boxes" makes access relatively simple now.
I've tried to make the main array behave similarly to green arrays where possible - the array "grows" in the same way, without leaving 'gaps' in the data that return nonsense values. By choosing an appropriate "default" value, you can choose whether the input data is treated as Integer or Float numbers. or Strings.
If you get a Ruby error at load time, it's because I haven't added any "protection" yet - editing the input string box should make it go away.

NB) The rule with Ruby class modules is simple, but can be awkward to get right. When FS starts up, it scans through primitives and modules in the order that you added them. So to be sure of Classes getting loaded correctly they need to be inside the first module placed into the schematic. Sometimes, the only way to do this is to put the Class module into an empty schematic, and then copy/paste everything else in there.

Re: two things array/ruby related

Posted: Sun Nov 03, 2013 1:15 pm
by tester
Thanks for working on that one. :-) Will be useful for various tasks. Although it works... strange or not working? Need to check why/what. Looks that devs have a lot of work to do, before ruby modules becomes user friendly.

As for ruby class modules and their awkwardness. Shouldn't be there some way to "retrigger" them (like the afterload primitive is used), to get the correct order? Or question to devs: wouldn't be appropriate to add some "mark" that would determine which ruby modules are loaded before other ruby parts start?

Re: two things array/ruby related

Posted: Sun Nov 03, 2013 9:56 pm
by billv
trogluddite wrote:Here's a first attempt at a more modular approach...

Wow...lot of work here Trog..thanks for the effort and time spent...
Looks like a great approach......will have to study a bit....