RobK.StringUtils

BlitzMax Forums/BlitzMax Module Tweaks/RobK.StringUtils

Robert(Posted 2005) [#1]
This module provides useful string functions. Originally I wrote it as part of a tokeniser, but I hope others find it handy.

Functions:

split() 'Splits a string into an array of strings
join() 'Joins an array of strings into a single string
classify() 'Determines the type of text in a string, eg Numeric or Whitespace
stringStart() 'Gets start of string until first occurence of a delimiter
stringEnd() 'Gets end of string after last occurence of a delimiter
findSubStrings() 'Finds all occurences of substring in a string
createStringTree() 'Creates a StringTree from an array of strings

Types:

StringTree - used for creating a binary tree of strings which can be searched very quickly.

Methods:

toArray()
find()
insert()
remove()
map()

Documentation available in the commands.htm file in the module's doc folder. Examples in demo.bmx file in the module's folder.

http://www.robertknight.me.uk/files/blitz/robk.stringutils.zip


Beaker(Posted 2005) [#2]
Good range of functions there.


flaith(Posted 2005) [#3]
very usefull functions
thx


Booticus(Posted 2005) [#4]
Lanks! These are perfect! I was just starting to make my own! Talk about the glory of reusable code (and your generosity!)


Takuan(Posted 2005) [#5]
I hate dealing with strings.
You got a picture? Will nail it on my timesaver of the week wall:-)


Idiot(Posted 2006) [#6]
How do you get these to work? I can't find any installation instructions.

I've tried putting them in the mod folder and in the pub.mod folder but I always get the error "can't find interface for module 'pub.stringutils'".

Google was no help either and I can't find documentation on how to put in a new module.


Idiot(Posted 2006) [#7]
error is on the line:
Import pub.stringutils

right after SuperStrict at the start of my program


Jason W.(Posted 2006) [#8]
Idoit,

Follow these steps:

1. Extract the robk.stringutils.zip in the {installed path}\BlitzMax\mod folder.
Mine looks like this: C:\Program Files\BlitzMax\mod\robk.mod

2. Open up a Command Prompt or Click on the START Button --- RUN option, and type the following:
"C:\Program Files\BlitzMax\bin\bmk.exe" makemods -a robk
NOTE: You might want to replace the path if your BlitzMAX is not installed in the same location as above

3. That should build the module for you to use in BlitzMAX.

4. Just run the demo that is located the in the C:\Program Files\BlitzMax\mod\robk.mod\stringutils.mod folder or the example above.

I hope that helps.

Jason


Idiot(Posted 2006) [#9]
I quit blitzmax, followed your instructions above and restarted blitxmax. I get the same error

"can't find interface for module 'pub.stringutils'"

The command prompt didn't have print feedback or anything, so I'm just assuming it worked.


skidracer(Posted 2006) [#10]

error is on the line:
Import pub.stringutils


Idiot, going by the topic title, maybe you should try:

Import RobK.StringUtils


LarsG(Posted 2006) [#11]
I'm sorry, but I couldn't help myself laughing when reading the replies.. :)


Murilo(Posted 2006) [#12]
Idiot, going by the topic title, maybe you should try:

Import RobK.StringUtils

Priceless!


Armitage 1982(Posted 2006) [#13]
Compile Error: Identifier 'TNodeEnum' not found
robk.mod/stringutils.mod/stringutils.bmx line 76

	Method toArray:String[]()
		
		Local result:String[]
		
		Local enum:TNodeEnum=_tree.Keys().ObjectEnumerator()
		
		While enum.HasNext()
			result=result[..result.length+1]
			
			result[result.length-1]=String(enum.NextObject())
		End While
		
		Return result
	End Method


Look's like BlitzMax as change TMAP (or else) since.
Any hint to fix this ?
Thanks ;)


Brucey(Posted 2006) [#14]
I believe TNodeEnum is now called TNodeEnumerator.


Armitage 1982(Posted 2006) [#15]
exellent suggestion Brucey ^^
And you know what ?


Compile Error: Identifier 'FindNode' not found
robk.mod/stringutils.mod/stringutils.bmx line 48

	Rem
	bbdoc: Finds a string in a StringTree
	returns: True if strToFind is found, or False otherwise.
	End Rem
	Method find:Int(strToFind:String)
		If (_tree.FindNode(strToFind))
			Return True
		Else
			Return False
		EndIf
	End Method


Ahahah ^^ hope it's not endless.
Why TNodeEnumerator isn't present in the doc ?

Thanks ;)


FOODy(Posted 2006) [#16]
I think FindNode must changed in _FindNode.
Look at BRL.Map Module for more Informations.

Greet,
FOODy


Armitage 1982(Posted 2006) [#17]
Thanks you both Foody and Brucey you saved the day ^^
All systems goes ;)