HTML

Blitz3D Forums/Blitz3D Programming/HTML

asdfasdf(Posted 2004) [#1]
How do I make an HTML Parser?


soja(Posted 2004) [#2]
You can use the InternetOpen, InternetOpenURL, InternetReadFile, and InternetCloseHandle from WinINet.dll to get the HTTP info which you can then parse like plain text. The problem with this is that if your net connection is bad, your program will hang waiting for the timeout. (Threads would help here.)


asdfasdf(Posted 2004) [#3]
Can I make it so I don't have to go online.


electronin(Posted 2004) [#4]
Yeah, just:
get the HTTP info which you can then parse like plain text.

but use ReadFile() for local stuff.


asdfasdf(Posted 2004) [#5]
Can any body give me a example for putting a button on a game?


asdfasdf(Posted 2004) [#6]
Can any body give me a example for putting a button on a game?


asdfasdf(Posted 2004) [#7]
Can any body give me a example for putting a button on a game?


asdfasdf(Posted 2004) [#8]
Can any body give me a example for putting a button on a game?


BlitzSupport(Posted 2004) [#9]
Eh? What are you trying to do?

Parsing HTML directly (at least, the in-depth type used in most web pages) is not a trivial task...

If you're in Blitz Plus and just want to display a page, use CreateHTMLView...


asdfasdf(Posted 2004) [#10]
Well I'm trying to be able to put buttons on a Blitz3D window.


Techlord(Posted 2004) [#11]
A HTML Parser is often requested for B3D, Its interesting that one does not exist in the code archives. However, I have always wanted to write one. Perhaps we can start one here. I'm going to write code and add to this specific post.

In parsing HTML I would read the file byte-by-byte. This makes it simple to parse the html text serially and identify html tags, attributes, special characters, etc. Next we should determine how to handle HTML tags and attributes. Heres some conditions to help:
1. HTML tag keywords are enclosed in < >
2. Formatted Text is enclosed between a HTML start tag (ie:<body>) and stop tag (ie</body>)
3. HTML attributes are followed by an equal sign (ie:<body bgcolor='#FFFFFF">)
4. HTML attribute values are optionally enclosed between single qoute or double quote.

With these conditions, we can create a flow for parsing the text. Finally, we could render the formated text and images to a ImageBuffer for display.

;HTML Parser
Type htmlpage
	Field id%						;page number% (reserved)
	Field typeid%						;format: 1=html
	Field filename$						;filename$						
	Field file%						;page file handle%
	Field byte%						;stores byte read from file
	Field buffer%						;page image buffer
	Field tagflag%						;0=text, 1=htmltag, 2=htmlattribute
	Field x%						;stores page imagebuffer x format coord
	Field y%						;stores page imagebuffer y format coord
End Type

Function htmlpageNew.htmlpage(filename$,typeid%=1)		;creates a new html page object
	this.htmlpage=New htmlpage
	this\id%=0
 	this\typeid%=typeid%
	this\filename$=filename$
	Return this
End Function

Function htmlpageRead(this.htmlpage)				;main html page read function filename$="index.html"
	this\file%=ReadFile(this\filename$)			;file handle
	If this\file%						;if no file handle then runtime error message
		While Not Eof(this\file%)			;parse until end of file
			 htmlpageParse(this\file%)		;html parse
		Wend						
		CloseFile(this\file%)				;close file after parsing
	Else
		RuntimeError(this\filename$+" does not exist!")	;if no file handle then runtime error message
	EndIf							;ditto
End Function

Function htmlpageParse(this.htmlpage)
	Select this\tagflag%					;select html text type
		Case 0;text
			this\byte%=ReadByte(file%)		;read html file byte-by-byte
			Select this\byte%
				Case 60;<
 					this\tagflag%=1
				default
					htmlpageFormatDraw(this)
			End Select
		Case 1;html keyword
			word$=htmlpageWordRead$(file%)
			Select 
				Case
			end Select 
		Case 2;html attribute
		Case 3;html attribute value
	End Select	
End Function

Function htmlpageWordRead$(file%)
	While Not Eof(file)
		byte%=ReadByte(file%)
		Select byte%
			Case 32, ;terminate characters: space
			Default
				word$=word$+Chr(byte%)
		End Select	
	Wend
End Function

Function htmlFormatDraw(this.htmlpage)
End Function




Gabriel(Posted 2004) [#12]
Well I'm trying to be able to put buttons on a Blitz3D window.


That has nothing to do with an HTML parser ( ? ) Go into the GUI section of the toolbox and find a GUI lib ( Jeppe's one is free and 3d, so that'd be a good start. )


eBusiness(Posted 2004) [#13]
Can any body give me a example for putting a button on a game?
Graphics 200,150,0,2
Repeat
	Cls
	Color 255,255,255
	Rect 50,50,100,50,0
	Text 100,75,"Exit",1,1
	Flip
	If MouseDown(1) And MouseX()>=50 And MouseX()<150 And MouseY()>=50 And MouseY()<100 Then Exit
Forever



Agamer(Posted 2004) [#14]
I like html


eBusiness(Posted 2004) [#15]
Html is utterly outdated, not two browser show it the same way, why? Because nothing is defined exact, and because people want features that the basic structure is not designed for, a ton of individual add-on scripting systems have been added, making the mess complete. Whenever I get time I'll make a replacement. DIE HTML!


Techlord(Posted 2004) [#16]
Blitz Programmer,

I understand what your attempting to achieve. You desire 1) to display html pages in Blitz3D, 2) use HTML tags to format your GUI, or 3) create your own markup language to display your GUI. I have desired to do this myself.

Minus all the various script support, Javascript, vbscript, DHTML, etc, HTML is a fairly simple formatting markup language. If simplicity is what you desire, then HTML can meet the need.

IMHO, a HTML for Blitz3D could still be very useful. So I'll continue to work on one and post the code. When complete I ill it to the code archives.


Techlord(Posted 2004) [#17]
Anyone still interested in writting a html parser?


Deldy(Posted 2004) [#18]
Use a xml-parser maybe, and then code the way the code sould be showed?

Just a idea.


John Blackledge(Posted 2004) [#19]
What I'd really like to see is a CreateHtml object/function for Blitz3D.
Not to parse html but just to display a page which has been create elsewhere.
Anyone up to writing a dll which hooks into the Microsoft dll which does exactly that?


poopla(Posted 2004) [#20]
I might be interrested in doing it. How many people want this?


Techlord(Posted 2004) [#21]
John,

I would like to see that as well. A HTML parser written with Blitz3D could be very benificial as well. An XML parser would probably be even more benificial.


John Blackledge(Posted 2004) [#22]
What I really want is to create my product's manual as a web page etc, then just say to Blitz: Display it here.


poopla(Posted 2004) [#23]
I'm not going to ber doing any dynamic linking to a microsoft object, but I have thought out writting a blitz parser for doing this. More later.


John Blackledge(Posted 2004) [#24]
Good on you, Go for it.