Re: two things array/ruby related
Posted: Sun Nov 03, 2013 5:23 am
Here's a first attempt at a more modular approach...
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.
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.