How Do I Print a Report from Several Programs to the Same I/O Device? (Magic xpa 2.x)
The scope of an I/O device is much the same as the scope of variables or forms. That is, each task can see and use the I/O devices of its ancestors.
However, it is often useful to call a totally unrelated program to do some printing. For instance, you might want to have a generic program to print some summary information or format some text. You can do this in Magic xpa by using a facility called I/O Name to Use.
In this example, we want to create a “Studio Cross-Reference” that will print at the end of several reports, so new users can figure out the studio codes. We have a program that prints out the codes, but how do we attach it to several different reports? Below we will show you how.
First, you need to set up the program that opens the I/O device. There isn’t very much to set up here, just two things:
-
Set the I/O device name. It’s good to make it something simple, with no spaces.
-
Pass the I/O device name to the called program. You don’t have to do this, but if you hard-code the name it wouldn’t make the called program very generic.
In our example, we typed ‘DVDS’ for I/O device name. Then we created an expression with the string ‘DVDS’ and passed that to the called program.
Now, in our called program, we just have to set up the I/O device. In the I/O Properties, set the I/O name to use to the passed parameter, which in this case will evaluate to ‘DVDS’.
That’s all there is to it. Now the output of the called program will be routed to the I/O device opened in the first program.
Hint: In some cases, you might want to have a “controlling task” which calls two or more separate programs for output. In this case, open the I/O device in the controlling task. If that task is the online task, or if there might not be any output, set Settings->Environment->Preferences->IO device Open timing to On Demand to prevent blank pages from being printed.
The Online and Rich Client Samples projects (program RP06 and RRP06