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

Username:   Password: 
 RegisterRegister   
 Forking quit
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Tubs




PostPosted: Fri Jun 06, 2003 11:33 am   Post subject: Forking quit

How can i set my program so that if the ESC button is pressed, it will close the window?

code:
var Choice : string

process Exit
  if Choice = KEY_ESC then
    quit
  end if
end Exit

fork Exit

for I : 1..10
  delay (100)
  put I
end for


doesnt work cause i suck at turing
Sponsor
Sponsor
Sponsor
sponsor
PaddyLong




PostPosted: Fri Jun 06, 2003 11:54 am   Post subject: (No subject)

it doesn't appear that you are actually getting any input for Choice

do something like

code:

if hasch then
   getch (Choice)
end if


put that into your Exit process before your if Choice = KEY_ESC ..

but for that to work you'd need to make Choice declared as
code:

var Choice : string (1)


also, if the only input you're going to be getting for Choice is to see whether to quit or not in the Exit process, you might as well make it a local variable to Exit (so just declare your var Choice : string (1) inside of the Exit process)
Tubs




PostPosted: Fri Jun 06, 2003 12:11 pm   Post subject: (No subject)

code:
process Exit
  var Choice : string (1)
  if hasch then
    getch (Choice)
  end if
  if Choice = KEY_ESC then
    quit
  end if
end Exit

fork Exit

for I : 1..10
  delay (100)
  put I
end for


ya still doesnt work, cuase i am dumb
Tony




PostPosted: Fri Jun 06, 2003 12:45 pm   Post subject: (No subject)

you forgot the loop Laughing
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Martin




PostPosted: Fri Jun 06, 2003 1:52 pm   Post subject: (No subject)

code:
process Exit
  loop
    if Choice = KEY_ESC then
      quit
    end if
  end loop
end Exit


A process still runs like a procedure, so when its end is reached, it will stop.
PaddyLong




PostPosted: Sat Jun 07, 2003 7:03 pm   Post subject: (No subject)

code:

process Exit
    var Choice : string (1)
    loop
        if hasch then
            getch (Choice)
            if Choice = KEY_ESC then
                quit
            end if
        end if
    end loop
end Exit

fork Exit

for I : 1 .. 10
    delay (100)
    put I
end for
Andy




PostPosted: Sat Jun 07, 2003 7:11 pm   Post subject: (No subject)

if u suck at turing, then why is ur rank programmer?
PaddyLong




PostPosted: Sat Jun 07, 2003 7:23 pm   Post subject: (No subject)

you are a very obnoxious individual dodge_tomahawk. you should learn a bit of modesty. Rolling Eyes
Sponsor
Sponsor
Sponsor
sponsor
Andy




PostPosted: Sat Jun 07, 2003 7:55 pm   Post subject: (No subject)

hmmm, why?
void




PostPosted: Sun Jun 08, 2003 10:36 am   Post subject: (No subject)

dodge_tomahawk.. dun worry man...Paddy is just on crack...theres no sympathy for stupidity...but being a programmer isnt a rank that you earn..its just one of those usergroups that you join..or atleast that how i got in..**laughs maniacly** (spell. error)
Tubs




PostPosted: Tue Jun 10, 2003 11:57 am   Post subject: (No subject)

dodge_tomahawk wrote:
if u suck at turing, then why is ur rank programmer?


i dont actually suck i just diss myself a lot
Blade




PostPosted: Tue Jun 10, 2003 12:33 pm   Post subject: (No subject)

heh... you dont join usergroups to get yer rank to change... mine hasnt changed yet. im actually a "kick ass hacker" it shows in my profile thing.. just not in my posts. it depends on how many posts you get... thats how it changes... *shakes head*
Andy




PostPosted: Tue Jun 10, 2003 5:48 pm   Post subject: (No subject)

ya... lots of ranks dun show for some reason, i wanna my newbe hacker to show Crying or Very sad
Tony




PostPosted: Tue Jun 10, 2003 7:48 pm   Post subject: (No subject)

dodge, you dont deserve your newbe hacker. If anything, I'm gonna assign 1337 spammer to you, cuz thats what you do best Laughing
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Tubs




PostPosted: Wed Jun 11, 2003 11:09 am   Post subject: (No subject)

well this weird shit....

code:
process Exit
    var Choice : string (1)

    loop
    drawfillbox (1, maxy - 15, 70, maxy, 12)
            Font.Draw ("ESC to Quit", 2, maxy - 10, font1, blue)
    delay (1000)

        if hasch then
            getch (Choice)
            if Choice = KEY_ESC then
                quit
            end if
        end if
    end loop
end Exit

fork Exit
Start
fork Exit


when i remove the drawing command for quit it doesnt work, but if its not there it works
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 2  [ 16 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: