Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
how to initialize an array in initialize method
arunkumarb
Hi All,
I want to declare and initialize an array in initialize method. is it possible? If so let me the syntax.
Thanks in Advance,
Arun
Find more posts tagged with
Comments
mwilliams
You could do something like, myArray = new Array();
Or
myArray = [];
What are you trying to do? Maybe I can help further.
arunkumarb
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="93755" data-time="1325869519" data-date="06 January 2012 - 10:05 AM"><p>
You could do something like, myArray = new Array();<br />
<br />
Or<br />
<br />
myArray = [];<br />
<br />
What are you trying to do? Maybe I can help further.<br /></p></blockquote>
<br />
<br />
Hi williams,<br />
Thanks for reply. I declared an array in initialize method. now I want to assign values to that array.<br />
how to assign values to that array.<br />
Thanks in Advance,<br />
Arun
mwilliams
What values are you trying to add to the array? Are they static values? Are you trying to create a dataSet? Are you grabbing values from the dataSet? Can you please explain your issue in more detail?
arunkumarb
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="93867" data-time="1326216224" data-date="10 January 2012 - 10:23 AM"><p>
What values are you trying to add to the array? Are they static values? Are you trying to create a dataSet? Are you grabbing values from the dataSet? Can you please explain your issue in more detail?<br /></p></blockquote>
<br />
Hi Williams,<br />
Thanks for your reply.<br />
<br />
Now i want to use an array in script. i do not know how to declare an array and how to initialize that array with static values like <br />
<br />
myArray[0]=1;<br />
myArrya[1]=2...etc.<br />
<br />
i want to write some script on Arrays. so Plz help me.<br />
<br />
Thanks in Advance,<br />
Arun
mwilliams
If you were wanting to put static values in an array, 1-10, you could do the following:
myArray = [1,2,3,4,5,6,7,8,9,10];
If you put this in your initialize method, you can then recall these values in expressions and script in your report.
myArray[0] would be 1
myArray[1] would be 2
etc...
If you wanted to populate the array with a field in your dataSet, you'd put the following in your initialize:
myArray = [];
Then, to populate it, you'd put something like the following in your onFetch script:
arrayLength = myArray.length;
myArray[arrayLength] = row["myField"];
This would fill your array up with the values in your dataSet field "myField".
Recalling the values would be the same as above.
Does this help? Let me know if you need more infomation.
arunkumarb
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="94285" data-time="1327099702" data-date="20 January 2012 - 03:48 PM"><p>
If you were wanting to put static values in an array, 1-10, you could do the following:<br />
<br />
myArray = [1,2,3,4,5,6,7,8,9,10];<br />
<br />
If you put this in your initialize method, you can then recall these values in expressions and script in your report.<br />
<br />
myArray[0] would be 1<br />
myArray[1] would be 2<br />
etc...<br />
<br />
If you wanted to populate the array with a field in your dataSet, you'd put the following in your initialize:<br />
<br />
myArray = [];<br />
<br />
Then, to populate it, you'd put something like the following in your onFetch script:<br />
<br />
arrayLength = myArray.length;<br />
myArray[arrayLength] = row["myField"];<br />
<br />
This would fill your array up with the values in your dataSet field "myField".<br />
<br />
Recalling the values would be the same as above.<br />
<br />
Does this help? Let me know if you need more infomation.<br /></p></blockquote>
<br />
<br />
hi williams,<br />
Thanks for ur reply ans its working fine. <br />
Now I want to perform some operations on that Array.<br />
E.g: for(i=0;i<=5;i++)<br />
{myArray
=i+5}<br />
how is it possible.
mwilliams
Can you explain more about what operations you want to perform on the array? Your above example would just change the first 5 values in the array to look like:
[5,6,7,8,9]
If that's what you're wanting to do, you already have the script above!