Author Topic: Undo  (Read 22576 times)

0 Members and 1 Guest are viewing this topic.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Undo
« Reply #30 on: February 26, 2011, 04:40:38 am »
I thought of that, but it could erase pixels that were drawn by multiple commamds. (Think Line(X1,Y1,X2,Y2,0))
@DJ_O I'm defensive in the extreme when it comes to programming (one of my programs only gives the user 4 tries to give valid input. There's  a cap on the number of tries not to insult the user, but to avoid my error message being displayed wrong.)
Now I am confused even more :/ . In what way are you defensive? Do you want to make sure people won't look at the source code? Do you want the program to simply deny their access after they fail to type valid input? (Like how on certain forums, when you type your password wrong 4 times, it bans your account for a week)

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: Undo
« Reply #31 on: February 26, 2011, 08:17:27 am »
Yea, those two posts in question are confusing to me as well.
     In regards to wanting to have unlimited undo's in TI BASIC in a drawing program: it is possible to have many(unlimited might be a bit much), but it would either: A: take loads of memory, or B: have to be limited to commands that are not too complex.
     Here is an idea of one solution (although simplified and not completely fleshed out).You could log each command and what variables said command took as input and store it in a string or list. It may be necessary to document what data a command is changing as well. Each command would have to have a separate undo algorithm that would restore whatever part of the screen the command affected. (for those commands that can logically be undone in such a way). When undo is called, the program would check to see what the last command issued was, recall the input, and then call the undo algorithm for that specific command.
     The other possibility I see is to use a lot of picture files or lists as others have suggested. I'm sure their may be other ways, it will just take some thought. Good luck!

Offline TravisE

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 182
  • Rating: +33/-0
    • View Profile
    • ticalc.org
Re: Undo
« Reply #32 on: February 26, 2011, 08:56:34 am »
The way I read it, “defensive” seems to be intended to mean that the code is written to handle every conceivable case possible, so that it is very difficult for a bug or malfunction to occur no matter what the user does.
« Last Edit: February 26, 2011, 08:57:24 am by TravisE »
ticalc.org staff member—http://www.ticalc.org/

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: Undo
« Reply #33 on: February 26, 2011, 07:20:42 pm »
Yes.
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

Offline jnesselr

  • King Graphmastur
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2270
  • Rating: +81/-20
  • TAO == epic
    • View Profile
Re: Undo
« Reply #34 on: February 26, 2011, 07:50:36 pm »

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: Undo
« Reply #35 on: February 26, 2011, 08:06:17 pm »
Yes.
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

Offline jnesselr

  • King Graphmastur
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2270
  • Rating: +81/-20
  • TAO == epic
    • View Profile
Re: Undo
« Reply #36 on: February 26, 2011, 08:31:15 pm »
Yes.
slightly spamish, but okay.  But wait, was that yes to me, or....  And it's good to program like that, but I don't make that my absolute top priority.

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Undo
« Reply #37 on: February 26, 2011, 08:36:03 pm »
I try to do that every time it's reasonably possible. My method is not to catch all possible errors, though. I try to simply make it so that the user can't possibly enter bad input to begin with.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: Undo
« Reply #38 on: February 26, 2011, 08:44:18 pm »
That's exactly what I'm talking about.
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

Offline jnesselr

  • King Graphmastur
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2270
  • Rating: +81/-20
  • TAO == epic
    • View Profile
Re: Undo
« Reply #39 on: February 26, 2011, 09:44:27 pm »
That's exactly what I'm talking about.
Then don't just respond with yes... meh.  Anyway, now that that's settled, and we all have good coding practice....

What are you going to choose for undos?  You can't have infinite undos the way you are talking about.  Not unless you save the state that happened right before the last update for every single update. (Which isn't possible)  I'd go with my previous idea, but then again, I'm biased, and am not entirely sure how hard it would be to code.

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: Undo
« Reply #40 on: February 27, 2011, 02:10:01 am »
I'd go with the compromise, but it just doesn't feel right to me somehow. About the most complicated logic in the program is the logic dealing with the preview feature for lines, and I'd like to keep it that way.
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Undo
« Reply #41 on: February 27, 2011, 02:11:19 am »
It's your program, so do whatever feels best.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline phenomist

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 132
  • Rating: +46/-3
    • View Profile
Re: Undo
« Reply #42 on: February 27, 2011, 02:40:12 am »
I don't know about the feasibility about this, but what if you store the total number of times every pixel was drawn on, and turn the pixels off for only those that are undo-ed?

For example, consider
A***B
*****
*****
*****
C***D

Drawn lines: A-B, B-C, C-D, D-A. Now the total times drawn counter looks like this:

21112
01010
00200
01010
21112

Undoing it once would reduce the counters on the D-A line, namely change it to

11112
00010
00100
01000
21111

so two pixels would turn off.

How would you store a 64x96 matrix? Since hopefully you're using less than 1000 actions due to list size limits, 10 pictures would be enough to store as a binary counter.

Hopefully this works?
Level Designer for Graviter

[Disclaimer: I can't program for my life.]

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Undo
« Reply #43 on: February 27, 2011, 05:39:44 am »
 :o

Do you have one of the older 128 KB calcs? A 95x63* matrix would take up 53 KB of RAM. The newer reduced RAM calcs only have 48 KB to work with.

*TI-BASIC can't draw into the last row and column of the screen.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Undo
« Reply #44 on: February 27, 2011, 09:35:57 am »
:o

Do you have one of the older 128 KB calcs? A 95x63* matrix would take up 53 KB of RAM. The newer reduced RAM calcs only have 48 KB to work with.
Actually due to limits placed on them by TI, all of the calcs usually have between 16000 and 21000 free RAM for basic programs.  :o indeed. :)