home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 106 / EnigmaAmiga106CD.iso / www / afc / afc-dir / itemparser_examples.lha / Examples / itemParser_Example1.e < prev   
Text File  |  1999-02-03  |  2KB  |  81 lines

  1. /*
  2.  
  3.   $VER: itemParser_Example_1 V1.00 - By Fabio Rotondo
  4.  
  5.   (C)Copyright Amiga Foundation Classes
  6.  
  7.   This source is provided in Public Domain, you
  8.   can use it and modify it without any written
  9.   permission by the authors.
  10.  
  11.   For more info about AFC and latest releases, please
  12.   visit:
  13.  
  14.     http://www.intercom.it/~fsoft/afc.html
  15.  
  16. */
  17.  
  18. MODULE 'afc/itemParser'
  19.  
  20. PROC main()
  21.   DEF ip:PTR TO itemParser          -> itemParser instance
  22.   DEF s:PTR TO CHAR                 -> a pointer to strings
  23.   DEF t=0                           -> a counter
  24.  
  25.   NEW ip.itemParser()               -> Here we create the class
  26.  
  27.  
  28.   /*
  29.       In the following line we'll parse a string.
  30.       Please, note the double quotes around the 3rd item.
  31.   */
  32.  
  33.   ip.scan('Item1 Item2 "This is a very long Item3" Item4')
  34.  
  35.   IF (s:=ip.first())
  36.     REPEAT
  37.       WriteF('Item (\d): \s\n', t++, s)
  38.     UNTIL (s:=ip.succ())=FALSE
  39.   ENDIF
  40.  
  41.  
  42.   /*
  43.       Here there is a typical example of how to use
  44.       the search() method.
  45.  
  46.       The first search() will fail because we are
  47.       searching for the exact match "Item3", but the
  48.       Item 3 string is far longer (see above)
  49.  
  50.       The right search() pattern is shown in the second
  51.       search() attemp.
  52.  
  53.       NOTE: remember to always check against NULL return values
  54.             from the search method!!
  55.  
  56.       NOTE2: as mentioned in the search() documentation, you can
  57.              use all valid AmigaDOS wildcards and search is case
  58.              insensitive.
  59.  
  60.   */
  61.  
  62.  
  63.   IF (s:=ip.search('Item3'))
  64.     WriteF('Found1: \s\n', s)
  65.   ELSE
  66.     WriteF('"Item3" search failed!\n')
  67.   ENDIF
  68.  
  69.   IF (s:=ip.search('#?item3'))
  70.     WriteF('Found2: \s\n', s)
  71.   ELSE
  72.     WriteF('"#?Item3" search failed!\n')
  73.   ENDIF
  74.  
  75.  
  76.  
  77.   END ip
  78.   CleanUp(0)
  79. ENDPROC
  80.  
  81.