Intouch Script Function Sample of FilePrint


FilePrint() is used to tell Wonderware� InTouch™ to print a specific file. See Tech Support Script Function Library to install this function.


FilePrint(Filename, InitState);

Filename A message tag or a quoted string (example: “C:\MYAPP\REPORT.TXT”) which is a fully qualified filename that is to be printed.
InitState A message tag or a quoted string (example: “MAXIMIZED”) which is a valid InitialState value (see below).

Important The InitState parameter is case sensitive.


FilePrint() returns an integer number as described below:

If the integer is greater than 31:

It means FilePrint() was successful. This number is the process Id of the Windows instance of the DOS Box. The process Id does not need to be used elsewhere in the script, thus the value can be ignored.

If an association for the file extension does not exist, and error will occur (error code 31). See the Wonderware Logger (WWLogger) for more information.

If the integer is equal to -1:

It means either the value for Filename or InitState was not specified. Both are required variables.

If the integer is between 0 and 31:

It means an error occurred during the execution of the associated application. See the WWLogger for the specific error message. Usually an error occurred because of a lack of memory. This can be caused by trying to start too many applications at one time. You may want to look at the return value and trigger an alarm or a “disable” link on the button which enables FilePrint. A discrete colorfill based on: “returnvalue < 31” will allow you to change the color or visibility of the button or some text associated with this action on the screen.

Details of FilePrint()

FilePrint() will start the application associated with the file specified under the Filename parameter. The association is stored in the WIN.INI file under your Windows directory. They can be changed or updated easily with the File Manager Associate function.

The application associated with the specified file will start and it will be instructed by InTouch to print the file, then shut down. FilePrint() provides a seamless interface to the printer from inside of your InTouch application without using SendKeys other than DDE.

An InitState value is specified to define the state of the application when it starts.

Here are the valid values for the InitState parameter.

Note InitState is a case sensitive parameter. Use all caps when specifying the InitState value.

“RESTORED” The application will start in its last known non-maximized state. This is the default value for InitState.
“MAXIMIZED” The application window will cover the entire screen
“MINIMIZED” The application will start as an icon.
“INVISIBLE” The application will start but will be hidden and no icon will be visible. Wonderware Technical Support suggests that if this option is used, you should make sure that the application specified in WindowsApplicationName can shut itself down. Otherwise, the application will run continuously.

Example of Using FilePrint()

The following is a script that uses FilePrint():

{ This is an example of using the FilePrint() Script function }
{ Call the function to print the file: C:\MYAPP\REPORT.TXT}
errorcode = FilePrint ( “C:\MYAPP\REPORT.TXT”, “INVISIBLE” );

Executing the script will start Microsoft Notepad, load and print the file C:\MYAPP\REPORT.TXT and exit. This will be done in the background which is invisible to the user.

Leave a Reply

Your email address will not be published. Required fields are marked *

2 × = 6