
-----------------------------------
bwong
Wed Jun 15, 2011 2:58 pm

Exiting loops and going back to start
-----------------------------------
What is it you are trying to achieve?
My issue comes at the ending of the quiz portion of my program.  Once the user is done the quiz, I want the program to go back to the main page (start of program).

What is the problem you are having?
I do not know how to do this.  I was told to make a large loop, and smaller loops for each section.  I tried this, but it did not work.  I also tried a more far-fetched idea which included using GUI.ShowWindow, and GUI.HideWindow, which not as much success.

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)





%%%%%%%%%%%%%%%%%%%%%%FORMATTING%%%%%%%%%%%%%%%%%%%%%%
import GUI
setscreen ("graphics: 800; 600")
%Question Header Box will be 640 * 044 pixels
%Question Answer Box will be 640 * 225 pixels
%Information Headers will be 640 * 044 pixels
%Information bodies  will be 640 * 445 pixels

%%%%%%%%%%%%%%%%%VARIABLE DECLARATION%%%%%%%%%%%%%%%%%
var mousex, mousey, mousesel, mousedown : int
var fadecolour : int := 000
var userselection : string := ""
var picBlended : int
%IMAGE VARIABLES: The image ID is used for organization.
%Sample: pic(usage: char (f (formating), q (quiz), i (info), t (titles)), number: int)
var picf01 : int := Pic.FileNew ("picf001_mainpage.jpg")
var picf02 : int := Pic.FileNew ("picf002_quizpage.jpg")
var picf03 : int := Pic.FileNew ("picf003_infopage.jpg")
var picf04 : int := Pic.FileNew ("picf04_testcomplete.jpg")

var picq01 : int := Pic.FileNew ("picq001_question1_q1.jpg")
var picq02 : int := Pic.FileNew ("picq002_question1_answer1.jpg")
var picq03 : int := Pic.FileNew ("picq003_question1_q2.jpg")
var picq04 : int := Pic.FileNew ("picq004_question1_answer2.jpg")
var picq05 : int := Pic.FileNew ("picq005_question1_q3.jpg")
var picq06 : int := Pic.FileNew ("picq006_question1_answer3.jpg")
var picq07 : int := Pic.FileNew ("picq007_question1_q4.jpg")
var picq08 : int := Pic.FileNew ("picq008_question1_answer4.jpg")
var picq09 : int := Pic.FileNew ("picq009_question1_q5.jpg")
var picq10 : int := Pic.FileNew ("picq010_question1_answer5.jpg")
var picq_highlight : int := Pic.FileNew ("picq_highlight.jpg")

var pici01 : int := Pic.FileNew ("pici001_information_Blackholes.jpg")
var pici02 : int := Pic.FileNew ("pici002_information_Nebula.jpg")
var pici03 : int := Pic.FileNew ("pici003_information_Stars.jpg")
var pici04 : int := Pic.FileNew ("pici004_information_Galaxies.jpg")
var pici05 : int := Pic.FileNew ("pici005_information_Planets.jpg")

var pict01 : int := Pic.FileNew ("pict001_information_Blackholes.jpg")
var pict02 : int := Pic.FileNew ("pict002_information_Nebula.jpg")
var pict03 : int := Pic.FileNew ("pict003_information_Stars.jpg")
var pict04 : int := Pic.FileNew ("pict004_information_Galaxies.jpg")
var pict05 : int := Pic.FileNew ("pict005_information_Planets.jpg")
%End image variables

var font001 : int := Font.New ("MyriadPro-Cond:72")
var font002 : int := Font.New ("MyriadPro-Cond:32")

var q1n : int := 0
var q2n : int := 0
var q3n : int := 0
var q4n : int := 0
var q5n : int := 0

var Answer : array 1 .. 5 of int

var animatebutton : int
var resultsbutton : int
var quizbutton : int
var infobutton : int
var quitbutton : int
%%%%%%%%%%%%%%%%%%%%%%PROCEDURES%%%%%%%%%%%%%%%%%%%%%%
procedure donothing
end donothing

procedure introduction
    Pic.DrawSpecial (picf01, 000, 000, picCopy, picFadeIn, 750)
    for i : 0 .. 255
        RGB.SetColor (fadecolour, i / 255, i / 255, i / 255)
        Font.Draw ("Astronomy", 020, 500, font001, fadecolour)
        View.Update
        delay (05)
    end for
    animatebutton := GUI.CreateButton (010, 040, 140, "Animation", donothing)
    resultsbutton := GUI.CreateButton (490, 040, 140, "Results", donothing)
    quizbutton := GUI.CreateButton (170, 040, 140, "Quiz", donothing)
    infobutton := GUI.CreateButton (330, 040, 140, "Information", donothing)
    quitbutton := GUI.CreateButton (650, 040, 140, "Exit", donothing)
end introduction

procedure test (questionhead, questionansw : int, answer : int)
    Pic.Draw (picf02, 000, 000, picCopy)
    Pic.DrawSpecial (questionhead, 080, 525, picCopy, picBlend + 85, 000)
    Pic.DrawSpecial (questionansw, 080, 200, picCopy, picBlend + 080, 000)
    loop
        Mouse.Where (mousex, mousey, mousedown)
        Pic.DrawSpecial (questionansw, 080, 200, picCopy, picBlend + 04, 000)
        if mousex >= 085 and mousex = 330 and mousey = 085 and mousex = 290 and mousey = 085 and mousex = 255 and mousey = 010 and mousey >= 040 and mousex = 170 and mousey >= 040 and mousex = 330 and mousey >= 040 and mousex = 490 and mousey >= 040 and mousex = 650 and mousey >= 040 and mousey = 085 and mousex = 330 and mousey = 085 and mousex = 290 and mousey = 085 and mousex = 255 and mousey = 010 and mousey >= 040 and mousex = 170 and mousey >= 040 and mousex = 330 and mousey >= 040 and mousex = 490 and mousey >= 040 and mousex = 650 and mousey >= 040 and mousey 