Ruby Issue: Draw and Init

For general discussion related FlowStone
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Ruby Issue: Draw and Init

Post by tulamide »

If a view is connected to the Ruby editor, when starting the schematic (and probably any exports also) the 'draw' method is called before the init method. A simple test will convince you, see attachment.

In my spline class example 2, I can resolve the issue by calling init from within the draw method, which should convince everyone who wasn't from the attached test.

This renders 'init' pretty much useless. Luckily, you can also initialize by just placing the initializing code at the very beginning of the Ruby editor, without defining an init method. No need to call init from the draw method then.

Thought you should be aware of it!
Attachments
order_issue.fsm
shows that 'draw' is called first when opening this schematic
(360 Bytes) Downloaded 802 times
"There lies the dog buried" (German saying translated literally)
Exo
Posts: 426
Joined: Wed Aug 04, 2010 8:58 pm
Location: UK
Contact:

Re: Ruby Issue: Draw and Init

Post by Exo »

Thanks for pointing this out and giving a solution.

I have noticed that too, it is rather odd and doesn't make much sense!
Flowstone Guru. Blog and download site for Flowstone.
Best VST Plugins. Initial Audio.
Tronic
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: Ruby Issue: Draw and Init? not true

Post by Tronic »

Your test is not very correct, look at this:
order_issue_not_true_issue.fsm
(427 Bytes) Downloaded 833 times

The problem that you have with your class Spline is that you must always load the modules that contain the classes, before any other modules, otherwise your class when the module invokes it, does not yet exist in memory.
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Ruby Issue: Draw and Init? not true

Post by tulamide »

Tronic wrote:Your test is not very correct, look at this:
The attachment order_issue_not_true_issue.fsm is no longer available

The problem that you have with your class Spline is that you must always load the modules that contain the classes, before any other modules, otherwise your class when the module invokes it, does not yet exist in memory.

I'm sorry, but you're not true. See, the watch method only gets triggered when the method it's in is also triggered. That's why you get the impression of a regular order, since after the first draw, the order is correct (draw, init, draw). The spline class is an expansion of the ruby edit class, any access to the class forces ruby to build it if not yet existant. That's why you have no issues at all when initializing at the very beginning of the editor, without creating an 'init' method.

My schematic on the other hand raises an error whenever one of the methods gets called, whatever is the first. No Spline Class involved at all!

See the attached schematic without your 'afterload' prim. (draw gets called 3x, init 1x)
Attachments
order_issue_not_true_issue.fsm
(417 Bytes) Downloaded 828 times
"There lies the dog buried" (German saying translated literally)
Tronic
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: Ruby Issue: Draw and Init

Post by Tronic »

Unfortunately I can not agree to your idea,
because if the method "Init" was not the first to be triggered,
would not be initialized the variable with which you observe the results,
you're considering the number of trig happened, but the method "draw" shows a longer time,
compared to that reported by the method "init",
so for me the order of execution is correct.
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Ruby Issue: Draw and Init

Post by tulamide »

Tronic wrote:...so for me the order of execution is correct.

That's exactly what I said in my last post. You get the impression, because after the first 'draw' call, the order indeed is correct. There's just the issue that draw gets called a first time before 'init'

Here's another schematic, and if this one doesn't convince you, I don't know what else. :)

Make sure Flowstone is not running, then open it with the schematic. After load, just click on the trigger button and be surprised ;)
Attachments
order_issue 2.fsm
(436 Bytes) Downloaded 855 times
"There lies the dog buried" (German saying translated literally)
Tronic
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: Ruby Issue: Draw and Init

Post by Tronic »

Sorry, but not...
trig order still
Method:
1) init
2) event
3) draw

try to switch OFF the module and retrig....
surprise....
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Ruby Issue: Draw and Init

Post by tulamide »

Tronic wrote:Sorry, but not...
trig order still
Method:
1) init
2) event
3) draw

try to switch OFF the module and retrig....
surprise....

Tronic, I see you misunderstand the whole issue. We talk past each other. Of course, it works after retrig. That's what I am saying the whole time! You don't even need to switch it off, just enter something in the editor, for example a space anywhere and retrigger. But the issue is not that it works afterwards, the issue is that, as you can clearly see in the last schematic I posted, 'init' doesn't get called, while 'draw' is called - at the very first time.

I don't know how I could explain it in another way so that it might get clearer.
"There lies the dog buried" (German saying translated literally)
Tronic
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: Ruby Issue: Draw and Init

Post by Tronic »

your preview test is not correct, it every time reset the variable when you trig the module,
because method init is called only the first time, so the variable @a_init is lost(is reset) in your case.
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Ruby Issue: Draw and Init

Post by tulamide »

Tronic wrote:your preview test is not correct, it every time reset the variable when you trig the module,
because method init is called only the first time, so the variable @a_init is lost(is reset) in your case.

Wrong again, I don't trig the module, I trig the event method. Also, your thought would also reset @a_draw

But I'll leave it as it is. I've done my best. :)
"There lies the dog buried" (German saying translated literally)
Post Reply