Array, Loop or combo of both?

Discuss topics that apply across the products, such as the PocketC language, or development in general

Postby blhorn on Fri Dec 21, 2001 11:16 pm

Merry xmas all,
I am randomly generating a number from 0 to 21, and with this number, I need to also generate that amount randomly on another table. So for example if I had 5 I would need to randomly access that table 5 times without generating the same hit twice. Then with that done, I need to put those into a table to print to screen.
I have the first random down, and I can acces the second table onece and put it to screen, but how is it possible to access it numurous times? Would I use an array, a loop or a combination of both? And if someone has a small example that would be great.


Just a partial of what I am trying to do..
RAD0 is the first generated number (max 24)
RADT is what I need to access a number of times (this will be a list of 1000)

I need to get RADT into a table, I can get one in, but how do I go about adding multiples? I am using Cadditem & Csetfield. Is this correct?

After looking at the original code I posted I realized some of what I had done wrong. Here is what I have got so far.

<pre id=code><font face=courier size=2 id=code>//start if
RAD1 = RAD0 ;
while (rollrads) {
evt = event (RAD1) ;
RAD1 -- ;
if (RAD1<=RAD0) {
rollRT= random (21)+1 ;
switch (rollRT) {
case 1:
RADN = "000" ;
RADT = "Unearthly" ;
break ;
case 2:
RADN = "001" ;
RADT = "Seven cardinal virtues" ;
break ;
case 3:
RADN = "002" ;
RADT = "Doppelganger" ;
break ;
//of course there is more here
//removed for posting
}//end switch
puts (RADT+"\n") ;
//I can get this to output screen but how do I get it into Ctable (I can get one in using Cadditem, then do I use Csetfield for the rest and if so, what is the best way for multiples?
}//end while
if (RAD1 == 0) {
//RADT = "No radiations....................Yet!" ;
rollrads = false ;
}//end if
}//end if
}//end radiations
</font id=code></pre id=code>

Edited by - blhorn on 12/22/2001 04:09:47

Edited by - blhorn on 12/24/2001 08:51:05

Edited by - blhorn on 12/24/2001 08:53:10
Posts: 18
Joined: Fri Nov 23, 2001 10:07 pm
Location: USA

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest