home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / RB3641.ZIP / EX2 / READLIST.MTH < prev    next >
Text File  |  1991-12-16  |  1KB  |  39 lines

  1.  
  2.  
  3.  
  4. !ToDoList methods !
  5.    
  6. readList
  7.  
  8.     "Read the ToDo list from disk.
  9.      The list is stored as a binary data using the 
  10.      ObjectFiler. so a new collection
  11.     can be built by loading the contents of the file 
  12.      by using the ObjectFiler.
  13.      This method is used in two places:
  14.     - when ToDo application window is opened.
  15.     - when Open is selected in File-pulldown. "
  16.  
  17.     | input tmpList testItem |
  18.  
  19.     input := Disk file: 'TODOFILE.OBJ'.
  20.     input close.
  21.     input := Disk file: 'TODOFILE.OBJ'.
  22.     ((input contents) = '') ifTrue: [            
  23.                 tmpList := OrderedCollection new.
  24.                 testItem := ToDoItem new.
  25.                 testItem type: 'Personal'.
  26.                 testItem deadline: '99.12.31'.
  27.                 testItem description: 'Celebrate!!'.
  28.                 "testItem priority: 'High'."
  29.                 testItem priority: 1.
  30.                 testItem completed: false.
  31.                 5 timesRepeat: [ tmpList add: testItem ].    
  32.     ]
  33.     ifFalse: [
  34.         tmpList := ObjectFiler loadFromPathName: 'TODOFILE.OBJ'.
  35.     ].
  36.     input close.
  37.  
  38.  ^(self replaceFrom:1 to:(self size) with: tmpList)! !
  39.