All pastes #56982 Raw Edit

Mine

public text v1 · immutable
#56982 ·published 2006-05-19 01:02 UTC
rendered paste body
alias up { return $upper($left($1,1)) $+ $right($1,-1) $2- }
alias edit {
  dialog -md edit edit
}
alias add {
  dialog -amd add add add
}
dialog edit {
  title "Edit .txt"
  size -1 -1 143 86
  option dbu
  list 1, 4 5 81 77, size
  button "Save", 6, 96 55 37 12
  button "Cancel", 7, 96 69 37 12
  edit "", 2, 90 15 50 10, autohs
  text "Value", 3, 90 5 25 8
  button "Add", 4, 96 27 37 12
  button "Remove", 5, 96 41 37 12
}
dialog add {
  title "Add Item"
  size -1 -1 120 40
  option dbu
  text "Item", 1, 3 3 14 8
  text "Value", 2, 49 3 15 8
  edit "", 3, 3 12 41 10, autohs
  edit "", 4, 49 12 66 10, autohs
  button "Accept", 5, 20 24 37 12
  button "Cancel", 6, 64 24 37 12
}

on *:DIALOG:edit:sclick:6:{
  if ($did(edit,2).edited == $true) { /write -ds $+ %edititem prices.txt
  /write prices.txt %edititem $did(edit,2).text }
  dialog -x edit
}
on *:DIALOG:edit:sclick:7:{
  dialog -x edit
}
on *:DIALOG:edit:sclick:5:{
  /write -ds $+ %edititem prices.txt
}
on *:DIALOG:edit:init:*:{
  var %i = 0
  /while ($lines(prices.txt) >= %i) {
    inc %i 1
    /tokenize 58 $read(prices.txt,%i)
    /did -a $dname 1 $$1
  }
}
on *:DIALOG:edit:close:*:{
  unset %i
}
on *:DIALOG:edit:sclick:1:{
  set %edititem $did(edit,1).seltext $+ $chr(58)
  /tokenize 58 $read(prices.txt, s, %edititem)
  /did -ra $dname 2 $1-  
  //echo
}
on *:DIALOG:edit:sclick:4:add
on *:DIALOG:add:sclick:6:{
  dialog -x add
}
on *:DIALOG:add:sclick:5:{
  if ($did(add,3).edited == $true) && ($did(add,4).edited == $true) {
    /write prices.txt $did(add,3).text $+ $chr(58) $did(add,4).text
  }
  dialog -x add
}
on *:TEXT:!price*:#:{
  var %sitem = $replace($2-,$chr(32),$chr(95))
  if ($read(prices.txt,s,%sitem $+ $chr(58)) == $null) { notice $nick Item Not Found | halt }
  else { notice $nick  $+ $up(%sitem) $+  $replace($read(prices.txt,s,%sitem $+ $chr(58)),$chr(95),$chr(32))
  }