To Do List - Dialog V2

By RagBot on May 31, 2008

This is just a to do list, I felt like scripting something because I was getting bored, and I like to write dialogs, so here it is!

Instructions
Add Item - Type in one item that you need to do and click "OK"
Del Item - Select finished or unwanted item and click "Del Item"
Edit Item - Change a selected item
Up - moves item up in the list
Down - moves item down in the list

V2 UPDATES**
Added UP and DOWN buttons
Added Edit Item button
Fixed it so it loads text file on start up
Deletes text file if it is empty
Deletes selected line, or top line if no line is selected.

dialog tdl {
  title "To Do List"
  size -1 -1 133 82
  option dbu
  list 1, 1 1 99 73, size
  button "Add Item", 2, 100 1 32 12
  button "Del Item", 3, 100 14 32 12
  text "Get Working! Version 2.0 By: RagBot", 5, 21 74 91 7
  button "Edit Item", 4, 100 26 32 12
  box "Move", 6, 100 39 32 33
  button "Up", 7, 101 45 30 12
  button "Down", 8, 101 58 30 12
}
on *:Dialog:tdl:init:0: { if (!$read(tdl.txt, 1)) { halt } | else { .loadbuf -o tdl 1 tdl.txt } }
on *:Dialog:tdl:sclick:2: { 
  write tdl.txt $?="To do list item" 
  did -a tdl 1 $!
}
on *:Dialog:tdl:sclick:3: {
  if (!$did(1).sel) {
    write -dl1 tdl.txt
    did -d tdl 1 1
  }
  else {
    write -dl $+ $did(1).sel tdl.txt 
    did -d tdl 1 $did(1).sel
  }
  if (!$read(tdl.txt, 1)) { .remove tdl.txt }
}
on *:Dialog:tdl:sclick:4: {
  write -l $+ $did(1).sel $?="Edit to do list item"
  did -o tdl 1 $did(1).sel $! 
}
on *:Dialog:tdl:sclick:7: {
  if ($did(1).sel <= 1) { halt }
  var %tdl.one = $read(tdl.txt, $did(1).sel)
  var %tdl.two = $read(tdl.txt, $calc($did(1).sel - 1))
  write -l $+ $calc($did(1).sel - 1) tdl.txt %tdl.one
  write -l $+ $did(1).sel tdl.txt %tdl.two
  did -o tdl 1 $calc($did(1).sel - 1) %tdl.one
  did -o tdl 1 $did(1).sel %tdl.two
}
on *:Dialog:tdl:sclick:8: {
  if ($did(1).sel >= $lines(tdl.txt)) { halt }
  var %tdl.one = $read(tdl.txt, $did(1).sel)
  var %tdl.two = $read(tdl.txt, $calc($did(1).sel + 1))
  write -l $+ $calc($did(1).sel + 1) tdl.txt %tdl.one
  write -l $+ $did(1).sel tdl.txt %tdl.two
  did -o tdl 1 $calc($did(1).sel + 1) %tdl.one
  did -o tdl 1 $did(1).sel %tdl.two
}
menu channel {
  To Do List:dialog -m tdl tdl
}

Comments

Sign in to comment.
RagBot   -  Jun 14, 2008

I\'m still a bit of a new scripter, i do have a few more things to learn, so bear with me as this is really a practise/pass time dialog. :)

 Respond  
Bahamut   -  Jun 06, 2008

The dialog itself functions properly, however there are a few scripting things you could change. /loadbuf -ro eliminates your /did -r; take a look at the helpfile and the /loadbuf switches a bit more. Your lack of error checking is not a good thing. You need to check things like:

If the user has selected an item before deleting it.
If the user has entered text into the textbox before adding it.
If the dialog is in use.

Not to mention, the concept and script is rather simple... I think you should have worked this out a little more before release.

 Respond  
napa182   -  Jun 05, 2008

/help /did
look at switches -b and -e
did -switch name id [n] [text | filename]

 Respond  
RagBot   -  Jun 05, 2008

i used the close button to use up a bit of extra space, i\'ll change around add and del item buttons but for Scakk\'s idea:

If you click delete it will delete the first item in the list. Perhaps make it so teh button is only active if an item is selected.
i\'m not sure how to do it, so if anyone knows how to do so just comment below with instructions how to add the code :) Thanks.
Also Eugenio, you can add exactly what you have to do, i\'m just not sure how long it can be until it doesn\'t work.

 Respond  
Eugenio   -  Jun 02, 2008

I thought you would be able to type in exactly what you have to do not just the name of the task.
/me rates 7

 Respond  
Scakk   -  May 31, 2008

1) If you click delete it will delete the first item in the list. Perhaps make it so teh button is only active if an item is selected.

2) If there is nothing in the .txt file have it delete the file until something is added back to it.

3) No point in the close button as you can close with the red x. Perhaps have and edit option.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.