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

  1. /*
  2. ** StringNode Example-5
  3. **
  4. ** add(), search(), clear() AND change() 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.search('momm')             -> The search is CASE insensitive AND match the first one ;)
  31.   WriteF('Current:\s\n', n.obj()) -> Here we are!
  32.  
  33.   n.change('My Mommy')       -> Wow! Now MOMMY is My Mommy!!!
  34.   shwall(n)
  35.  
  36.   n.clear()                  -> Empty StringNode!
  37.   shwall(n)
  38.  
  39. EXCEPT DO
  40.   explain_exception()
  41.   END n                       -> Remember ALWAYS TO end an OBJECT
  42.   CleanUp(0)
  43. ENDPROC
  44.  
  45. PROC shwall(n:PTR TO stringnode)
  46.   WriteF('------- \d ----------\n', n.numitems())
  47.  
  48.   IF n.first()                      -> Here we go TO the first node item
  49.     REPEAT
  50.       WriteF('Node:\s\n', n.obj()) -> Node STRING...
  51.     UNTIL n.succ() = FALSE          -> LOOP UNTIL the end
  52.   ELSE
  53.     WriteF('No Nodes in LIST...\n')
  54.   ENDIF
  55. ENDPROC
  56.  
  57.