[Gambas-user] Mystery characters added to start of html file

richard terry rterry at ...1822...
Sat Jan 26 22:46:38 CET 2008


I'm writing my drug browser which consists of a 50MB postgres backend of data 
and a simple gui to search/manipulate/display the data (see the screen dump). 
I've written something similar in basic 11 years ago, and a couple of years 
ago in wxPython, so its only taken a couple of hours to knock up, though I'm 
still struggling with the gambas syntax (shouldn't be as it is quite 
simple!!!)

The drug product information retreived after quite complex multi-join queries 
is quite simple - fields such as $Result!composition, $Result!indications 
etc, and I've chosen to do a string substitute of the fields for a 
corresponding name in a hmtl template like this:

<h2> <FONT COLOR="#000070"><a name=Composition></a>Composition</FONT></h2>
%(composition)s<br>

(in my python version this %(composition)s structure meant I could substitute 
a whole dicitonary into the template in one call, don't know if that is 
possible in gambas basic so I've just done a section by section substitution.

Anyhow, I hence end up with the html document as per the picture which is 
actually in a textedit control

If I save it from the internal string generated (not from the textedit) using 
this code:

  DIM hfile AS File
  DIM sFilename AS String
   sFilename = "/home/richard/tmp/temp.html"
   hfile = OPEN sFilename FOR WRITE CREATE 
   WRITE #hfile, st      'st is the html string I've created
   CLOSE #hfile

I end up with a couple of extra bytes at the start of the file which then are 
displayed at the top if I re-display the  file.

��<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>  
<meta content="text/html;

I've checked by printing out at the console prior to the write, and they don't 
show up as being in the string.

Thanks in advance, any help appreciated.

Richard
-------------- next part --------------
A non-text attachment was scrubbed...
Name: demo_drug_browser_gambas.png
Type: image/png
Size: 144711 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20080127/7755e681/attachment.png>


More information about the User mailing list