Code archives/Miscellaneous/word parse

This code has been declared by its author to be Public Domain code.

Download source code

word parse by Kev2007
using a simple lexer to parse the passed string and print out each spaced word.
show_Tokens("this is a line of text, using a simple lexer to display each word.")
Function show_Tokens(SLine$,identifier$=" ")
	;
	For loop = 1 To Len(SLine$)
		loop1 = loop - pos - 1 
		pos = Instr(SLine$,identifier$,loop)
		If pos > 0 Then
			Print Trim(Mid(SLine$,loop1+loop,pos-loop))
			loop = pos
		ElseIf(loop1+loop < Len(SLine$))
			Print Trim(Mid(SLine$,loop1+loop,pos-loop))
			Exit
		EndIf
	Next
End Function

Comments

None.

Code Archives Forum