sakura_chan 9 Posted February 14, 2009 Is it possible to define a bunch of variables without having to define each one? like this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _a1 = 1; _a2 = 2; _a3 = 3; _a4 = 4; I want to have a looped statement instead of this clutter. Also, how could I select a variable (local) based on another number? <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _number1 = 21; _number2 = 24; _number3 = 30; _number4 = 42; for "_i" from 1 to 4 do { _object animate [format ["anim%1", _i], _number_i]; output needs to be: _object animate ["anim1, 21]; _object animate ["anim2, 24]; _object animate ["anim3, 30]; _object animate ["anim4, 42]; }; I currently use the format command to make the list of variables and then get the number or array from the config file because getnumber/getarray can call the variable using a string. I basically want the script to call the numbers from the config (8 classes with 11 numbers each) and store it in the script, and dynamically call the appropriate numbers from the main "while do" loop. Its not 100% necessary, but I do like smooth organized code. Please help! Share this post Link to post Share on other sites
dachevs 1 Posted February 15, 2009 for first question, you can do: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _i=0; for "_i" from 1 to 4 do { format ["a%1 = 1", _i]; }; for 2nd question, I think it needs to be like this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _i=0; _numbers = [21,24,30,42]; for "_i" from 1 to 4 do { call compile format ["_object animate [""anim%1"", %2]", _i, _numbers select (_i - 1)]; }; Share this post Link to post Share on other sites