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

Summary:
We use Webclient on site, and it is not viable to set a default printer for all users (i.e a constant [PRINTER]Port parameter on the servers INI file which will propagate to all users), nor can we have a separate INI file for each client.

If the [PRINTER]Port parameter is left empty, then it will attempt to print to LPT1. This is not relevent to all our users, and setting up a mapped LPT1 port on every computer that 'may' use WebClient is not a viable solution.

What is the best way of letting the user choose their own printer, either everytime, or just the first time on that local PC?
 

Solution:
This functionality can be achieved through the Cicode function shown below. This can be used for normal clients, as well as display clients.

Copy the function below into a new Cicode file within your project, rename the function as desired, and link all your old print buttons to this new function.

What does this function do?:

* Firstly it will check for the INI parameter [PRINTER]Port to see if an existing printer has been defined
- If you want users to select their own printers, ensure that this parameter is blank on the machine that prepared the Web deployment.
- To confirm, after loading webclient on a machine, Check the INI file located at:
C:\Documents & Settings\<username>\Local Settings\Temp\Citect\<DeploymentName>Citect.ini

* Secondly, if the INI parameter is blank, instead of printing to LPT1, it will prompt the user to select a printer:



* Thirdly, if a valid selection is made, it will check the [PRINTER]NoPrompt INI parameter, to determine whether to ask the user to save the selection as a default.
* Fourthly, if the user elects to save the printer as default, then the parameter [PRINTER]Port=<PrinterName> is saved to the INI file.

- WEBCLIENT NOTE: Due to the nature of the operation of Citect WebClient, the Default Printer will probably only remain
valid for the current session of WebClient, because, when restarted, the deployments INI with a blank [PRINTER] section will overwrite the clients INI.
- It is possible to mark the clients Citect.ini as 'Read Only' to prevent this overwrite, but this has to be done manually, and has to be manually un-done if any deployment changes are made, to ensure the latest copy is used.

* Lastly, the user is then prompted as to whether they wish to print using the selected printer, and displays the printer that they are going to print to.

FUNCTION
MyPrintFunction
()

STRING sPrinter;
INT iPromptDefault;

    //Checks [PRINTER]Port INI parameter for an existing printer
    sPrinter = ParameterGet("Printer", "Port", "");

    //If there is no printer defined in INI, then prompt user to choose
    
IF sPrinter = "" THEN 
        sPrinter =
FormSelectPrinter()
        
//Has a selection been made?
        
IF sPrinter <> "" THEN
            //Save as Default Printer?
            //IF INI param [PRINTER]NoPrompt=1 THEN it won't prompt & wont save 
            
iPromptDefault = ParameterGet("Printer", "NoPrompt", "");
            
IF iPromptDefault <> 1 THEN 
                IF Message("PRINT","Save this printer as your default?",1+32) <> 299 THEN 
                    ParameterPut("Printer", "Port", sPrinter);
                END 
            END 
        END
    END

    IF sPrinter <> "" THEN 
        IF Message( "Print?", "Print Current Page to^n" + sPrinter + "?",1+32) = 0 THEN 
            WinPrint(sPrinter)
        END 
    END
END


Keywords:
webclient web client printer print select slection selecting default 
 

Attachments