Declaring a variable after it has been declared


#1

Ah. This should be my 3rd quick question since I joined this forum.

As the title says. What will happen if you declare a variable after it have been declared, especially a *temp one?

I have a sub routine, and for some reason, it contains a single *temp command. That says, re-calling this sub routine will essentially re-declare the temporary variable.
And again for some reason, I found myself quite lazy to test it by myself :stuck_out_tongue_closed_eyes: (it’s 2 A.M… what am I doing late here?)

Anyway, is it okay? What will be happened if it isn’t?


#2

Test it and see. If you’re too lazy to test it, why should you expect others to test it out for you? If it’s something you know how to work out the answer, why don’t you do that and then share your result with us?


#3

If it’s that concerning of an issue, why don’t you just declare the temp variable earlier in the scene, then just have the subroutine set the variable? I can guarantee there’s no error for setting a variable when the variable has already been set.


#4

This. With this way of coding I never had a single problem with temp variables.


#5

Well, I just re-read my code and I think I found the solution. Since this variable only used in a *label, I think I can declare the variable just below the *label

Well…
Thank you everyone, for the motivations and suggestion :upside_down:


#6

Just tested this re-declaring issue (If not because of the decree of the pigeon :expressionless:)


The result?

  • Yes = *temp a 1
  • No = return to the choice cycle
  • Add 3 = *set a +1 (I know, it’s 1 not 3)
  • Done = *ending

I choose the {Add “3”} option multiple times, and the value goes up. When I choose {Yes} afterward, the value of the variable [a] returned to 1

Long story short, redeclaring a *temp variable is basically re- *set - ing the variable to it’s original *temp value.


#7

Lol I m not a programmer or code master just a simple game hacker and it’s not new to me when u first declare a value to a variable it will be it’s base value and any further changes will be made on the base .I hope u know about flow chart right there is a loop where u can possibly re adjust the value to it’s original rate .( And I know this because I try to crack your game stats and sometimes it will lead to error .Else it will lead to reset value to it’s original ie before my change ) :stuck_out_tongue_closed_eyes: