Custom Block Parameter names and Variable names

I need a bit of explanation on what I encountered with the block def below:

image

The "t" after Func-t in the join is a drop of the block parameter "t" in header.
The "t" after Var-t in the join is drop of the var "t" from variables list.

  • I set global var t to 99.
  • I click on TEST 22 block and get the result shown.
  • I click on var reporter t and see the old value 99, instead of 100.

I thought maybe it is taken as the local block parameter t.
But then it should have been 23, due to change by 1 block.

  • Why am I confused ?
  • Are block parameter names same as a global var not allowed ?

AND THEN:

  • I added image to the REPORT.
  • Clicked on TEST and got a result that I thought was more correct than the first time. Also indicating that any reference to "t" in the Block def is local.
    image

It seemed to me, until the actual image the "t" parameter value was not correct. Somehow, right after executing the add, it got corrected.

All subsequent clicks on TEST produced the same result shown in second pic.
And the result 23 and 23 without the add block.

Is there something else going on that I do not see and understand.

Please explain.

(OMG, I'm getting a heart attack)

What do you expect to happen? You're not telling me that you think by assigning some value to a global variable that happens to have the same name as a formal parameter to a function you're somehow ... I dunno ... testing the function, are you?

[edit]: Hang on, while I try to understand what you might be expecting...

Okay, let's see, you have a formal parameter that has the same name as a global variable. The inner scope eclipses the outer one, so inside the function body the variable t will always refer to the formal parameter, regardless where you peeled it off from. A variable is just a name.

I am trying to understand the testing result.
1st time is gave 22 and 22, instead of 23 and 23.
After I added t+1, it became correctly 23 and 24.

Why the heart attack !

Edit: i was trying to sort out the scopes of the same name vars and parameters.
As soon as it worked correctly (the second time after adding t+1), I understood that it was a local reference. That part is clear.

But getting 22 and 22 instead of 23 and 23 I do not get ?

(why medical conditions happen is a mystery :slight_smile:)

I think you might have discovered another bug. Let me investigate.
Thanks!

[edit:] I can't reproduce this. Are you sure you applied the changes before testing the function? I can't get it to reproduce your first screenshot.

Hi!
I can't reproduce it either.
I get 23!

Joan

The only change was the definition of the block.
I Applied and tested. If it was not applied I would not have gotten anything at all.
Once it got corrected on my PC, I could not fail it either.

But once earlier you told me about the Windows weirdnesses and asked to reboot etc.
So I will go through a full cycle of resets and rewrite the block in another instance and see if I can make it happen again.

Sorry to occupy your time in the middle of v6.

No worries, Turgut! I'd rather find errors sooner than later (even fear of them makes me gasp :grinning:)

OK, I tried this with a fresh reset / restart and the problem does NOT happen.
So this was another one of those Windows idosyncracies on my PC.
Sorry all.

Whew, thanks! Now I feel better :sweat_smile: