I need help on making this code smaller
Author |
Message |
blackwhite
|
Posted: Tue Jul 13, 2004 3:57 pm Post subject: I need help on making this code smaller |
|
|
code: | for x : 1 .. value (1)
ticketid (x) := username (1)
end for
for x : value (1) .. value (2)
ticketid (x) := username (2)
end for
for x : value (2) .. value (3)
ticketid (x) := username (3)
end for
for x : value (3) .. value (4)
ticketid (x) := username (4)
end for |
I'm using this to make a random raffle draw for myself, but obviously this will only work if there are exactly 4 people. I would have to manually add code for it to work for more, and so I need it to use the amount of people (variable name "memnum").
In this code, I'm basically assigning each member to the ticket number they bought, so i can use a random number and find the ticketholder. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
AsianSensation
|
Posted: Tue Jul 13, 2004 7:16 pm Post subject: (No subject) |
|
|
code: | value (0) := 1
for i : 1 .. 4
for x : value (i - 1) .. value (i)
ticketid (x) := username (i)
end for
end for
|
make sure when you declare value, it is an array with lower bound 0. |
|
|
|
|
|
blackwhite
|
Posted: Wed Jul 14, 2004 11:38 am Post subject: (No subject) |
|
|
thanks a lot. i tried something like that, but it didn't work for some reason, and it got confusing with all my variables, so i just restarted. |
|
|
|
|
|
|
|