SetLocalArrayString
Contents |
[edit] SetLocalArrayString(object, string, int, string)
Simulates storing a local string in an array.
[edit] Parameters
oidObject
Object to store the array on.
sVarName
Name of the array.
nVarNum
Position (index) in the array to store the variable in.
nValue
String to store in the array.
[edit] Description
Although this is hardly an array, it can be accessed like one, and can even be looped through. It works by creating a new local string object on whatever object you passed in through the parameters. This local string is called sVarName + nVarNum, so in otherwords if the following is executed:
SetLocalArrayString(oPC, "myarray", 1, "hello");
What actually happens is:
SetLocalString(oPC, "myarray1", "hello");
[edit] Remarks
Found in nw_o0_itemmaker.nss on line 20.
In essence, arrays are nice because they:
a) Allow for cleaner code, and
b) Allows you to make a simple loop statement to get many variables' values, rather than having to type a bunch of variable names yourself.
[edit] Known Bugs
None.
[edit] Requirements
#include " nw_o0_itemmaker "
[edit] Version
1.28
[edit] Example
//Sets 10 variables quickly on the PC, using a for loop. //myarray1 is set to "number 1", //myarray2 is set to "number 2", etc. #include "nw_o0_itemmaker" void main() { object oPC=GetPCSpeaker(); int nLoop; for (nLoop=1; nLoop<=10; nLoop++) { SetLocalArrayString(oPC, "myarray", nLoop, "number "+IntToString(nLoop)); } }
[edit] See Also
functions: |
author: Lilac Soul, editor: Charles Feduke, additional contributor(s): Graziano Lenzi