Re: printing on same line

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Mon, 11 Aug 2003 07:07:11 +0000 (08/11/03 17:07:11)
, Steve <bleak_outlook at hotmail.com> wrote:

>
>
> Ok, I am willing to believe that I am an idiot, so please bear with me.
>
> Running the couple lines of code I have included below, my printer will 
> not change lines.  I have tried placing newline characters within the 
> data and manually between lines to no avail.  It prints everything, just 
> does it on top of the last line.  I know the printer is fine because 
> everything else I print is fine.  Am I missing something here?
>
> imp = 0
> savenumb = open(char_save_name1, "r")
>
> if savenumb = -1 or savenumb = 0 then
> 	message = message_box("No File Found", "Its way broke.", 1)
> 	return
> end if
>
> while 1 do
> curr_line = gets(savenumb)
>
> if atom(curr_line) then
> exit  end if
> 	
> 	wPuts(Printer, curr_line)	
> 	wPuts(Printer, "\n")
> 	
> end while
>
> close(savenumb)	
>

Definitely not an idiot question.

The 'problem' is that, when using wPuts(), control characters such as 
LineFeed are not translated as actions to be performed but are literally 
used as characters to be printed.

What you need to do to move the next print position to the start of the 
next line is to set the X,Y position before printing. A way of doing this 
is to get the getTextExtent values for each 'line' you print. This will 
return the height, in pixels, of the line to print. To move to the next 
line, you need to keep track of the current Y value and increment this 
before printing a line.

Initially 'Y' will be zero, meaning it starts at the top of the page.

Another alternative is to use drawText() instead of wPuts(). This will 
automatically return the height of the text just printed, you then add this 
to the next 'line' position before printing the next line.

-- 

cheers,
Derek Parnell

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu