Discussions related to Visual Prolog
vjoer
Posts: 18
Joined: 7 Feb 2006 13:42

Hanoi project in VP9

Unread post by vjoer »

Hello

Has the Hanoi Towers example been tested on the VP 9 release?

My test shows the error:
Server error!
The server encountered an internal error and was unable to complete your request.

Error message:
End of script output before headers: hanoi.exe
Regards
Viorel Farcas
User avatar
Thomas Linder Puls
VIP Member
Posts: 1202
Joined: 28 Feb 2000 0:01

Re: Hanoi project in VP9

Unread post by Thomas Linder Puls »

I am afraid that it is long time since we have tested this.

It will work if you change the last part of the "hanoi.pro" file like this:

Code: Select all

constants     docBegin = @'Content-Type: text/html; charset=UTF-8   <!DOCTYPE html> <html> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <body> <p> '.     docEnd = @' </p> </body> </html> '.   clauses     run() :-         O = outputStream_console::new_stdout(),         O:setMode(stream::ansi(utf8)),         stdio::outputStream := O,         stdio::write(docBegin),         ParmList = cgi::getParamList(),         runme(ParmList),         stdio::write(docEnd).   end implement hanoi   goal     mainExe::run(hanoi::run).
The important changes are:
  • The goal should use mainExe::run (it should not initialize the console)
  • The stdio::outputStream should be set manually to an outputStream_console::new_stdout() stream.
  • I will recommend that you use UTF-8 for encoding your HTML.
  • The output stream should be set to that mode
  • The chosen encoding should be stated as part of the "Content-Type" HTTP header
  • I also recommend that you supply a "meta" http-equiv element that also gives the ContentType (It may be overkill)
  • <!DOCTYPE html> says that the content is html5
  • Notice that it is essential that there is a blank line between the HTTP header and !DOCTYPE
We will (in a later version) handle the stream handling in the cgi class.
Regards Thomas Linder Puls
PDC
Post Reply