From 11:00 PM CST Friday, Feb 14th - 6:30 PM CST Saturday, Feb 15th, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Printing Text from a (logfile)

Hallo everyone!
 
Can anyone help me with my programm? I need do print text from a logfile. Printing text is not difficult but i get trobles with the linefeed!
I get text every view minutes and want to print it "realtime". It would not help me to print a hole page, i only need one line and it should not be more than one line.
 
I have allready tried to use the
 
SetPrintAttribute (ATTR_PRINT_AREA_HEIGHT, 300);
SetPrintAttribute (ATTR_PAPER_HEIGHT, 300);
...
but it does not work- it always gives out the hole page with one line of text.
 
i tried to use the
SetPrintAttribute (ATTR_EJECT_AFTER, 0);
 
but this would effect, that it is not "realtime" anymore
 
if enyone can help me please send me the answere to my e-mail occount : pletzer6x@gmx.at
 
And sorry for ma bad english!
 
Chris
0 Kudos
Message 1 of 6
(3,655 Views)
Hi!

   Which function do you actually use for prinbting? I mean, PrintTextFile, PrintTextBuffer.....

   Moreover, how is your log file formatted like? Is it a Linux like text file (without '\n' character)?

If you want let me know...

graziano
0 Kudos
Message 2 of 6
(3,635 Views)

Hallo,

I get the data from a .dat file and read it into a char string, because i do not want all data from the log file to print. otherwise i would use the fileprint methode.

So i use

PrintTextBuffer (Text, ""); to print the texts

the printer does very well- but always when there is something to print it prints the text on the top and gives out the hole sheet.

i can not disable the EJECT_AFTER and wait for a full page, because i need it on time and a secound change in the logfile could occour in an hour od a week.

I think i have to set the printer setups that it does not use A4, but how to do this?? As i told you i tried the ATTR_PRINT_AREA_HEIGHT... but they did not work.

Is there a way for linefeed or formfeed??

A short Information i use a needle printer with endlessly paper.

Thanks for Help Chris

0 Kudos
Message 3 of 6
(3,625 Views)

can i use something like

0X0D and 0X0A    for formfeed and linefeed in the text??

 

0 Kudos
Message 4 of 6
(3,627 Views)
PrintTextBuffer() prints an entire page at one time.  What you can do is store a page of data and then print it using PrintTextBuffer()
 
As you read in the log file, place the text you want to print into another string buffer.  Look at strcat() or any of the other functions that allow you to append data onto an existing string.  You can format lines with the \r and \n characters. 
When you want to print the page, call PrintTextBuffer() passing it the buffer you just made containing the formated data for the page you want to print.
 
 
0 Kudos
Message 5 of 6
(3,618 Views)

Thanks

I already have my strings manipulated but not with strcopy, strncopy or strcat... because this will affect that an ascii 0 will stop the copy or cat!!!!!

I found now a way for my print job!

printer = OpenFile ("LPT1", VAL_WRITE_ONLY, VAL_OPEN_AS_IS, VAL_ASCII);
WriteFile (printer, Text, 20); 

good old c

and the linefeed

WriteFile (printer, Linefeed, 2);//0x0d0a

CloseFile (printer); // important- otherwise it will not print!

so it prints as soon as there is a new string

 

but thank you for your tips! Chris 

0 Kudos
Message 6 of 6
(3,616 Views)