Computer Science Canada BlackJack help - Variable has no value |
Author: | JamesV [ Sat Jan 08, 2011 10:16 am ] | ||
Post subject: | BlackJack help - Variable has no value | ||
What is it you are trying to achieve? I am trying to create a simple game of blackjack What is the problem you are having? When I add more then 3 cards (Hit more then 1) to the users hand (which is an array), I am not able to calculate the total. I get variable has no value. Describe what you have tried to solve this problem Ive tried to move code out of the procedures, but I end up messing it up more because its easier to call code from a procedure when im using a GUI.CreateButtonFull. Ive also tried to determine if there is a problem adding more then 3 cards. FYI: When I call cards from the txt file, I simply have them in this format 1H 2H 3H 1D 2D 3D 1 = A 11 = J 12 = Q 13 = K
Please specify what version of Turing you are using Turing 4.1.1 |
Author: | Insectoid [ Sat Jan 08, 2011 11:23 am ] |
Post subject: | RE:BlackJack help - Variable has no value |
Why is your_cards an array of strings? That's just making more work for yourself. |
Author: | TokenHerbz [ Sat Jan 08, 2011 11:40 am ] |
Post subject: | RE:BlackJack help - Variable has no value |
your proc hit seems wrong, (From what i can see of it) and it could only be working for 2 cards because your specifically give those 2 cards the values which they don't get (or the 3rd card) from the proc hit. have you tried to manual enter the 3rd card in the way you did 1,2 under that proc? what happens if you try that? |
Author: | JamesV [ Sat Jan 08, 2011 1:08 pm ] |
Post subject: | Re: BlackJack help - Variable has no value |
Ok, thanks guys. I ended up switching the procedure hit too: procedure hit hitcount += 2 numberofcards += 1 your_cards (numberofcards) := deck (random_cards (hitcount)) put your_cards (numberofcards) your_total end hit And it fixed the problem. Thanks for your help ![]() |