|
|
While I would be in favor of a solution like PoD's, storing and
retrieving from an array is easy.
#declare num = 20;
#declare MyArray = array[Num];
#declare i = 0;
#while (i < num)
#declare MyArray[i] = i;
#declare i = i + 1;
#end
this stores the current value of i into the array at each position (so
MyArray[5] = 5) to get them out, simply do something like the following
#declare i = 0;
#declare Sum = 0;
#while (i < num)
#declare Sum = Sum + MyArray[i];
#declare i = i + 1;
#end
it is that simple.
Steve
Ken wrote:
>
> Jerry Anning wrote:
> >
>
> >
> > Just generate the random number separately, save it in a variable, and
> > use it in both places. For your shingling project, in order to
> > account for the variable positions of other shingles, you could either
> > save the random numbers in an array as you create them and sum the
> > correct row or column for the needed offset, or (bad idea) reset the
> > random number stream with the original seed and run the random number
> > through the needed number of iterations at placement time. If you are
> > crazy enough to do that, you will also have to reseed and iterate each
> > time in the placement loop. An array would be much better.
> >
> > Jerry Anning
> > clem "at" dhol "dot" com
>
> I understand how to use arrays but am unsure hot to pass a value to one
> for storage and later retrieval. A brief example would be appreciated.
>
> --
> Ken Tyler
>
> mailto://tylereng@pacbell.net
Post a reply to this message
|
|