1. column aligmnent %4d versus %d

Euphoria 4.00.05 Windows 7 Pro
Another off-the-wall question. 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 everyone asking me, "Can't you keep the columns straight?" So, I did a little test the result of which is that if I use the formatting string -> "%4d" <- I get columns that have the correct number of spaces and digits and are generally aligned but wander by about 1/2 character width. If I use the format string -> "%d <- I get perfect character alignment; however, since there are different numbers of digits the entire column moves back and forth. I am using w32lib function wputs to print. The text string sent to wputs is created by sprintf(). I am using courier, a monospace font. I have tentatively ruled out the printer (HP8610) - wputs combination because I can print a single character anywhere on the page that is "bang on" location wise (to the nearest few thousandths of an inch - dial calipers!). Has anyone out there explored this? Maybe found a solution? I suppose I could draw the characters on the page and then print the dots? Bite your tongue!

Thanks, in advance,
jd

new topic     » topic index » view message » categorize

2. Re: column aligmnent %4d versus %d

Instead of using 4% for placement, Why don't you try position(left,top)

Don Cole

new topic     » goto parent     » topic index » view message » categorize

3. Re: column aligmnent %4d versus %d

DonCole said...

Instead of using 4% for placement, Why don't you try position(left,top)

Don Cole

Thanks for the quick reply.
I guess I don't understand. position(x,y) applies only to the cursor position of the console monitor.

regards, jd

new topic     » goto parent     » topic index » view message » categorize

4. Re: column aligmnent %4d versus %d

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

new topic     » goto parent     » topic index » view message » categorize

5. Re: column aligmnent %4d versus %d

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 message » categorize

6. Re: column aligmnent %4d versus %d

OK, reduce it to the simplest thing that still goes wrong. Try inserting (before the loop start)

--temp: 
    txt = {"nine", 
           "ten"} 
    line_num = 9 

It may also help to add

?{{Printer,left_margin,top_margin +(i-1) * page[6]},build_line} 

immediately before/after the wPuts() line, see if that exposes anything

new topic     » goto parent     » topic index » view message » categorize

7. Re: column aligmnent %4d versus %d

I still think the best way is to use position to force the line to be straight.

I included a small code I whipped up real fast.

You can substitute your own data for Col%d.

include win32lib.ew 
constant col={1,15,22,33,44} 
integer i 
for x=1 to 10 do 
    for y=1 to length(col) do 
        position(x,col[y]) 
        printf(1,"Col%d",{y}) 
    end for 
end for 
i=wait_key() 
 

Don Cole

new topic     » goto parent     » topic index » view message » categorize

8. Re: column aligmnent %4d versus %d

DonCole said...

I still think the best way is to use position to force the line to be straight.

I included a small code I whipped up real fast.

You can substitute your own data for Col%d.

Don Cole


Sorry all, I've been away for the last week.
I must be completely missing what you are saying. I am not printing to the console screen. I am printing to a win32lib page which is then sent to the printer. It is the only way I know to print to an modern inkjet printer. If I were printing to a dot matrix, teletype or chain belt printer the standard %d euphoria format routine would probably work OK. Position(x,y) is not a win32lib routine. wPuts() is the equivalent of puts(); but sends the output to the 'pseudo-page'. See code, above, for more insight.
Thanks for your help.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu