Results 1 to 8 of 8

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

  1. #1

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

    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.

    Code:
    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).

  2. #2
    Missing a ; at the end of this line:

    Code:
    private["_i","_rawaddress"]
    Should be:

    Code:
    private ["_i","_rawaddress"];
    You have to check Arma2.rpt now, as thats the only place it reports syntax errors.

  3. #3
    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 ";"

  4. #4
    That fixed it, Thank you
    Where is the Arma2.rpt created? I'll need it to debug my larger function.

  5. #5
    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
    Fire And Smoke for ArmA2: JTD_FireAndSmoke v0.2

    For better future effects addons, please vote for this ticket.

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

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

  7. #7
    Quote Originally Posted by Frostman View Post
    That fixed it, Thank you
    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

  8. #8
    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)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •