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

Username:   Password: 
 RegisterRegister   
 how to UNDO?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Wing_Wing




PostPosted: Sat Nov 25, 2006 11:35 pm   Post subject: how to UNDO?

I have this code thing here...

View.Set ("offscreenonly")
var mx, my, mx2, my2, mb, pic : int
loop
mousewhere (mx, my, mb)
if mb = 1 then
pic := Pic.New (0, 0, maxx, maxy)
loop
mousewhere (mx2, my2, mb)
Pic.Draw (pic, 0, 0, picCopy)
drawbox (mx, my, mx2, my2, black)
exit when mb not= 1
View.Update
end loop
end if
end loop

and it can draw boxes, but how do i make it so that i can also undo? anyone help me out?
Sponsor
Sponsor
Sponsor
sponsor
CodeMonkey2000




PostPosted: Sun Nov 26, 2006 12:15 am   Post subject: (No subject)

not sure wat u mean by "undo" but if u want 2 get rid of the boxes cls it
and u need to free the pic
code:
View.Set ("offscreenonly")
var mx, my, mx2, my2, mb, pic : int
loop
    mousewhere (mx, my, mb)
    if mb = 1 then
        pic := Pic.New (0, 0, maxx, maxy)
        loop
            mousewhere (mx2, my2, mb)
            Pic.Draw (pic, 0, 0, picCopy)
            drawbox (mx, my, mx2, my2, black)
            exit when mb not= 1
            View.Update
        end loop
        Pic.Free (pic)
    end if
    cls
    View.Update
end loop
Wing_Wing




PostPosted: Sun Nov 26, 2006 7:56 pm   Post subject: (No subject)

i mean by pressing keys such as CTRL+Z to undo
Tony




PostPosted: Mon Nov 27, 2006 10:47 am   Post subject: (No subject)

you would have to take a screenshot and save it, before drawing a new box. Input.KeyDown to read input, and if it's Ctrl+Z, draw saved image to screen to 'step back'.

Though I think that Ctrl+Z might have a special meaning in Turing.. Thinking
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Prince Pwn




PostPosted: Mon Nov 27, 2006 2:12 pm   Post subject: (No subject)

Yeah for some reason none of the CTRL_ combos work... Probably because Windows uses them. eg:
code:

var keys : array char of boolean
loop
    Input.KeyDown (keys)
    if keys (KEY_CTRL_Z) then %replace with any key, ctrl doesnt work
        exit
    end if
end loop
Prince Pwn




PostPosted: Mon Nov 27, 2006 2:15 pm   Post subject: (No subject)

Wait I just found this in the Turing help menu...

Quote:
Constants beginning with "KEY_" are char values. These are the values returned by getch and used as an index into the Input.KeyDown array. The constants that the constants KEY_KEYPAD_5, KEY_SHIFT, KEY_CTRL and KEY_ALT can only be used in conjunction with Input.KeyDown. The getch and getchar subprograms do not return these values. All other constants with with SHIFT, CTRL and ALT as part of the name cannot be checked for in the Input.KeyDown array.
Tony




PostPosted: Mon Nov 27, 2006 2:39 pm   Post subject: (No subject)

right, so what you are looking for is
code:

var keys : array char of boolean
loop
    Input.KeyDown (keys)
    if keys (KEY_CTRL) and keys('z') then
        put "Ctrl+z"
    end if
end loop
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Prince Pwn




PostPosted: Mon Nov 27, 2006 5:37 pm   Post subject: (No subject)

Cool that way works =D But not in text mode =(
Sponsor
Sponsor
Sponsor
sponsor
Clayton




PostPosted: Mon Nov 27, 2006 5:52 pm   Post subject: (No subject)

won't Ctrl + Z noramally crash Turing during a get though Thinking
ericfourfour




PostPosted: Tue Nov 28, 2006 12:45 am   Post subject: (No subject)

Freakman wrote:
won't Ctrl + Z noramally crash Turing during a get though Thinking

Yes it will. I don't remember anyone brining up get though. But I guess that is partly why Tony went over using Input.KeyDown. Very Happy
Foundation




PostPosted: Sun Dec 03, 2006 5:40 pm   Post subject: (No subject)

In the help menu there is a portion on what Input KeyDown can take. Look that up, but I'm not sure what you mean when you want it to work in text mode because I'd guess you are doing a paint program for school and work in graphics mode.
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  [ 11 Posts ]
Jump to:   


Style:  
Search: