home *** CD-ROM | disk | FTP | other *** search
- /*
-
- $VER: itemParser_Example_1 V1.00 - By Fabio Rotondo
-
- (C)Copyright Amiga Foundation Classes
-
- This source is provided in Public Domain, you
- can use it and modify it without any written
- permission by the authors.
-
- For more info about AFC and latest releases, please
- visit:
-
- http://www.intercom.it/~fsoft/afc.html
-
- */
-
- MODULE 'afc/itemParser'
-
- PROC main()
- DEF ip:PTR TO itemParser -> itemParser instance
- DEF s:PTR TO CHAR -> a pointer to strings
- DEF t=0 -> a counter
-
- NEW ip.itemParser() -> Here we create the class
-
-
- /*
- In the following line we'll parse a string.
- Please, note the double quotes around the 3rd item.
- */
-
- ip.scan('Item1 Item2 "This is a very long Item3" Item4')
-
- IF (s:=ip.first())
- REPEAT
- WriteF('Item (\d): \s\n', t++, s)
- UNTIL (s:=ip.succ())=FALSE
- ENDIF
-
-
- /*
- Here there is a typical example of how to use
- the search() method.
-
- The first search() will fail because we are
- searching for the exact match "Item3", but the
- Item 3 string is far longer (see above)
-
- The right search() pattern is shown in the second
- search() attemp.
-
- NOTE: remember to always check against NULL return values
- from the search method!!
-
- NOTE2: as mentioned in the search() documentation, you can
- use all valid AmigaDOS wildcards and search is case
- insensitive.
-
- */
-
-
- IF (s:=ip.search('Item3'))
- WriteF('Found1: \s\n', s)
- ELSE
- WriteF('"Item3" search failed!\n')
- ENDIF
-
- IF (s:=ip.search('#?item3'))
- WriteF('Found2: \s\n', s)
- ELSE
- WriteF('"#?Item3" search failed!\n')
- ENDIF
-
-
-
- END ip
- CleanUp(0)
- ENDPROC
-
-