problem with GetCompVar - Forum

Forum Navigation
You need to log in to create posts and topics.

problem with GetCompVar

When I want to use GetCompVar  inside a subroutine it always crashes at runtime.

See my example if you click on button it is ok, if you click on function it is ko. The code is the same !

Any idea?

Uploaded files:
  • You need to login to have access to uploads.

Hi @phil78, I don't understand your sample app.
I have isolated the functionality and it works fine for me.
Please check the attached app.

Thank you!

Uploaded files:
  • You need to login to have access to uploads.

Hi @luishp thanks for reply.

Your test works with a simple variable while mine is with an array of objects.
In my example I initialized [MyObj1] and [MyTotal1] on another page to be sure that the variable was known in another page like in my application. Just put it on page-enter of the first page so you don't have to navigate.
My test shows that the same code called in a function or directly in the button does not have the same behavior. I guess when you click on GetCompVar function you crash too ?

@phil78 the problem is not related to GetCompVar. It's something regarding to the parameter [n].  I have just used another variable to get the value and it works now. Please check the fixed attached app.

Regards.

Uploaded files:
  • You need to login to have access to uploads.

Thank you @Luishp and sorry for the delay because I tried to understand without success why it does not work in my app.

it seems that we can't use directly the parameters without going through the variables, what is the reason? In the debug I see a ! that must disturb GetCompVar [total] [MyTotal[!n]] and GetCompVar [obj] [MyObj[!n]] .

This being in my real program, I assign the parameter in a variable inside the subroutine and I still get the error $App.tirage is undefined while the console shows that the original object is valid!

SetVar [nW] [nT]
consolelog "joueur J1G [MyT1(0).J1G] , nW [nW]"
While [nW] > 0
GetCompVar [tirage] [MyT[nW]]
Consolelog "tirage [tirage(0).J1G] joueurs [J1] [J2]"

it seems that we can't use directly the parameters without going through the variables, what is the reason?

@phil78 I'm not sure about the reason, but I discovered it some time ago when executing callback subroutines. It's probably related to global/local variable scope, but not sure. Anyway, once you know about it, it's easy to adapt your code.

This being in my real program, I assign the parameter in a variable inside the subroutine and I still get the error $App.tirage is undefined while the console shows that the original object is valid!

No idea, sorry. I have not faced similar situations nor have been able to reproduce it.

Regards.

@luishp I understand you especially when I copy the code blocks in another application I don't have the problem. Even the bug with the radio button and the neoradio class reappeared when I don't have it elsewhere!
Could the file be corrupted?

regards

Could the file be corrupted?

@Phil78 I think it is probably the browser cache showing you the old file version.
Please, press Ctrl-F5, once your app have been loaded, to force a a full reload and let me know if it works.
Regards.

Hi @luishp  After deleted cache, history, and cookies there is no difference ...

I will try to create a new app and copy paste the code.

Regards