[Gambas-user] Problem with printing picture in executable

GuruLounge - MailLists maillists at ...1367...
Fri May 12 17:58:29 CEST 2006


Brian,

You should include your Gambas version and platform.

Jeff

On Fri, 2006-05-12 at 13:40 +1000, Brian Edwards wrote:
> Hi,
> 
> I am a new Gambas user and have just written a nice Address Book program
> to demonstrate the use of databases using SQLite.
> 
> It has been quite a learning experience but all is working very nicely
> except for one problem. Each year my with and I send dozens of Christmas
> Cards and I have included a routine to extract all contacts to whom we
> send Christmas Cards and print out labels for with a little picture of
> holly an bell in the top right corner.
> 
> This works perfectly running the program from the Gambas IDE but fails
> when I try to run it as a standalone executable.
> 
> I get 13[Null object] failure message.
> 
> Note the executable prints out normal labels without the picture.
> 
> The picture path is the same as the executable and is ./picture name.
> 
> I thought this should work OK as I can open the database using
> ./databasename.
> 
> What am I doing wrong?
> 
> The labelPrint() subroutine is attached.
> 
> Apart from this I am having great fun.
> 
> Brian
> 
> plain text document attachment (labelPrint()~)
> '**********************************************************************************************
> 
> 
> PUBLIC SUB labelPrint(txtQuery AS String, txtXmas AS String)
> 'txtQuery is the sql function and txtXmas is to let this sub 
> 'know that it is printing Xmas labels
> 
> DIM rData AS Result
> DIM intContactNo AS Integer 'the total number of contact labels to print
> DIM iNd AS Integer 'a counter index
> DIM iSt AS Integer 'is label number - 14 labels per page
> DIM iSt01 AS Integer 'is label row counter - 2 columns of 7 rows
> DIM iR AS Integer 'printing position from left on page 
> DIM iT AS Integer 'printing position from top of page
> DIM tName AS String 'string to concatenate name
> DIM tState AS String 'string to concatenate state and poscode
> DIM pXmas AS Picture ' jingle bells picture
> 
> 
> 
>   rData = $hConn.Exec(txtQuery)  'run the query
>     
>   Picture["./jingle_bells_01.png"] = pXmas 'I don't think this does anything
>   pXmas = Picture["./jingle_bells_01.png"] ' gets the picture
>     
>   iSt = 1 'start printing at label 1 - column 1, row 1
>   
>   intContactNo = rdata.Count 'how many labels
>   rData.MoveFirst 'get the first
>   
>   IF Printer.Setup() THEN RETURN  'setup the printer 
> 
>   Draw.Begin(Printer) ' Initializes the draw
> 
>   Draw.Font.Name = "Times New Roman" 'selects the font
> 
>   FOR iNd = 1 TO intContactNo STEP 1 'printing loop start
>   
>     IF iSt > 1 THEN  'begin checking which label to print 
>       
>      IF iSt MOD 14 = 1 AND iSt <> 1  THEN  'check if it is greater that 14
>         PRINTER.NewPage 'and if so print new page
>         iSt = 1 'and also reset the lable number counter
>      END IF
>     END IF  
>     
>      tName = (rData["title"] &" " & rData["given01"] & " " & rdata["surname"]) 'concatenate the names
>      'and make it look pretty if there is no title
>      IF rData["title"] = ""  THEN tName = ( rData["given01"] & " " & rdata["surname"])
>      
>     
>     tState = (rData["state"] &"  " & rData["postcode"])'concatenate state and postcode
>     
> 'Set the Initial Left(iR) and Top(iT) Margins at 21mm - 1 = 0.042mm
>   iR = 500
>   iT = 500
>  
>  'Calculate horizontal position of Start Label. If the RHS one set Left Margin to 126mm
>   
>   IF (iSt MOD 2 = 0) THEN iR = 3000
>  
>  'Calculate verticle positon of  Label- label height = 37mm
>  
>  iSt01 = Int ((iSt-1)/2)
>  IF iSt > 2 THEN  iT = (500 + iSt01*880)
>  
>  'If its Xmas print jingle bells at top right of label
>  
>  IF txtXmas = "y"  THEN
>   Draw.Picture(pXmas, iR + 1600 ,iT)
>  END IF
>  
>  'print address
>  
>  Draw.Text(tName, iR,iT)
>  iT = iT + 120 'new line
>  Draw.Text(rData["street01"],iR,iT)
>  iT = iT + 120
>  IF rData["street02"] <> "" THEN 'some addresses don't have two streets
>   Draw.Text(rData["street02"], iR, iT)
>   iT = iT + 120
>  END IF
>  Draw.Text(rData["city"], iR, iT)
>  iT = iT + 120
>  Draw.Text(tState, iR, iT)
>  iT = iT + 120
>  Draw.Text(rdata["country"], iR, iT)
>  iT = It + 120 
>   
>  iSt = iSt + 1 'increment label number
>  
>  rData.MoveNext ' get next contact  
>    
>  NEXT
>  
> 'when all contacts processed print page
> 
> Draw.End
> END
> 
> '**********************************************************************************************
> 
> PUBLIC SUB BtnXmas_Click()
> 
>  labelPrint("select * from Table01 where xmas = 'y'order by surname","y")
> 
> END
> 
-- 

     .^.
     /V\
    /( )\
    ^^-^^
Linux Advocate





More information about the User mailing list