Applies To:
  • CitectSCADA 5.xx, 6.xx, 7.00
  • CitectHMI 5.xx, 6.xx, 7.00

Summary:
Is there a way to print documents from CitectSCADA runtime, whilst manually allowing the Operator/User to select the file/document and the printer?
 

Solution:

Yes. Printing can be executed via command line print commands using the Exec( ) cicode function. The following cicode script shows an example of achieving this.

/* 
FILE: CustomPrint.ci
AUTHOR: Navnit K Mudaliar
Date: 10/08/2007

REVISION:
1.0 First revision for release 1.0.

NOTES:
Function: FormPrintFile.
This function allows the user to print a text file to a specified printer, the file does not need to be saved using the WinFile cicode function.
If a printer and file name is not specified, the function will prompt the operator to select a Printer followed by a File using standard Windows Forms. Upon selecting a valid printer and file, the text file is sent to the selected printer.
*/

FUNCTION
FormPrintFile(
STRING sPrinter = "", STRING sFileName = ""
)

    STRING sCommand;

             IF sPrinter = "" THEN
        sPrinter =
FormSelectPrinter();
    END

    IF sFileName = "" THEN
        sFileName =
FormOpenFile("Choose File to Print","*.txt","Text Files (*.txt)|*.txt|All Files (*.*)|*.*|");
    END

       IF (sFilename <> "") THEN
       
IF FileExist(sFileName) THEN
           
IF (sPrinter <> "") THEN
                sCommand =
"Print /d:" + sPrinter + " " + sFileName;
                Exec
(sCommand);
            ELSE
               
Prompt("A Printer has not been Selected");
            END
        ELSE
           
Prompt("File does not Exist");
        END
    ELSE
       
Prompt("No File Selected");
    END
END

 

Keywords:
Print 

Attachments