Tag System - Up The Swanie

Blitz3D Forums/Blitz3D Beginners Area/Tag System - Up The Swanie

Hiya All! :)

As you'll see from the routine below, I am trying to implement a tag system (like html codes to switch what should effect the text) And I have never used the Left$ or Right$ commands before, and as you will also spot that it doesnt work in my favour at all. And thus, I'd really appreciate any help in getting it working as it should do.

What it should do is:

Read the Message$ text
Decipher any tags found in the square brackets
Reset to just before the tag
Change the colour / effect or what have you
And draw the finished outcome.

Im using an imagebuffer as I can reposition the whole thing alot easier, then calling to update each time etc.

Graphics 640,480
SetBuffer BackBuffer()

Global message$
message$=			"[R]Please [G]Change [B]My [P]colors[Return]"  
message$=message$+	"[N]And this is default / normal text and this should be [B]blue Text"

Global char$
Global XPos,YPos
Global Text_Area=CreateImage(640,256)

Draw_To_Screen()

While Not KeyHit(1)
Cls
	DrawImage Text_Area,0,0
Flip
Wend


Function Draw_To_Screen()
SetBuffer ImageBuffer(Text_Area)
For t = 1 To Len(message$)  

	char$=Mid$(message$,t,1)
	
	If char$=Left$(message$,3)="[R]"
		Color 128,000,000
		XPos=Xpos-(3*8)
	End If
	
	If char$=Left$(message$,3)="[G]"
		Color 000,200,000
		XPos=Xpos-(3*8)

	End If
	
	If char$=Left$(message$,3)="[B]"
		Color 000,000,250
		XPos=Xpos-(3*8)
	End If

	If char$=Left$(message$,3)="[P]"
		Color 100,000,250
		XPos=Xpos-(3*8)
	End If
	
	If char$=Left$(message$,3)="[W]"
		Color 255,255,255
		XPos=Xpos-(3*8)

	End If
	
	If char$=Left$(message$,8)="[Return]"
		XPos=0
		YPos=YPos+8
	End If
	
	Text XPos+(t*8),YPos,char$
	
Next
SetBuffer BackBuffer()
End Function


Cheers & Many many thanks,
Mikey F :)