Quote: "trying to write a simple program our GW2 guild"
I salute your choice of MMO. I play an Asura Mesmer and a Charr Thief.
The problem with your code is to do with variable scope. The scope of a variable is its "lifetime", or more simply is the lines of code in which it exists. Variables declared in functions exist only within those functions. Equally functions do not have access to variables declared outside themselves unless:
1. They are parsed to the function as parameters
2. They are explicitly declared as global
3. They are arrays and are not explicitly declared as local (arrays default to global)
So in your code, the Drawing() function tries to use the prize variable but prize is not a global. Therefore the line
print "The prize amount is ";prize/2
is actually creating a new variable called prize that is local to Drawing(), initializing it to 0 and then dividing it by 2 which of course gives 0.
To get your code working, I just modified it so that you parse all the necessary variables as parameters to the functions.
cls
REM Lottery Program for GW2
input "Enter Prize Amount: ",prize
input "Enter Total Number of Entries: ",entries
print "Press Any Key to Enter Entrants."
wait key
REM ================= Get Entrant Names
Dim lottery$(entries)
print "You must enter a name for EACH entry."
for a = 1 to entries
enterName(a)
next a
print "press key to continue"
wait key
Drawing(entries, prize)
wait key
end
function enterName(a)
input "Enter Name: ";lottery$(a)
endfunction
function Drawing(entries, prize)
rnd1=rnd(entries)
name$=lottery$(rnd1)
print "The Winner is "; name$
print "The prize amount is "; prize/2
print "Guild/New Pot amount is "; prize/4
endfunction
I can't say I really understand the logic here though lol. What happens to the 25% that doesn't go to the winner or back into the pot?
Also for future reference, watch your indentation. I've corrected it in the example above. The rule of thumb is that you should indent code within structure blocks that have a beginning and an end (e.g. if..endif, function..endfunction, for..next etc.).
Hope that helps.