Kirbeh_Pr0nz commented on a Page, Memo  -  Jun 09, 2009

i know its a little late Vortex XD but this should fix it:

on *:load:{ 
  mkdir Memos 
  write Memos/inbox.txt
  write Memos/outbox.txt
  write Memos/saved.txt
  write Memos/contacts.txt
}

alias memos { If (!$dialog(memo.main)) { dialog -drmo memo.main memo.main } }

menu * {
  Memos:memos
}

;======================Main=======================
dialog memo.main {
  title "Memo Manager"
  size -1 -1 207 169
  option dbu
  button "Done", 15, 133 152 37 12, ok
  tab "Inbox", 10, 5 0 195 144
  list 100, 11 16 184 109, tab 10 size vsbar
  button "Delete", 103, 111 128 37 12, tab 10
  button "Delete All", 104, 158 128 37 12, tab 10
  button "Save", 102, 62 128 37 12, tab 10
  button "Reply", 101, 11 128 37 12, tab 10
  tab "Outbox", 11
  list 200, 11 16 184 109, tab 11 size vsbar
  button "Delete", 202, 84 128 37 12, tab 11
  button "Delete All", 203, 133 128 37 12, tab 11
  button "Cancel", 201, 35 128 37 12, tab 11
  tab "Saved", 12
  list 300, 11 16 184 109, tab 12 size vsbar
  button "Delete", 301, 60 128 37 12, tab 12
  button "Delete All", 302, 111 128 37 12, tab 12
  button "New Memo", 13, 35 152 37 12
  button "Contacts", 14, 84 152 37 12
}

on *:dialog:memo.main:sclick:*:{
  If ($did == 13) { dialog -drmo memo.new memo.new }
  If ($did == 14) { dialog -drmo memo.contacts memo.contacts }
  If ($did == 101) && ($did(100).seltext) { 
    set %memo.reply on
    dialog -drmo memo.new memo.new 
    did -a memo.new 101 $gettok($did(100).seltext,1,45) 
  }
  If ($did == 102) && ($did(100).seltext) { 
    write memos/saved.txt $read(memos/inbox.txt,w,$did(100).seltext $+ * )
    write -dl $+ $readn memos/inbox.txt
    loadlists
  }
  If ($did == 103) && ($did(100).seltext) { 
    dialog -n memo.main
    If ($input(Are you sure you wish to delete this message? $crlf $+ $did(100).seltext,y,Delete Memo) == $true) {
      var %temp $read(memos/inbox.txt,w,$did(100).seltext $+ *)
      write -dl $+ $readn memos/inbox.txt
      loadlists
    }
    dialog -ov memo.main memo.main
  }
  If ($did == 104) {
    dialog -n memo.main
    If ($input(Are you sure you wish to delete all messages in your inbox?,y,Delete All) == $true) { write -c memos/inbox.txt | loadlists }
    dialog -ov memo.main memo.main 
  }
  If ($did == 201) { dialog -n memo.main | ms cancel $$?="Enter nick/channel to cancel last memo for:" }
  If ($did == 202) && ($did(200).seltext) { 
    var %temp $read(memos/outbox.txt,w,$did(100).seltext $+ *)
    write -dl $+ $readn memos/outbox.txt
    loadlists
  }
  If ($did == 203) {
    dialog -n memo.main
    If ($input(Are you sure you wish to clear your outbox?,y,Delete All) == $true) { write -c memos/outbox.txt | loadlists }
    dialog -ov memo.main memo.main 
  }
  If ($did == 301) && ($did(300).seltext) { 
    dialog -n memo.main
    If ($input(Are you sure you wish to delete this message? $crlf $+ $did(300).seltext,y,Delete Memo) == $true) {
      var %temp $read(memos/saved.txt,w,$did(300).seltext $+ *)
      write -dl $+ $readn memos/saved.txt
      loadlists
    }
    dialog -ov memo.main memo.main
  }
  If ($did == 302) {
    dialog -n memo.main
    If ($input(Are you sure you wish to delete all saved messages?,y,Delete All) == $true) { write -c memos/saved.txt | loadlists }
    dialog -ov memo.main memo.main 
  }
}

on *:dialog:memo.main:dclick:*:{
  If ($did == 100) { set %memo.view.num 100 | dialog -drmo memo.view memo.view }
  If ($did == 200) { set %memo.outbox on | dialog -drmo memo.new memo.new }
  If ($did == 300) { set %memo.view.num 300 | dialog -drmo memo.view memo.view }
}

on *:dialog:memo.main:init:*:{
  set %memo.open on
  .timer -m 1 1 loadmemos
}

on *:dialog:memo.main:close:*:{
  unset %memo.*
}

;=======================New========================
dialog memo.new {
  title "New Memo"
  size -1 -1 204 70
  option dbu
  text "(separate nicks with a space)", 3, 126 7 72 8
  edit "", 101, 19 6 105 10, autohs
  button "To:", 100, 7 6 11 10, flat
  edit "", 200, 6 19 193 31, autovs vsbar multi
  button "Send", 201, 55 54 37 12
  button "Cancel", 202, 108 55 37 12, cancel
}

on *:dialog:memo.new:init:*:{ 
  If (%memo.reply) { 
    unset %memo.reply
    did -a memo.new 200 $gettok($read(memos/inbox.txt,w,* $+ $did(memo.main,100).seltext $+ *),4,58)
    did -f memo.new 200
    did -c memo.new 200 1 1 $len($did(200) + 1)
  }
  If (%memo.outbox) {
    unset %memo.outbox
    did -a memo.new 200 $gettok($read(memos/outbox.txt,w,* $+ $did(memo.main,200).seltext $+ *),4-,58)
    did -a memo.new 101 $gettok($read(memos/outbox.txt,w,* $+ $did(memo.main,200).seltext $+ *),1,45)
  }
}

on *:dialog:memo.new:sclick:*:{
  If ($did == 100) { dialog -drmo memo.contacts memo.contacts }
  If ($did == 201) && ($did(101)) { 
    set %memo.write.nicks $numtok($did(101),32)
    dialog -n memo.new 
    dialog -n memo.main
    set %memo.num 1
    set %memo.new.text $did(200)
    If (%memo.write.nicks == 1) { ms send $did(101) $did(200) }
    else { .timermemo %memo.write.nicks 4 memosend $did(101) }
    set %memo.new.write $did(101) - $asctime(mmm d - H:nn:ss) : $did(200)
    dialog -x memo.new
  }
}

;=======================View========================
dialog memo.view {
  title "Memo from"
  size -1 -1 204 53
  option dbu
  edit "", 1, 6 3 193 31, read autovs vsbar
  button "Done", 3, 82 38 37 12, ok
  button "Add to Contacts", 2, 0 43 45 9
}

on *:dialog:memo.view:init:*:{ 
  dialog -t $dname $did(memo.main,%memo.view.num).seltext
  If (%memo.view.num == 100) { did -a $dname 1 $gettok($read(memos/inbox.txt,w,* $+ $did(memo.main,%memo.view.num).seltext $+ *),4-,58) }
  elseif (%memo.view.num == 200) { did -a $dname 1 $gettok($read(memos/outbox.txt,w,* $+ $did(memo.main,%memo.view.num).seltext $+ *),4-,58) }
  elseif (%memo.view.num == 300) { did -a $dname 1 $gettok($read(memos/saved.txt,w,* $+ $did(memo.main,%memo.view.num).seltext $+ *),4-,58) }
}

on *:dialog:memo.view:sclick:2:{ write memos/contacts.txt $$gettok($did(memo.main,%memo.view.num).seltext,1,45) }

on *:dialog:memo.view:close:*:{ unset %memo.view.num }

;======================Contacts======================
dialog memo.contacts {
  title "Contact List"
  size -1 -1 90 97
  option dbu
  list 1, 2 2 85 82, size
  button "New Contact", 2, 2 85 40 9
  button "Delete", 3, 47 85 40 9
}

on *:dialog:memo.contacts:init:*:{
  filter -cxfo memos/contacts.txt memo.contacts 1 $crlf
}

on *:dialog:memo.contacts:sclick:*:{
  If ($did == 2) { 
    dialog -n memo.main 
    dialog -n memo.contacts
    If ($dialog(memo.new)) { dialog -n memo.new }
    write memos/contacts.txt $$input(Enter new contact nick:,eo,New Contact) 
    If ($dialog(memo.new)) { dialog -ov memo.new memo.new }
    dialog -ov memo.contacts memo.contacts
    filter -cxfo memos/contacts.txt memo.contacts 1 $crlf
  }
  If ($did == 3) && ($did(1).seltext) { write -dl $+ $did(1).sel memos/contacts.txt | filter -cxfo memos/contacts.txt memo.contacts 1 $crlf }
}

on *:dialog:memo.contacts:dclick:1:{ If ($dialog(memo.new)) { did -ra memo.new 101 $did(memo.new,101) $did(1).seltext } }

;======================Loading======================
alias -l loadmemos var %dialog $dialog(memo.loading,memo.loading,-4)
dialog memo.loading {
  title "Memo Manager"
  size -1 -1 163 35
  option dbu
  text "Downloading from MemoServ...", 1, 37 13 89 8, center
}

on *:dialog:memo.loading:init:*:{ ms info }

;======================Remotes======================

on ^*:notice:*:?:{
  If ($nick == MemoServ)  {
    If (You have a new memo from * iswm $1-) { haltdef | .timer -m 1 1 newmemo $7 }
    If (You have * new memos. iswm $1-) { haltdef | .timer -m 1 1 newmemos $3 }
    If (Type /msg MemoServ READ * to read it. iswm $strip($1-)) { haltdef }
    If ($strip($1-) == Type /msg MemoServ LIST NEW to list them.) { haltdef }

    If (%memo.open) {
      haltdef
      If (%memo.write.nick)  {
        If (!$read(memos/inbox.txt,w,* $+ %memo.write.info $+ *)) { write Memos/inbox.txt %memo.write.info : $1- }
        unset %memo.write.*
      }
      If (You currently have * memo* iswm $1-) { set %memo.total $strip($4) | ms read new }
      elseif (Memo * from * iswm $1-) {
        set %memo.write.nick $4 
        set %memo.write.info $4 - $remove($5,$chr(40)) $6 - $7
        If ($2 == %memo.total) { ms del all | dialog -x memo.loading }
      }

      elseif ($1- == You have no new memos.) || ($1- == You have no memos.) {
        unset %memo.write.*
        If ($dialog(memo.loading)) { dialog -x memo.loading | loadlists }
      }

      elseif (Last memo to * has been cancelled. iswm $1-) { .timer -m 1 1 memocancely }
      elseif ($1- == No memo was cancellable.) { .timer -m 1 1 memocanceln }
      elseif (Nick * isn't registered. iswm $1-) { If (%memo.write.nicks) { dec %memo.write.nicks } | .timer -m 1 1 nonick $strip($2) }
      elseif (Memo sent to * iswm $strip($1-)) { 
        dec %memo.write.nicks
        If (%memo.write.nicks == 0) { unset %memo.write.nicks | write memos/outbox.txt %memo.new.write | unset %memo.new.write | .timer -m 1 1 memosent }
      }
      elseif ($1- == All of your memos have been deleted.) { loadlists }
    }
  }
}

;=======================Aliases=======================
alias -l newmemo {
  If ($input(You have a new memo from $1 $+ $crlf $+ Open Memo Manager?,y,Memo Alert) == $true) { 
    If ($dialog(memo.main)) { dialog -x memo.main }
    dialog -drmo memo.main memo.main 
  }
}
alias -l newmemos {
  If ($1 isnum) && ($input(You have $1 new memo(s). $+ $crlf $+ Open Memo Manager?,y,Memo Alert) == $true) {
    If ($dialog(memo.main)) { dialog -x memo.main }
    dialog -drmo memo.main memo.main 
  }
}
alias -l memocancely { var %input $input(Last memo to $4 successfully cancelled,o,Memo Cancelled) | dialog -ov memo.main memo.main }
alias -l memocanceln { var %input $input(All memos sent to this user have been read,o,Memo Cancellation Failed)  | dialog -ov memo.main memo.man }
alias -l nonick { var %input $input($1 is not a registered nick,o,Memo Error) | dialog -ov memo.main memo.main }
alias -l memosent { var %input $input(Memo finished sending,o,Success) | dialog -ov memo.main memo.main | dialog -x memo.new }

alias -l loadlists {
  did -r memo.main 100,200,300
  var %memo.num 1
  while ($calc(%memo.num - 1) != $lines(memos/inbox.txt)) {
    did -a memo.main 100 $gettok($read(memos/inbox.txt,%memo.num),1-3,58)
    inc %memo.num
  }
  If (%memo.total isnum) { did -c memo.main 100 $calc($did(memo.main,100).lines - %memo.total + 1) }
  var %memo.num 1
  while ($calc(%memo.num - 1) != $lines(memos/outbox.txt)) {
    did -a memo.main 200 $gettok($read(memos/outbox.txt,%memo.num),1-3,58)
    inc %memo.num
  }
  var %memo.num 1
  while ($calc(%memo.num - 1) != $lines(memos/saved.txt)) {
    did -a memo.main 300 $gettok($read(memos/saved.txt,%memo.num),1-3,58)
    inc %memo.num
  }
}

alias -l memosend {
  ms send $gettok($1-,%memo.num,32) %memo.new.text
  inc %memo.num
}
 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.