Return a valid line.

Blitz3D Forums/Blitz3D Programming/Return a valid line.

Bobysait(Posted 2006) [#1]
This function allow to have commented text in your file.

for example, you want to read an xml file, and you just want to return the values, but not commented texts .

Notice the function will "self-loop" to go to the next line and check it until the line is a valide one.

( you can replace the "ReadLine" command by your own , for example if you have an encryption function to return values )

Function VER_Line$(File%,Ligne$)
	l_f%	=	File
	l_l$	=	Ligne
	If Len (l_l)>0
		ParseLine$=Left(l_l,2)
		If ParseLine="<!" ; Paragraphe commenté ===============
			DebugLog "commentaire :"+l_l
			Repeat
				l_l	=	ReadLine(l_f)
				DebugLog "			"+l_l
				ExitLoc=Instr(l_l,"/!>")
				If exitLoc>0 
					l_l=VER_Line(File,ReadLine(l_f))
					Return l_l
				EndIf
			Forever
		ElseIf ParseLine="//" ; ligne commentée =================
			DebugLog "commentaire :"+l_l
			; on verifie la ligne suivante!
			l_l=VER_Line(File,ReadLine(l_f))
			Return l_l
		Else
			Return l_l
		EndIf
	Else ; ligne vierge =====================================
		l_l=VER_Line(File,ReadLine(l_f))<>0
		Return l_l
	EndIf
End Function




feel free to comment, and if you have any code faster, Ring me !!! :)