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

Username:   Password: 
 RegisterRegister   
 back to menu help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Michael




PostPosted: Thu Sep 14, 2006 4:29 pm   Post subject: back to menu help

hey people i got this problem again... using procedures and menus
i made this small program .. not complete yet...
press 1 to go to question one.. but how do i get back to menu after question is done?

in other words.. how do i get out of that procedure to the main line once the procedure is done?

code:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%    Name: Michael Litvak       %%%%%%
%%%%%%    Date: Sept. 14        %%%%%%%%%%%%
%%%%%%%%  Title: ICS 2          %%%%%%%%%%%%
%Purpose: To create a program using loops %%

%%%%%%%%%%%% SCREEN SETTINGS %%%%%%%%%%
View.Set ("graphics:400;400,nobuttonbar")
setscreen ("offscreenonly")

drawfillbox (400, 0, 0, 400, black)

%%%%%%%%%%%%%% FONT SETTINGS %%%%%%%%%%%
% The "Font.Draw" program.
var font1, font2 : int
font1 := Font.New ("arial:35")
assert font1 > 0
font2 := Font.New ("comic sans ms:18:bold")


%%%%%%%%% VAR DECLARATIONS %%%%%%%%
var total_q1 : int

%%%%%% SET KEYBOARD CHARS %%%%%%%
var chars : array char of boolean
Input.KeyDown (chars)


%%%%%%%%%%%%%%%%%%% Question 1 %%%%%%%%%%%%%%%%
proc question1
    total_q1 := 0 % set variable

    %colour settings
    colorback (black)
    color (white)

    for i : -100 .. 100 by 2
        drawfillbox (400, 0, 0, 400, black)             %background
        delay (50)

        locate (2, 19)
        put " QUESTION 1" ..
        locate (4, 1)
        put "This program runs numbers from  -100 to 100 by 2s and displays running total as it runs"

        Font.Draw ("Number count: ", 1, 250, font2, white)
        Font.Draw (intstr (i), 160, 200, font1, yellow) %draws numbers count

        total_q1 := total_q1 + i  %calculation total
        Font.Draw ("Running total: ", 1, 140, font2, white)
        Font.Draw (intstr (total_q1), 150, 90, font1, yellow) %draws running total

        Font.Draw ("_________________", 0, 170, font1, white)        %seperator
        Font.Draw ("_________________", 0, 80, font1, white)                %seperator
        Font.Draw ("_________________", 0, 280, font1, white)                        %seperator
        Font.Draw ("____", 145, 375, font1, brightgreen)                                %seperator
        View.Update %update the screen
       
    end for
end question1



%%%%%% MAINE LINE %%%%%%%%%%

colorback (black)
color (white)

loop
    Input.KeyDown (chars)

    colorback (black)
    color (white)
    put "Press the number of the question"
    put "1. Question 1"

    locate (1, 1)
    if chars ('1') then
        question1
    end if
end loop
Sponsor
Sponsor
Sponsor
sponsor
[Gandalf]




PostPosted: Thu Sep 14, 2006 5:39 pm   Post subject: (No subject)

Once a procedure is finished, execution will automatically return to where the procedure was called. I believe the problem you are experiencing is that the menu doesn't appear in the first place? Well, that's because you set "offscreenonly" mode and you haven't called View.Update yet. If you're having trouble understanding that, try reading through the walkthrough on View.Update.
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: