Objectmix
Tags Register Mark Forums Read

printing variable problems : Pascal

This is a discussion on printing variable problems within the Pascal forums in Programming Languages category; 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" ...


Object Mix > Programming Languages > Pascal > printing variable problems

Reply

 

LinkBack Thread Tools
  #1  
Old 04-11-2006, 04:01 PM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default printing variable problems

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  
Old 04-11-2006, 06:15 PM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: printing variable problems

<jaf.2k@ntlworld.com> wrote in message
news:1144789243.835930.249590@i39g2000cwa.googlegroups.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  
Old 04-11-2006, 07:58 PM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: printing variable problems


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  
Old 04-12-2006, 02:40 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: printing variable problems

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  
Old 04-12-2006, 02:54 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: printing variable problems

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  
Old 04-12-2006, 08:11 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: printing variable problems

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  
Old 04-12-2006, 09:11 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: printing variable problems


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  
Old 04-12-2006, 09:31 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: printing variable problems

sorry ... function sl not procedure sl - DIK

  #9  
Old 04-12-2006, 11:46 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: printing variable problems


"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  
Old 04-12-2006, 01:15 PM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: printing variable problems

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


Reply

Thread Tools


Similar Threads

Thread Thread Starter Forum Replies Last Post
Printing variable name and value usenet RUBY 1 11-25-2007 11:40 PM
Problem printing variable with $stdout.print usenet RUBY 5 11-22-2007 10:01 AM
Variable Printing usenet Adobe Indesign 0 11-06-2007 02:33 PM
Printing variable names usenet RUBY 3 08-18-2007 06:36 PM
Printing variable length pages usenet basic.visual 5 02-17-2006 02:12 PM


All times are GMT -5. The time now is 12:39 PM.

Managed by Infnx Pvt Ltd.