TGC Codebase Backup



Parse String Function by mintman

22nd Nov 2003 21:05
Summary

This function will parse a string.



Description

This function will parse a string and find the specified entry from the parsed strings.
It needs the string to parse, the delimiter (such as a space, or a comma) and the entry to get (starting at zero).

Example:
Print ParseString("Hello, Mello, Jello, Dello", ",", 2)

Output:
Jello



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    function ParseString(String$, Delimiter$, ValueNumber)
   z = 0
   repeat
   ParseStringRestart:
      a$ = mid$(String$,z)
      if a$ = Delimiter$
         i = i + 1
         z = z + 1
         goto ParseStringRestart
      endif
      if i = ValueNumber then value$ = value$ + a$
      z = z + 1
   until i > valuenumber or z > len(string$)
endfunction value$