Jump to content
Sign in to follow this  
Frostman

While... Do... Not working - Please help!

Recommended Posts

Please someone,

Can you help me figure this out, i have a function which doesn't seem to work in ArmAII.

I've tracked the problem down to a while do loop, and made this simple function to bug test.

private["_i","_rawaddress"]

_rawaddress = [];
_i = 0;

while {_i < 10} do
{
     _i = _i + 1;
     _rawaddress = _rawaddress + [_i];
};
_rawaddress

However when run the function returns <null>, please for the love of god show me the problem (i'm tearing my hair out).

Share this post


Link to post
Share on other sites

Missing a ; at the end of this line:

private["_i","_rawaddress"]

Should be:

private ["_i","_rawaddress"];

You have to check Arma2.rpt now, as thats the only place it reports syntax errors.

Share this post


Link to post
Share on other sites

Nothing wrong at first glance (except perhaps a semicolon after private [...], tried that? ). Tell us how you're calling it.

Edit: In there late with the ";"

Share this post


Link to post
Share on other sites

That fixed it, Thank you :yay:

Where is the Arma2.rpt created? I'll need it to debug my larger function.

Share this post


Link to post
Share on other sites

Aside from the ";" I cannot see what's wrong either. I would avoid using "_i" as a variable name just because it's difficult to know what might be a reserved variable name. As you probably already know "_x" is a reserved variable name, so "_i" might be too. Give it a more meaningful (and thus hopefully less likely to be reserved) name.

*edit*

nebber mind :)

Share this post


Link to post
Share on other sites

In XP: Documents and Settings\username\Local Settings\Application Data\ArmA 2

or the equivalent in vista whatever that may be....

Share this post


Link to post
Share on other sites
That fixed it, Thank you :yay:

Where is the Arma2.rpt created? I'll need it to debug my larger function.

Mine is here:

C:\Documents and Settings\David\Local Settings\Application Data\ArmA2\arma2.RPT

arma2.RPT is one of the files permanently open in my Notepad++, always having a look at it :) It gets pretty big, but don't be afraid to empty it once in a while.

*edit*

Nebber mind - again :D

Share this post


Link to post
Share on other sites

Also, dunno if you know or not, but you do NOT need to private your variables the way you use them.

Variables can be used in the scope they are created in, and all sub-scopes of that scope. What is inside the brackets of your while-loop is a sub-scope of the main scope, and thus they will work perfectly well there without privating.

If you on the other hand would have initialized _rawadress inside of the while-loop, and then wanted to do something with it in the main scope after the loop, then you would need to private it, since otherwise it wouldn't exist in the main scope (other than as a possible return value from the while loop, depending on design)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×