Re: column aligmnent %4d versus %d

new topic     » goto parent     » topic index » view thread      » older message » newer message
petelomax said...
jessedavis said...

I just wrote a short euphoria routine that allows me to print to a inkjet printer from within euphoria without a lot of hassle. The problem is

Maybe if you post the code someone will spot something

Pete

        startDoc( "EuPrint Job")      ---|----WIN32LIB PRINTER ROUTINES 
        startPage()     -----------------| 
 
 
        for i = 1 to length(txt) do 
                integer len = length(txt[i]) 
                sequence build_line = {} 
                if line_num then 
                    build_line = build_line & sprintf("%4d%1s", {line_num,lne_flg}) 
                    build_line = build_line & txt[i] 
                    line_num += 1     
                end if                
                wPuts({Printer,left_margin,top_margin +(i-1) * page[6]},build_line)    --page[6] is the line spacing 
        end for	 
		 
	endPage()   ---------| 
        endDoc()        -----|----W32LIB ROUTINES TO HANDLE PRINTER 
        releasePrinter()  ---| 
 

1st line: XXX9Xtext string X is a space character
2nd line: XX10Xtext string

I cannot illustrate it here but the problem is that on the printout page the "9" is not above the "0" in "10" but between the "1' and the "0" in "10" it's shifted 1/2 character to the left. My understanding of the format string is that it should always place 4 character slots on the page, placing the integer as is appropriate and should not attempt to "center" or whatever it's trying to do. Since I am using a constant width font the characters should stay put, in the slots provided.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu