home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 106 / EnigmaAmiga106CD.iso / www / afc / afc-dir / stringnode_examples.lha / Examples / First_Del_Example.e < prev    next >
Encoding:
Text File  |  1997-09-09  |  1.6 KB  |  61 lines

  1. /*
  2. ** StringNode Example-2
  3. **
  4. ** add(), del(), first(), succ() AND last() methods.
  5. **
  6. ** (C)Copyright 1996/97 Amiga Foundation Classes
  7. **
  8. ** See: http://www.intercom.it/~fsoft/afc.html
  9. **
  10. **      FOR more info about AFC AND more modules
  11. */
  12.  
  13. MODULE 'afc/StringNode',   -> Our MAGIC MODULE
  14.        'afc/Explain_Exception'
  15.  
  16. PROC main()  HANDLE
  17.   DEF n:PTR TO stringnode      -> This is our OBJECT instance
  18.  
  19.   NEW n.stringnode()           -> OBJECT initialization
  20.  
  21.   n.add('Zorro')              -> Here we add some items...
  22.   n.add('Batman')
  23.   n.add('Superman')
  24.   n.add('Gold Drake')
  25.   n.add('Mandrake')
  26.   n.add('MOMMY')
  27.  
  28.   shwall(n)                   -> Here we see them
  29.  
  30.   n.first()                   -> This method should be checked agains FALSE...
  31.   n.del()                     -> It is DEAD!
  32.   shwall(n)                   -> Show Results
  33.  
  34.   n.succ()                    -> Two items later... (The first killed...)
  35.   n.del()                     -> Another Kill!
  36.   shwall(n)                   -> Show Results
  37.  
  38.   n.last()                    -> The last item
  39.   n.del()                     -> Is DEAD too!
  40.   WriteF('Last:\s\n', n.obj()) -> Now this is the last
  41.   shwall(n)
  42.  
  43. EXCEPT DO
  44.   explain_exception()
  45.   END n                       -> Remember ALWAYS TO end an OBJECT
  46.   CleanUp(0)
  47. ENDPROC
  48.  
  49. PROC shwall(n:PTR TO stringnode)
  50.   WriteF('------- \d ----------\n', n.numitems())
  51.  
  52.   IF n.first()                      -> Here we go TO the first node item
  53.     REPEAT
  54.       WriteF('Node:\s\n', n.obj()) -> Node STRING...
  55.     UNTIL n.succ() = FALSE          -> LOOP UNTIL the end
  56.   ELSE
  57.     WriteF('No Nodes in LIST...\n')
  58.   ENDIF
  59. ENDPROC
  60.  
  61.