;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; inlist ;;; If item is found, returns "true". If not, returns "false" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; alias inlist { var %cur = 1 :start1 if (%cur <= $lines($1)) { if ($2- = $read($1, %cur)) { goto true1 } else { inc %cur goto start1 } } return 0 goto end1 :true1 return 1 :end1 } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; getline ;;; If item is found, returns the number of line. If not, returns "0" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; alias getline { var %cur = 1 :start2 if (%cur <= $lines($1)) { if ($2- = $read($1, %cur)) { goto get2 } else { inc %cur goto start2 } } else return 0 goto end2 :get2 return %cur :end2 } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; additem / delitem ;;; Adds or deletes an item (aka line) to the list (aka text file) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; alias additem { if ($exists($1)) { if ($inlist($1, $2-) != false) { echo 04 » " $+ $2- $+ " already exists! return } else { write $1 $2- echo 09 » You have added " $+ $2- $+ " to " $+ $1 $+ " } } } alias delitem { if ($exists($1)) { if ($inlist($1, $2-) != true) { echo 04 " $+ $2- $+ " was not found at " $+ $1 $+ " return } else { write -dl $+ $getline($1,$2-) $1 echo 09 You have deleted " $+ $2- $+ " at " $+ $1 $+ " } } }