CP - Alen Breed Remake - 6

Miscellaneous Forums/Blitz Showcase/CP - Alen Breed Remake - 6

Just knocked up a little thing to add to utils for the player info stuff... Copy this and call it testfile.bb!

; read test file

Print readitem("testfile.bb","speed")
Print readitem("testfile.bb","maxhealth")
Print readitem("testfile.bb","protection")
Print readitem("testfile.bb","toilet")

WaitKey


Function readitem$(filename$,item$)
	filein = ReadFile(filename)
	ret$ = "?Null?"
	lin$ = ""
	Repeat
		l$ = ReadLine(filein)
		lb = Instr(l$,"<"+item+">")
		rb = Instr(l$,"</"+item+">")
		If lb>0 And rb>0
			lb = lb + Len("<"+item+">")
			ret= Mid(l,lb,rb-lb)
		EndIf
	Until Eof(filein)
	CloseFile filein
	Return ret$
End Function

; test file
;<maxhealth>100</maxhealth>
;<speed>0.1</speed>
;<protection>2</protection>