View Full Version : running a codeblock once (is global word buggy?)
claudiof 06-24-2009, 10:22 PM global string $run_once;
if (`window -exists BlahBlahNonExistent1`)
{
global string $run_once="yes";
};
print $run_once;
yes
//there isnt a windows such name but BlahBlahNonExistent1 print already assigned.
print $run_once assigns always "yes"
I was attempting to control to run block only once
is it possible ?
and what do you think of this weirdness of control flow ?
it assigns to "yes" however if is always false
|
|
berniebernie
06-25-2009, 07:33 AM
could it be that run_once was given a value at one point, without being cleared at the end ?
also, I'm not 100% sure, but I don't think you re-declare 'global string' inside of a block statement
claudiof
06-25-2009, 10:40 AM
I think the main problem not understood enough.
I mean if condition is false somehow $run_once is always "yes";
by another mean
global string $run_once="yes";
this line is always working without any control of "if" condition
this is not common for general language rules.
goleafsgo
06-25-2009, 01:06 PM
It looks like a bug. Split your string declaration/init into two separate lines and it should work.
eg.
global string $run_once;
if (`window -exists BlahBlahNonExistent1`)
{
global string $run_once;
$run_once="yes";
};
print $run_once;
GennadiyKorol
06-26-2009, 08:31 PM
If I remember correctly in earlier versions of Maya the interpreter would not run statements that both include and assign to a global variable. I remember I had to split into two statements as goleafsgo has shown to make it work.
CGTalk Moderation
06-26-2009, 08:31 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.