
-----------------------------------
cam_1011
Fri May 29, 2009 10:26 am

Turing Menu Help, Button Interface... Gr 12 project, need help please...due soon
-----------------------------------
What is it you are trying to achieve?
A Menu that would allow the user to click a button to go to a blackjack game or the other button to go to a poker game 


What is the problem you are having?
I dont know how to make the program so when I click blackjack, it will read my settings and use my variables to run it 


Describe what you have tried to solve this problem
I have looked at many menu options, tried putting all the blackjack information in the blackjack main procedure which it didnt want 


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)

import GUI 

setscreen ("grpahics: 300;125")

procedure blackjack
put" You have selected blackjack"
delay(2000)
cls

end blackjack

procedure poker
end poker

var button1: int :=GUI.CreateButton(25,25,0,"Blackjack",blackjack)  
var button2: int :=GUI.CreateButton(300,25,0,"Poker",poker)

loop
if GUI.ProcessEvent then
end if
end loop

%These are the variables used in the blackjack game
var points, cpoint : int
var card1, card2, card3, card4, card5, cardc1, cardc2, cardc3, cardc4, cardc5 : int
var name : string
var choice, temp, total, money, bet2, win, num1, under21, totalc, num2, num3, num4, num5, num6, shuffle : int
var choice2, choice3, choice4, choice5, choice6, choice7, col1, col2, col3, col4, col5 : string
var key : array char of boolean
var time2 : string
var nameTextField, addressTextField : int
var cardq : int



View.Set ("graphics:350;300")

%setting variables with default values
card1 := 0
card2 := 0
card3 := 0
card4 := 0
card5 := 0
cardc1 := 0
cardc2 := 0
cardc3 := 0
cardc4 := 0
cardc5 := 0
choice2 := "s"
choice3 := "n"
choice4 := "s"
choice4 := "s"
choice5 := "s"
under21 := 0


end if 

%money to start off with
money := 1000

% These are procedure for blackjack game

%Card Generator for computer
procedure cardai (var num : int)
    randint (num, 1, 10)
    temp := num
end cardai

%Card Generator for user
procedure card (var num : int)
    randint (num, 1, 10)
    if num = 1 then
        num := 11
    end if
    temp := num
end card

%Computer AI
procedure computerai
    cardai (cardc1)
    cardc1 := temp
    cardai (cardc2)
    cardc2 := temp
    totalc := cardc1 + cardc2
    if totalc  21 and card3 = 11 then
        card3 := 1
        put "Changed your ace to 1"
        put "Your total is now: " ..
        total := card1 + card2 + card3 + card4 + card5
        put total
        put "Would you like to hit or stand?"
        get choice7
        if choice7 = "h" or choice7 = "H" then
            if card3 = 0 then
                card (card3)
                card3 := temp
                total := total + card3
                points := total
                put "Your total is now "
                put total
                delay (1500)
                match
                return
            elsif card4 = 0 then
                card (card4)
                card4 := temp
                total := total + card4
                points := total
                put "Your total is now "
                put total
                delay (1500)
                match
                return
            elsif card5 = 0 then
                card (card5)
                card5 := temp
                total := total + card5
                points := total
                put "Your total is now "
                put total
                delay (1500)
                match
                return
            end if
        else
            match
            return
        end if
    elsif points > 21 and card4 = 11 then
        card4 := 1
        put "Changed your ace to 1"
        put "Your total is now: " ..
        total := card1 + card2 + card3 + card4 + card5
        put total
        put "Would you like to hit or stand?"
        get choice7
        if choice7 = "h" or choice7 = "H" then
            if card3 = 0 then
                card (card3)
                card3 := temp
                total := total + card3
                points := total
                put "Your total is now "
                put total
                delay (1500)
                match
                return
            elsif card4 = 0 then
                card (card4)
                card4 := temp
                total := total + card4
                points := total
                put "Your total is now "
                put total
                delay (1500)
                match
                return
            elsif card5 = 0 then
                card (card5)
                card5 := temp
                total := total + card5
                points := total
                put "Your total is now "
                put total
                delay (1500)
                match
                return
            end if
        else
            match
            return
        end if
    elsif points > 21 and card5 = 11 then
        card5 := 1
        put "Changed your ace to 1"
        put "Your total is now: " ..
        total := card1 + card2 + card3 + card4 + card5
        put total
        put "Would you like to hit or stand?"
        get choice7
        if choice7 = "h" or choice7 = "H" then
            if card3 = 0 then
                card (card3)
                card3 := temp
                total := total + card3
                points := total
                put "Your total is now "
                put total
                delay (1500)
                match
                return
            elsif card4 = 0 then
                card (card4)
                card4 := temp
                total := total + card4
                points := total
                put "Your total is now "
                put total
                delay (1500)
                match
                return
            elsif card5 = 0 then
                card (card5)
                card5 := temp
                total := total + card5
                points := total
                put "Your total is now "
                put total
                delay (1500)
                match
                return
            end if
        else
            match
            return
        end if
    end if
if cpoint > points and cpoint  cpoint and points  21 and points  21 and cpoint  21 then
    win := 5
end if
if win = 0 then
    put "You lose, the dealer had " ..
    put cpoint, ", you had " ..
    put points
    put "You lost " ..
    put bet2, " dollars"
    put "Do you wish to play another round?"
    get choice6
    cls
    money := money - bet2
elsif win = 1 then
    put "You win, the dealer had " ..
    put cpoint, ", you had " ..
    put points
    put "You won " ..
    put bet2, " dollars"
    put "Do you wish to play another round?"
    get choice6
    cls
    money := money + bet2
elsif win = 2 then
    put "Dealer Busted"
    put "You win, the dealer had " ..
    put cpoint, ", you had " ..
    put points
    put "You won " ..
    put bet2, " dollars"
    put "Do you wish to play another round?"
    get choice6
    cls
    money := money + bet2
elsif win = 3 then
    put "You Busted"
    put "You lost, the dealer had " ..
    put cpoint, ", you had " ..
    put points
    put "You lost " ..
    put bet2, " dollars"
    put "Do you wish to play another round?"
    get choice6
    cls
    money := money - bet2
elsif win = 4 then
    put "Push, the dealer had " ..
    put cpoint, ", you had " ..
    put points
    put "Do you wish to play another round?"
    get choice6
    cls
elsif win = 5 then
    put "You and dealer both busted"
    put "The dealer wins by default"
    put "You lost " ..
    put bet2, " dollars"
    put "Do you wish to play another round?"
    get choice6
    cls
    money := money - bet2
end if
cls
end match

%Card Playing
procedure jack
    card (card1)
    card1 := temp
    card (card2)
    card2 := temp
    total := card1 + card2
    if total = 21 then
        cls
        put "You Have 21"
        delay (3000)
        points := total
        match
        return
    else
        cls
        put "The dealer's showing card is " ..
        put cardc2
        put "Your cards are:"
        randint (num2, 1, 4)
        if num2 = 1 then
            color (12)
            col1 := "H"
        elsif num2 = 2 then
            color (12)
            col1 := "D"
        elsif num2 = 3 then
            color (255)
            col1 := "S"
        elsif num2 = 4 then
            color (255)
            col1 := "C"
        end if
        put "{" ..
        put card1, col1, "} " ..
        randint (num3, 1, 4)
        if num3 = 1 then
            color (12)
            col2 := "H"
        elsif num3 = 2 then
            color (12)
            col2 := "D"
        elsif num3 = 3 then
            color (255)
            col2 := "S"
        elsif num3 = 4 then
            color (255)
            col2 := "C"
        end if
        put "{" ..
        put card2, col2, "}"
        color (255)
        put "Your total is: " ..
        put total
        if total 