Long Shot

Crittar

Member
I hope someone out there has come across what I'm looking for :)

We have various terminals around which have "slave printers" attached (i.e. a parallel printer hanging on the back).

We have a package which throws reports to these printers.

I believe this is done by outputting to the terminal but sending various control codes which indicate that output should really be to the slave printer.

I want to duplicate this effect in various programs but do not know what the control codes are - does anyone out there know please?
 
Terminals! Do people still use them? :D

If they're all emulating say, VT100's then that should make it easy. Here's a couple of examples that can be found on the web (Just search for "VT100 pass-through printing" and you'll get loads of info):

PTP=Pass-through printing
\E = Escape char (27)
^ = Control

For VT100, VT220, (SCO)ANSI, or AT386:
PTP off = \E[4i
PTP on = \E[5i

For Wyse 50, 60:

PTP off = ^T
PTP on = ^R
 

Crittar

Member
Mike,

Thank you for that, it starts me in the right direction but I am still having problems. I have posted the code I used for my test below:

Code:
DEFINE VARIABLE pt-on  AS CHARACTER NO-UNDO.
DEFINE VARIABLE pt-off  AS CHARACTER NO-UNDO.
 
DEFINE STREAM pstream.
 
OUTPUT STREAM pstream TO TERMINAL.
 
ASSIGN
  pt-on
  'This is a test string'
  pt-off
  WITH NO-LABELS
	NO-BOX.
 
OUTPUT STREAM pstream CLOSE.

When I run the above I have to run it three times before I see any output on the printer. I then get the string two and a bit times (finishes at 'str' on third occurrence).

If I put a skip in after the string I then get the characters 2;1H after 'This is my test string' but no skip.

Would you have any further pointers please?
 
It could be that the escape sequences are incorrect for the type of terminal. When you get pieces of standard text missing, this usually means that the characters interpreter in the terminal has eaten them. e.g. it was expecting some further command characters.

From your code example, I presume that:

1. You have initialized the two variables
2. The ASSIGN is actually a DISPLAY statement

I wouldn't try to mix FRAME's and escape sequences at this point. Try to keep them separate. The output of a DISPLAY statement always includes a zillion escape sequences of its own.

Instead, use PUT SCREEN to output the sequences and then see what you get. If there are characters missing from the text that you expect to see, then it's likely that the sequence is incorrect or incomplete.

Have a look at switching on the echo mode of the terminal. Usually, the escape sequences are not printed to the screen (that would be daft) but you can switch echo on and it will display any sequences as well as normal text. It makes a mess of the screen, but it will show you what has actually been received by the terminal.

I'm feeling very nostalgic. :)
 
I forgot to mention, you don't need to open a stream to the terminal. In a character environment, the default stream is automatically to the terminal.

So you should be able to just use PUT SCREEN from any point in your program.

But if you do need to use a stream, you might need to consider these options when opening it:

BINARY (possibly)
NO-MAP
NO-CONVERT

Have a look at the help for OUTPUT TO.

Another alternative is to use the device name for the terminal itself in the OUTPUT statement, and send your character stream directly to it. e.g.

OUTPUT TO /dev/term1 NO-ECHO NO-MAP NO-CONVERT.
 

Crittar

Member
Mike,

Your assumptions were correct - I got interrupted by the phone whilst typing the example in. It should have read:
Code:
DEFINE VARIABLE pt-on  AS CHARACTER NO-UNDO.
DEFINE VARIABLE pt-off  AS CHARACTER NO-UNDO.
 
DEFINE STREAM pstream.
 
OUTPUT STREAM pstream TO TERMINAL.
 
ASSIGN
  pt-on = CHR(27) + '[5i'
  pt-off = CHR(27) + '[4i'.
 
OUTPUT STREAM pstream TO TERMINAL.
 
DISPLAY
  pt-on
  'This is a test string'
  pt-off
  WITH NO-LABELS
	NO-BOX.
 
OUTPUT STREAM pstream CLOSE.

I know that the terminal is the default ouptut device, I put the stream in because the output seemed to be "buffering" somewhere and I thought that might force the printing to occur.

I think that the reason for the partial string is that the printer had reached end of line.

I changed the above code to use PUT SCREEN and the results were worse:

I still had the "buffering" effect but getting characters like 1;H6 between words in 'This is my test string".

I'm just about to try your final suggestion, I'll keep you posted.
 

MHotovec

Member
We use

def stream s-out.
output stream s-out through svt.
disp stream s-out ....

Will that work in your environment?

Mark

Crittar said:
I hope someone out there has come across what I'm looking for :)

We have various terminals around which have "slave printers" attached (i.e. a parallel printer hanging on the back).

We have a package which throws reports to these printers.

I believe this is done by outputting to the terminal but sending various control codes which indicate that output should really be to the slave printer.

I want to duplicate this effect in various programs but do not know what the control codes are - does anyone out there know please?
 

Crittar

Member
Mark,

Not sure what your environment is - we are running under unix. Your suggestion simply causes the error message:

/bin/sh: svt: not found


Mike,

Your last suggestion of:

OUTPUT TO /dev/term1 NO-ECHO NO-MAP NO-CONVERT.

results in:

** Unable to open file: /dev/term1. Errno=2. (98)
 
/dev/term1 was an example. You have to go and see what the device name is on your system and substitute that name. Each terminal will have a different device name.

1;H6 looks like part of a cursor positioning sequence that is output by Progress. I think that you are doing everything right, but your escape sequences must be incorrect. Do you happen to know what type of terminal or what they are emulating?

If Progress can control the terminal via the protermcap file, then you must be able to via the 4GL. Rather than go for pass-through printing, have you tried something simpler like switching on the blink/bold highlighting for a word? I can't remember the sequences but these you will definitately find in the protermcap file, under the entry indicated by your TERM environment variable. I would try those first. If you can get that working, switching on pass-through should be a doddle.
 

Crittar

Member
Mike,

We are emulating VT220.

I know that passthru printing will work - the package we run does it, all I have to do is find the trick I am missing.

I think I've managed to get hold of a copy of an old vt100 manual, I'm hoping to find some useful info in there.

I'll let you know what I find out but if you have any more thoughts in the meantime I would be grateful to hear them.
 

Crittar

Member
I've now managed to obtain a copy of the vt220 manual which I am perusing. I have also found a little more information by digging through the package.

There is a table containing printer details which has within it the codes for turning slave printing on and off.

It also has (prior to the esc [ 5 i) the code:

Esc [ 1 8 * u

I haven't been able to make sense of this via the vt220 manual yet - does it ring any bells with you?
 

Crittar

Member
OK:

I've tried all kinds of variations on 'output to'.
I've even been through protermcap and tried mapping to every device under the sun in case that's how the package handled it.

I do get output to the printer. I don't get line-feeds (I get what appear to be the screen mapping characters).

Please, please, please - if anyone out there has managed to get pass-thru printing working, give me a clue.
 

cecsno

Member
Try this, create a UNIX file called start-slave (or whatever) with the following
^[[5i
Create a file end-slave
^[[4i
Have your procedure output to a file then execute the following after closing the file.

unix silent cat start-slave.
unix silent cat file-name.
unix silent cat end-slave

Crittar said:
OK:

I've tried all kinds of variations on 'output to'.
I've even been through protermcap and tried mapping to every device under the sun in case that's how the package handled it.

I do get output to the printer. I don't get line-feeds (I get what appear to be the screen mapping characters).

Please, please, please - if anyone out there has managed to get pass-thru printing working, give me a clue.
 

Crittar

Member
Cecsno,

That sounds like an excellent workround, I will give that a try as soon as I can and let you know the outcome.
 

Crittar

Member
Many apologies to all for my delay in replying to this, I was side-tracked on to another job and have only just managed to get back to this one.

Cecsno, I used a variation of your suggestion: I wrote the control characters and the appropriate data to a file and used os-command silent cat myfilename.

Wondrous - the report appears on the slave printer exactly as I want!!

BUT

When control is returned to the calling program the only menu item visible is "reports" (the printing program having been called from a sub-menu on this menu-item). Moving the cursor left or right with the cursor keys causes the other menu items to become visible but the initial display on return form the reporting program is not acceptable.

Having read the manual it advises that the "silent" option on "os-command" should only be used when you are certain that there will be no output to the screen.

In this case it is debatable whether there is output to the screen as the data actually passes through the screen to the printer.

However it is definitely the os-command silent cat... which causes the error because if I comment this line out the menus are redisplayed perfectly on return to the calling program.

Sorry about the long winded explanation but now for the question: does anyone have any idea how to ensure that the menus are displayed correctly on return?
 
Are you putting a form-feed (CTRL-L) character at the end of your test output?

You may need CR and LF characters at the end of lines try using the following:

Code:
DEFINE VARIABLE pt-on  AS CHARACTER NO-UNDO.
DEFINE VARIABLE pt-off  AS CHARACTER NO-UNDO.
DEFINE VARIABLE pt-cr  AS CHARACTER NO-UNDO.
DEFINE VARIABLE pt-ff  AS CHARACTER NO-UNDO.
 
DEFINE STREAM pstream.
 
ASSIGN
  pt-cr = CHR(13) + CHR(10)
  pt-ff = CHR(12)
  pt-on = CHR(27) + '[5i'
  pt-off = CHR(27) + '[4i'.
 
OUTPUT STREAM pstream TO TERMINAL BINARY.
 
PUT STREAM pstream UNFORMATTED
  pt-on 'This is a test string' pt-cr pt-ff
  pt-off.
 
OUTPUT STREAM pstream CLOSE.
 

Crittar

Member
Simon,

No matter what I do, if I try to send the stream direct to the terminal I get the terminal mapping characters displayed.

Putting it to a file on disk and then using os-command cat filename works perfectly as far as printing is concerned - just gives me the problem detailed above.
 

Dirky

New Member
If you don't want to use a UNIX file to redirect the output, perhaps the 'put' statement in combination with the 'control' keyword can help you out... it helped me out once when I needed to write some null string characters to a file..
 

cecsno

Member
Did you do the end-slave to reset the terminal after cat of the file.

Also if your print procedure is a subroutine do a return after the end-slave so other printer controls are not set.

How about an example of you code.

Crittar said:
Many apologies to all for my delay in replying to this, I was side-tracked on to another job and have only just managed to get back to this one.

Cecsno, I used a variation of your suggestion: I wrote the control characters and the appropriate data to a file and used os-command silent cat myfilename.

Wondrous - the report appears on the slave printer exactly as I want!!

BUT

When control is returned to the calling program the only menu item visible is "reports" (the printing program having been called from a sub-menu on this menu-item). Moving the cursor left or right with the cursor keys causes the other menu items to become visible but the initial display on return form the reporting program is not acceptable.

Having read the manual it advises that the "silent" option on "os-command" should only be used when you are certain that there will be no output to the screen.

In this case it is debatable whether there is output to the screen as the data actually passes through the screen to the printer.

However it is definitely the os-command silent cat... which causes the error because if I comment this line out the menus are redisplayed perfectly on return to the calling program.

Sorry about the long winded explanation but now for the question: does anyone have any idea how to ensure that the menus are displayed correctly on return?
 
Top