| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| Hey all. I'm doing an ordering / booking system which is capable of printing invoices. The only thing which really annoys me at the moment is that if I want two variables printed (from printer to paper, not to screen) on the same line, then the length of the first variable affects the layout of the second variable. I'll give an example as I'm not so good at explaining. I want a part of my invoice to look like this when printed on paper: Description: 4" Exhaust Tail Pipe Description: 5" Exhaust Tail Pipe Description: 18" Wheel Trim Description: 20" Wheel Trim It will not look like that, instead it will look like this: Description: 4" Exhaust Tail Pipe Description: 5" Exhaust Tail Pipe Description: 18" Wheel Trim Description: 20" Wheel Trim The length of my 'stock name' variable affects the layout of things horizontal from it when printed. In the above '18" Wheel Trim' is shorter than '4" Exhaust Tail Pipe' and so the text and variable are brought further left automatically. This can start to get messy when lots of items are printed. GotoXY only works for printing variables to screen, and I've tried printing spaces but that would only help for the current stock item, there are loads of stock items so this doesn't work. Any help would be greatly appreciated. Cheers. |
|
#2
| |||
| |||
| <jaf.2k@ntlworld.com> wrote in message news:1144789243.835930.249590@i39g2000cwa.googlegr oups.com... > Hey all. > > I'm doing an ordering / booking system which is capable of printing > invoices. The only thing which really annoys me at the moment is that > if I want two variables printed (from printer to paper, not to screen) > on the same line, then the length of the first variable affects the > layout of the second variable. I'll give an example as I'm not so good > at explaining. > > I want a part of my invoice to look like this when printed on paper: > > Description: 4" Exhaust Tail Pipe Description: 5" Exhaust Tail > Pipe > > Description: 18" Wheel Trim Description: 20" Wheel Trim > > It will not look like that, instead it will look like this: > > Description: 4" Exhaust Tail Pipe Description: 5" Exhaust Tail > Pipe > > Description: 18" Wheel Trim Description: 20" Wheel Trim > > The length of my 'stock name' variable affects the layout of things > horizontal from it when printed. In the above '18" Wheel Trim' is > shorter than '4" Exhaust Tail Pipe' and so the text and variable are > brought further left automatically. This can start to get messy when > lots of items are printed. GotoXY only works for printing variables to > screen, and I've tried printing spaces but that would only help for > the > current stock item, there are loads of stock items so this doesn't > work. Any help would be greatly appreciated. Create a string[n] variabe and assing the concatenation of your 'Description:' + the actual description + a load of spaces to it. Pascal's strictly enforced type-checking will discard the spaces that exceed the declared length of the string. HTH, Robert -- Robert AH Prins prino at prino dot plus dot com |
|
#3
| |||
| |||
| jaf.2k@ntlworld.comsaid > I'm doing an ordering / booking system which is capable of printing > invoices. The only thing which really annoys me at the moment is that > if I want two variables printed (from printer to paper, not to screen) > on the same line, then the length of the first variable affects the > layout of the second variable. I'll give an example as I'm not so good > at explaining. > I want a part of my invoice to look like this when printed on paper: > Description: 4" Exhaust Tail Pipe Description: 5" Exhaust Tail Pipe > Description: 18" Wheel Trim Description: 20" Wheel Trim > It will not look like that, instead it will look like this: > Description: 4" Exhaust Tail Pipe Description: 5" Exhaust Tail Pipe > Description: 18" Wheel Trim Description: 20" Wheel Trim > The length of my 'stock name' variable affects the layout of things > horizontal from it when printed. In the above '18" Wheel Trim' is > shorter than '4" Exhaust Tail Pipe' and so the text and variable are > brought further left automatically. This can start to get messy when > lots of items are printed. GotoXY only works for printing variables to > screen, and I've tried printing spaces but that would only help for the > current stock item, there are loads of stock items so this doesn't > work. Any help would be greatly appreciated. You will need to write a set of routines to control your printer directly. I have done so for Epson's that use ESC P2 codes and there are specific codes to position the print head at what are effectively horizontal and vertical 'TAB' positions. If you would like a .PDF file detailing the Epson codes then I could attach it to an e-mail. JG |
|
#4
| |||
| |||
| jaf.2k@ntlworld.com wrote : > > I'm doing an ordering / booking system which is capable of printing > invoices. The only thing which really annoys me at the moment is that > if I want two variables printed (from printer to paper, not to screen) > on the same line, then the length of the first variable affects the > layout of the second variable. If you want to control your printer without using escape sequences, you could write a function to return a given number of spaces - e.g. space(30). Then write your strings as: writeln('Description: ',var1,^M,space(30),'Description: ',var2); /klaus |
|
#5
| |||
| |||
| On 2006-04-12, Klaus Jorgensen <kj@no.spam> wrote: >> on the same line, then the length of the first variable affects the >> layout of the second variable. > > If you want to control your printer without using escape sequences, you > could write a function to return a given number of spaces - e.g. > space(30). If it is a printer that uses a proportional font that won't work. Escape sequences, and hoping that you have a printer that is still doscompatible. To circumvent these kind of problems myself, I wrote TeX code once, and compiled it to PS or PDF that I then could throw binary to the printer. |
|
#6
| |||
| |||
| JRS: In article <4a2o2eFr6ldeU1@individual.net>, dated Tue, 11 Apr 2006 23:14:45 remote, seen in news:comp.lang.pascal.borland, Robert AH Prins <prino@onetel.com> posted : > >Create a string[n] variabe and assing the concatenation of your >'Description:' + the actual description + a load of spaces to it. >Pascal's strictly enforced type-checking will discard the spaces that >exceed the declared length of the string. I'd prefer to write a function that, given a string, returns that string with trailing spaces added to bring it to stated length; or that writes as if given such a string. const Plenty = ' ' ; function SL(const S : string ; const L : byte) : string ; begin SL := S + copy(Plenty, 1, L-length(S)) end {SL} ; function WS(const S : string ; const L : byte) : string ; begin Write(S, '':L-length(S)) end {WS} ; Untested : but something similar should work. -- © John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. © <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links; <URL:http://www.merlyn.demon.co.uk/clpb-faq.txt> RAH Prins : c.l.p.b mFAQ; <URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ. |
|
#7
| |||
| |||
| with: procedure sl (s : string ; l : integer) ; begin if length (s) < l then fillchar (s [length (s) + 1], l - length (s), ' ') ; s [0] := char (l) ; sl := s ; end ; format output: writeln (invoice, 'Description: ', sl (item_name, 33) ... etc) ; DIK |
|
#8
| |||
| |||
| sorry ... function sl not procedure sl - DIK |
|
#9
| |||
| |||
| "dik" <quagga5@yahoo.com>said > with: > procedure sl (s : string ; l : integer) ; > begin > if length (s) < l then > fillchar (s [length (s) + 1], l - length (s), ' ') ; > s [0] := char (l) ; sl := s ; > end ; > format output: > writeln (invoice, 'Description: ', sl (item_name, 33) ... etc) ; Wont work when proportional spaced font is used (the most common scenario). JG |
|
#10
| |||
| |||
| Marco van de Voort wrote : > On 2006-04-12, Klaus Jorgensen <kj@no.spam> wrote: >>> on the same line, then the length of the first variable affects the >>> layout of the second variable. >> >> If you want to control your printer without using escape sequences, you >> could write a function to return a given number of spaces - e.g. >> space(30). > > If it is a printer that uses a proportional font that won't work. I'm no expert in proportional fonts, but are you telling me that printing a string that is prefixed with a given number of space characters, does not always start at the same position? Will the printer print the xxx's on a different position if printed as follows: writeln(space(30),'xxx iiiiiiii'); writeln(space(30),'xxx mmmmmmmm'); Just curious - IIRC, I used proportional fonts on a laser-printer many years back without any problems. /klaus |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.