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

  1. /*
  2. ** StringNode Example-1
  3. **
  4. ** Add() AND Sort() 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 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.   n.sort()                    -> Sort (CASE Sense, Alphabetical A...Z)
  30.   shwall(n)                   -> Show Results
  31.   n.sort(TRUE, TRUE)          -> Sort (No CASE Sense, Alphabetical INVERTED Z...A)
  32.   shwall(n)                   -> Show Results
  33.  
  34. EXCEPT DO
  35.   explain_exception()
  36.   END n                       -> Remember ALWAYS TO end an OBJECT
  37.   CleanUp(0)
  38. ENDPROC
  39.  
  40. PROC shwall(n:PTR TO stringnode)
  41.   WriteF('------- \d ----------\n', n.numitems())
  42.  
  43.   IF n.first()                      -> Here we go TO the first node item
  44.     REPEAT
  45.       WriteF('Node:\s\n', n.obj()) -> Node STRING...
  46.     UNTIL n.succ() = FALSE          -> LOOP UNTIL the end
  47.   ELSE
  48.     WriteF('No Nodes in LIST...\n')
  49.   ENDIF
  50. ENDPROC
  51.  
  52.