Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 How would I combine these two programs into one?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
pcmang




PostPosted: Tue Jan 20, 2009 9:39 am   Post subject: How would I combine these two programs into one?

I this learning game I need to make for school but I made half and he made the questions. I'm having problems calling because procs aren't being declared but if I move it, it'll do that same the other way around.

I need to replace the "you rox" with questions and the "u sux" with the failed procedure(s). (Inno if you need all those passed and failed procedures) and when they click the correct answer to the question I need to go to the passed procedure then the processing procedure. (or if its easier just the processing proc).

code:
import GUI
%Declaration Statement
%P.E.I, Nova Scotia
var winID : int := Window.Open ("position:400;100,graphics:640;400")
var winID2 : int
var font : int
font := Font.New ("Arial:20")
var picID, picID2, picIDon, picIDma, picIDnu, picIDbc, picIDyu, picIDqu: int
var font6 : int
font6 := Font.New ("Arial:12")
var startButton, exitButton : int
var rangeX, rangeY, button:int
var ontarioName, manitobaName, nunavutName, britishcolumbiaName, yukonName, quebecName: string
proc title
    Font.Draw ("Learn Canadian Geography!", 140, 379, font, 0)
end title

proc intro
    Font.Draw ("This program was designed to develop your Canadian Geography knowledge", 70, 355, font6, 0)
end intro

procedure mainScreen
    locate (1, 36)
    put "Learn Canadian Geography!"
    picID := Pic.FileNew ("canada.jpg")
    Pic.Draw (picID, 1, 1, picCopy)
    GUI.Show (startButton)
    GUI.Show (exitButton)
    title
    intro
end mainScreen

proc processing
    winID2 := Window.Open ("position:1;550,graphics:640;400")
    picID2 := Pic.FileNew ("canadapicresize.jpg")
    Pic.Draw (picID2, 1, 1, picCopy)
    drawbox (395,50,500,205,7)
    loop
       mousewhere (rangeX, rangeY, button)
    if button = 1 then
    if rangeX >= 270 and rangeX <=395 and rangeY >= 45 and rangeY <= 140 then
picIDon := Pic.FileNew ("OntarioZoom.jpg")
    Pic.Draw (picIDon, 1, 1, picCopy)
    put "What is the name of this province?: "..
    get ontarioName
    if ontarioName = "ontario" or ontarioName = "Ontario" then
    put "nice"
    else
    put "you sux"
    end if
    end if
    end if
    if button = 1 then
if rangeX >= 215 and rangeX <=270 and rangeY >= 70 and rangeY <= 175 then
picIDma := Pic.FileNew ("ManitobaZoom.jpg")
    Pic.Draw (picIDma, 1, 1, picCopy)
    put "What is the name of this province?: "..
    get manitobaName
    if manitobaName = "manitoba" or manitobaName = "Manitoba" then
    put "u rox"
    else
    put "i hate u"
    end if
    end if
    end if
    if button = 1 then
if rangeX >= 235 and rangeX <=380 and rangeY >= 176 and rangeY <= 400 then
picIDnu := Pic.FileNew ("NunavutZoom.jpg")
    Pic.Draw (picIDnu, 1, 1, picCopy)
    put "What is the name of this territory: "..
    get nunavutName
    if nunavutName = "nunavut" or nunavutName = "Nunavut" then
    put "u rox"
    else
    put "i hate u"
    end if
    end if
    end if
        if button = 1 then
if rangeX >= 1 and rangeX <=100 and rangeY >= 100 and rangeY <= 205 then
picIDbc := Pic.FileNew ("BritishColumbiaZoom.jpg")
    Pic.Draw (picIDbc, 1, 1, picCopy)
    put "What is the name of this province?: "..
    get britishcolumbiaName
    if britishcolumbiaName = "british columbia" or britishcolumbiaName = "British Columbia" then
    put "u rox"
    else
    put "i hate u"
    end if
    end if
    end if
    if button = 1 then
    if rangeX >= 1 and rangeX <=120 and rangeY >= 211 and rangeY <= 325 then
picIDyu := Pic.FileNew ("YukonZoom.jpg")
    Pic.Draw (picIDyu, 1, 1, picCopy)
    put "What is the name of this territory?: "..
    get yukonName
    if yukonName = "yukon" or yukonName = "Yukon" or yukonName = "Yukon Territory" or yukonName = "yukon territory" then
    put "u rox"
    else
    put "i hate u"
    end if
    end if
    end if
      if button = 1 then
    if rangeX >= 395 and rangeX <=500 and rangeY >= 50 and rangeY <= 205 then
picIDqu := Pic.FileNew ("QuebecZoom.jpg")
    Pic.Draw (picIDqu, 1, 1, picCopy)
    put "What is the name of this province?: "..
    get quebecName
    if quebecName = "Quebec" or quebecName = "quebec" then
    put "u rox"
    else
    put "i hate u"
    end if
    end if
    end if
    end loop
end processing


proc exitFunction
    Window.Close (winID)
    Window.Close (winID2)
end exitFunction

exitButton := GUI.CreateButton (570, 10, 0, "Exit", exitFunction)
startButton := GUI.CreateButton (20, 10, 0, "Start", processing)
GUI.SetColor (startButton, brightred)
GUI.SetColor (exitButton, brightred)
mainScreen

loop
    exit when GUI.ProcessEvent
end loop

________________________________________________________________________________________________

import GUI

var tdot,reg,reg1,yell,vanc,town,mani,wh,cha,vanc1,vic,vic1,hali,hali1,que,nun,yuk,brit,town1 :int
var font : int
font := Font.New ("Arial:20")
var startButton, exitButton : int
%Fonts
var font1 : int
font1 := Font.New ("Calabri:12:bold,italic")
var font2 : int
font2 := Font.New ("Times New Roman:16:italic")
var font6 : int
font6 := Font.New ("Arial:12")
var font4 : int
font4 := Font.New ("Calabri:18")
var winID : int := Window.Open ("position:400;100,graphics:640;400")
var winID2 : int
var picID, picID2, picIDon, picIDma, picIDnu, picIDbc, picIDyu, picIDqu: int
var rangeX, rangeY, button:int
var ontarioName, manitobaName, nunavutName, britishcolumbiaName, yukonName, quebecName: string

proc title
    Font.Draw ("Learn Canadian Geography!", 140, 379, font, 0)
end title

proc intro
    Font.Draw ("This program was designed to develop your Canadian Geography knowledge", 70, 355, font6, 0)
end intro

%Main Screen that the user goes into
procedure mainScreen
    locate (1, 36)
    put "Learn Canadian Geography!"
    picID := Pic.FileNew ("canada.jpg")
    Pic.Draw (picID, 1, 1, picCopy)
    GUI.Show (startButton)
    GUI.Show (exitButton)
    title
    intro
end mainScreen


%When a user clicks on the wrong button...
procedure Failed
    cls
    var picOp : int
    picOp := Pic.FileNew ("art_failed.jpg")
    Pic.Draw (picOp, 50, 140, picCopy)
    Pic.Free (picOp)
    Font.Draw ("It seems that your knowledge is limited.", 100, 100, font2, red)
    Font.Draw ("Review the capital cities and try again.", 100, 80, font2, red)
    delay (3500)
    mainScreen
end Failed

%When all questions are answered correctly
procedure MissionComplete
cls
picID := Pic.FileNew ("mission.jpg")
    Pic.Draw (picID, 160, 30, picCopy)
    Pic.Free (picID)
    Font.Draw ("Slick. You got everything right!", 100, 100, font2, red)
    delay (3500)
end MissionComplete

%When Right Answer(Yukon Question)
proc Passed7
    cls
    picID := Pic.FileNew ("Slick_header.jpg")
    Pic.Draw (picID, 160, 30, picCopy)
    Pic.Free (picID)
    Font.Draw ("Slick. You got it right!", 100, 100, font2, red)
    delay (3500)
    GUI.Hide(que)
    GUI.Hide(yuk)
    GUI.Hide(town)
    GUI.Hide(tdot)
    GUI.Disable(que)
    GUI.Disable(yuk)
    GUI.Disable(town)
    GUI.Disable(tdot)
    MissionComplete
end Passed7

%Yukon Question
procedure YukScreen
cls
    Font.Draw ("Geography Quiz!", 200, 380, font, red)
    Font.Draw ("What is the Capital City of Yukon Territory?", 25, 320, font1, black)
    GUI.Enable(que)
    GUI.Enable(yuk)
    GUI.Enable(town)
    GUI.Enable(tdot)
    GUI.Show(que)%Y-value 280
    GUI.Show(yuk)%Y-Value 190
    GUI.Show(town)%Y-Value 220
    GUI.Show(tdot)%Y-Value 250
    GUI.SetColor (nun, brightred)
    GUI.Show (exitButton)
end YukScreen

%When Right Answer(Quebec Question)
proc Passed6
    cls
    picID := Pic.FileNew ("Slick_header.jpg")
    Pic.Draw (picID, 160, 30, picCopy)
    Pic.Free (picID)
    Font.Draw ("Slick. You got it right!", 100, 100, font2, red)
    delay (3500)
    GUI.Hide(hali)
    GUI.Hide(nun)
    GUI.Hide(town)
    GUI.Hide(wh)
    GUI.Disable(hali)
    GUI.Disable(nun)
    GUI.Disable(town)
    GUI.Disable(wh)
    YukScreen
end Passed6

%Quebec Question
procedure QueScreen
cls
    Font.Draw ("Geography Quiz!", 200, 380, font, red)
    Font.Draw ("What is the Capital City of Nunavut?", 25, 320, font1, black)
    GUI.Enable(hali)%Y-Value 250
    GUI.Enable(nun)%Y-Value 190
    GUI.Enable(town)%Y-Value 220
    GUI.Enable(wh)%Y-Value 280
    GUI.Show(wh)
    GUI.Show(hali)
    GUI.Show(nun)
    GUI.Show(town)
    GUI.Show (exitButton)
end QueScreen

%When Right Answer(Nunavut Question)
proc Passed5
    cls
    picID := Pic.FileNew ("Slick_header.jpg")
    Pic.Draw (picID, 160, 30, picCopy)
    Pic.Free (picID)
    Font.Draw ("Slick. You got it right!", 100, 100, font2, red)
    delay (3500)
    QueScreen
end Passed5

%Nunavut Question
procedure NunScreen
cls
    Font.Draw ("Geography Quiz!", 200, 380, font, red)
    Font.Draw ("What is the Capital City of Nunavut?", 25, 320, font1, black)
    brit := GUI.CreateButton (25, 280, 0, "British Columbia", Failed)
    hali := GUI.CreateButton (25, 250, 0, "Halifax", Failed)
    town := GUI.CreateButton (25, 220, 0, "Charlettetown", Failed)
    nun := GUI.CreateButton (25, 190, 0, "Iqaluit", Passed5)
    GUI.SetColor (brit, brightred)
    GUI.SetColor (hali, brightred)
    GUI.SetColor (nun, brightred)
    GUI.SetColor (town, brightred)
    GUI.Show (exitButton)
end NunScreen

%When Right Answer(Nova Scotia Question)
proc Passed4
    cls
    picID := Pic.FileNew ("Slick_header.jpg")
    Pic.Draw (picID, 160, 30, picCopy)
    Pic.Free (picID)
    Font.Draw ("Slick. You got it right!", 100, 100, font2, red)
    delay (3500)
    GUI.Hide(hali1)
    GUI.Hide(reg)
    GUI.Hide(mani)
    GUI.Hide(town)
    GUI.Disable(hali1)
    GUI.Disable(reg)
    GUI.Disable(mani)
    GUI.Disable(town)
    NunScreen
end Passed4

%Nova Scotia Question
procedure NovaScreen
cls
    Font.Draw ("Geography Quiz!", 200, 380, font, red)
    Font.Draw ("What is the Capital City of Nova Scotia?", 25, 320, font1, black)
    GUI.Enable(hali1)
    GUI.Enable(reg)
    GUI.Enable(mani)
    GUI.Enable(town)
    GUI.Show(hali1)
    GUI.Show(reg)
    GUI.Show(mani)
    GUI.Show(hali1)
    GUI.SetColor (reg, brightred)
    GUI.SetColor (hali1, brightred)
    GUI.SetColor (mani, brightred)
    GUI.SetColor (town, brightred)
    GUI.Show (exitButton)
end NovaScreen

%When Right Answer(British Columbia Question)
proc Passed3
    cls
    picID := Pic.FileNew ("Slick_header.jpg")
    Pic.Draw (picID, 160, 30, picCopy)
    Pic.Free (picID)
    Font.Draw ("Slick. You got it right!", 100, 100, font2, red)
    delay (3500)
    GUI.Hide(vanc)
    GUI.Hide(town)
    GUI.Hide(mani)
    GUI.Hide(vic1)
    GUI.Disable(vanc)
    GUI.Disable(town)
    GUI.Disable(mani)
    GUI.Disable(vic1)
    NovaScreen
end Passed3

%British Columbia Question
procedure BritScreen
 cls
    Font.Draw ("Geography Quiz!", 200, 380, font, red)
    Font.Draw ("What is the Capital City of British Columbia?", 25, 320, font1, black)
    GUI.Enable(vanc)
    GUI.Enable(town)
    GUI.Enable(mani)
    GUI.Enable(vic1)
    GUI.Show(vanc)
    GUI.Show(town)
    GUI.Show(mani)
    GUI.Show(vic1)
    GUI.Show (exitButton)
end BritScreen

%When Right Answer(Manitoba Question)
proc Passed2
    cls
    picID := Pic.FileNew ("Slick_header.jpg")
    Pic.Draw (picID, 160, 30, picCopy)
    Pic.Free (picID)
    Font.Draw ("Slick. You got it right!", 100, 100, font2, red)
    delay (3500)
    GUI.Hide(reg)
    GUI.Hide(tdot)
    GUI.Hide(que)
    GUI.Hide(mani)
    GUI.Disable(reg)
    GUI.Disable(tdot)
    GUI.Disable(que)
    GUI.Disable(mani)
     BritScreen
end Passed2
   
%Maintoba Question
procedure maniScreen
    cls
    Font.Draw ("Geography Quiz!", 200, 380, font, red)
    Font.Draw ("What is the Capital City of Manitoba?", 25, 320, font1, black)
    GUI.Enable(reg)
    GUI.Enable(tdot)
    GUI.Enable(que)
    GUI.Enable(mani)
    GUI.Show (reg)
    GUI.Show (mani)
    GUI.Show (que)
    GUI.Show (tdot)
    GUI.Show (exitButton)
end maniScreen

%When right Answer(PEI Question)
proc Passed1
    cls
    picID := Pic.FileNew ("Slick_header.jpg")
    Pic.Draw (picID, 160, 30, picCopy)
    Pic.Free (picID)
    Font.Draw ("Slick. You got it right!", 25, 100, font2, red)
    delay (3500)
    GUI.Hide (town)
    GUI.Hide (cha)
    GUI.Hide (yell)
    GUI.Hide (vic)
    GUI.Disable(town)
    GUI.Disable(cha)
    GUI.Disable(yell)
    GUI.Disable(vic)
    GUI.Show (exitButton)
    maniScreen
end Passed1

%Second Question
procedure PEIScreen
    cls
    Font.Draw ("Geography Quiz!", 200, 380, font, red)
    Font.Draw ("What is the Capital City of Prince Edward Island?", 25, 320, font1, black)
    GUI.Enable(yell)
    GUI.Show (town)%Y-Value 220
    GUI.Show (cha)%Y-Value 250
    GUI.Show (yell)%Y-Value 190
    GUI.Show (vic)%Y-Value 280
    GUI.Show (exitButton)
end PEIScreen

%When right Answer(Toronto Question)
procedure Passed
    cls
    GUI.Hide (reg)
    GUI.Hide (tdot)
    GUI.Hide (vanc)
    GUI.Hide (yell)
    GUI.Disable(reg)
    GUI.Disable(tdot)
    GUI.Disable(vanc)
    GUI.Disable(yell)
    picID := Pic.FileNew ("Slick_header.jpg")
    Pic.Draw (picID, 160, 30, picCopy)
    Pic.Free (picID)
    Font.Draw ("Slick. You got it right!", 25, 100, font2, red)
    delay (3500)
    GUI.Show (exitButton)
    PEIScreen
end Passed

%Ontario Question
procedure OntScreen
    cls
    Font.Draw ("Geography Quiz!", 200, 380, font, red)
    Font.Draw ("What is the Capital City of Ontario?", 25, 320, font1, black)
   GUI.Show(reg)
   GUI.Show(tdot)
   GUI.Show(vanc)
   GUI.Show(yell)
    GUI.Show (exitButton)
end OntScreen

proc exitFunction
    Window.Close (winID)
    Window.Close (winID2)
end exitFunction

%Buttons
exitButton := GUI.CreateButton (570, 10, 0, "Exit", exitFunction)
startButton := GUI.CreateButton (20, 10, 0, "Start", processing)
    que := GUI.CreateButton (25, 280, 0, "Quebec City", Passed6)
    tdot := GUI.CreateButton (25, 250, 0, "Toronto", Passed)
    vanc := GUI.CreateButton (25, 220, 0, "Vancouver", Failed)
    yell := GUI.CreateButton (25, 190, 0, "YellowKnife", Failed)
    reg := GUI.CreateButton (25, 280, 0, "Regina", Failed)
    vanc1 := GUI.CreateButton (25, 250, 0, "Vancouver", Passed)
    town := GUI.CreateButton (25, 220, 0, "Charlettetown", Failed)
    mani := GUI.CreateButton (25, 190, 0, "Winnipeg", Passed2)
    hali := GUI.CreateButton (25, 250, 0, "Halifax", Failed)
    hali1 := GUI.CreateButton (25, 250, 0, "Halifax", Passed4)
    nun := GUI.CreateButton (25, 190, 0, "Iqaluit", Failed)
    town1 := GUI.CreateButton (25, 220, 0, "Charlettetown", Passed1)
    wh := GUI.CreateButton (25, 280, 0, "WhiteHorse", Failed)
    cha := GUI.CreateButton (25, 250, 0, "Towncharlette", Failed)
    reg1 := GUI.CreateButton (25, 190, 0, "Regina", Failed)
    vic := GUI.CreateButton (25, 280, 0, "Victoria", Passed3)
    vic1 := GUI.CreateButton (25, 280, 0, "Victoria", Passed3)
    hali := GUI.CreateButton (25, 250, 0, "Halifax", Failed)
    yuk := GUI.CreateButton (25, 190, 0, "Iqaluit", Failed)
    brit := GUI.CreateButton (25, 280, 0, "British Columbia", Failed)
    GUI.SetColor (brit, brightred)
    GUI.SetColor (yuk, brightred)
    GUI.SetColor (hali, brightred)
    GUI.SetColor (vic1, brightred)
    GUI.SetColor (vic, brightred)
    GUI.SetColor (reg1, brightred)
    GUI.SetColor (cha, brightred)
    GUI.SetColor (town, brightred)
    GUI.SetColor (wh, brightred)
    GUI.SetColor (que, brightred)
    GUI.SetColor (hali, brightred)
    GUI.SetColor (hali1, brightred)
    GUI.SetColor (yell, brightred)
    GUI.SetColor (tdot, brightred)
    GUI.SetColor (vanc, brightred)
    GUI.SetColor (reg, brightred)
    GUI.SetColor (vanc, brightred)
    GUI.SetColor (mani, brightred)
    GUI.SetColor (town, brightred)
    GUI.SetColor (town1, brightred)
GUI.SetColor (startButton, brightred)
GUI.SetColor (exitButton, brightred)
mainScreen

loop
    exit when GUI.ProcessEvent
end loop
[/code]
Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: Tue Jan 20, 2009 9:52 am   Post subject: RE:How would I combine these two programs into one?

Sounds like you have a circular dependency (that is, A needs B, B needs A, so neither one can be declared before the other). Fortunately, there is a way to resolve this; it's called "forward declarations".

I don't remember my Turing syntax terribly well, but it looks a little like:

code:
forward procedure A ( arguments list... ) % this is a forward DECLARATION (not definition)

procedure B ( arguments list... )
    % DECLARATION and DEFINITION of B
end B
body procedure A ( arguments list ... )
    % DEFINITION of A
end A


Check the forward keyword in the Turing help for more information.

Side note: use [ syntax = "turing" ] [ / syntax ] to highlight your code in the future please.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: