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

  1. /*
  2. ** StringNode Example-1
  3. **
  4. ** setattrs() AND change() example
  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 sn:PTR TO stringnode
  18.  
  19.   NEW sn.stringnode()
  20.  
  21.   sn.setattrs([
  22.               TAGSTR_MAXCHARS, 3,   -> We want a maximum of 3 bytes loss
  23.               0,0])
  24.  
  25.   sn.add('Hello My Big World!')     -> We create a STRING
  26.   WriteF('Str:\s - Chars(\d)\n', sn.obj(), StrMax(sn.obj()))
  27.  
  28.   sn.change('Hello Big World!')     -> We change this STRING
  29.                                     -> (NOTE: StrMax() remains the same!
  30.   WriteF('Str:\s - Chars(\d)\n', sn.obj(), StrMax(sn.obj())) 
  31.  
  32.  
  33.   sn.change('Hello')    -> We change again with a slighty smaller STRING
  34.                         -> This time STRING is resized
  35.   WriteF('Str:\s - Chars(\d)\n', sn.obj(), StrMax(sn.obj()))
  36.  
  37. EXCEPT DO
  38.   explain_exception()
  39.   END sn
  40.   CleanUp(0)
  41. ENDPROC
  42.