Compile function Get_Printer_Port(Report)

************************************************************************************************
*
* This program is proprietary and is not to be used by or disclosed to others, nor is it to be
* copied without written permission from SRP Computer Solutions unless used exclusively within
* the context of the licensed user's proprietary application or within a deployed runtime
* generated by the licensed user
*
* Name       :  Get_Printer_Port
*
* Description:  Scans the OINSIGHT.INI file for a custom section that tracks which printer and
*				port a specific form/report is assigned to. Used in environments where different
*				workstations may have different print drivers or captured ports than others.
*
* Notes:		
*
* Parameters:
*   Report		[in] -- The name of the report that we need to retrieve the printer and port for.
*
* History (Date, Initials, Notes)
*   10/05/98  dmb   Original programmer
*   10/07/98  dmb   Removed the WIN.INI scan because the driver and port is also being stored
*					with the printer name in the OINSIGHT.INI file
*	10/21/98  dmb	Made sure that Ans is set to null if only @FM is assigned to variable to
*					avoid problems with the OIPI
*	11/12/98  dmb	Return the entire printer definition rather than Printer and Port to
*					accomodate the Set_Default_Printer subroutine
*	05/02/02  dmb	Return Windows default printer and port if there is no assignment listed
*
************************************************************************************************

$insert LOGICAL

Declare function GetPrivateProfileString, WritePrivateProfileString, GetPrivateProfileSection

/* Get printer name assigned to form/report */
lpszSection = "Printers":\00\
lpszEntry = Report:\00\
lpszDefault = "":\00\
lpszPrinter = Str(\00\, 1024)
cbPrinter = Len(lpszPrinter)
lpszFileName = "OINSIGHT.INI":\00\
Value = GetPrivateProfileString(lpszSection, lpszEntry, lpszDefault, lpszPrinter, cbPrinter, lpszFileName)
Convert \0020\ to \2000\ in lpszPrinter
lpszPrinter = TrimB(lpszPrinter)

If lpszPrinter EQ "" then
	/*	Printer assignment does not exist. Return default printer instead  */
	lpszSection = "windows":\00\
	lpszEntry = "device":\00\
	lpszDefault = "":\00\
	lpszPrinter = Str(\00\, 1024)
	cbPrinter = Len(lpszPrinter)
	lpszFileName = "win.ini":\00\
	Value = GetPrivateProfileString(lpszSection, lpszEntry, lpszDefault, lpszPrinter, cbPrinter, lpszFileName)
end

Convert \002C\ to \20FE\ in lpszPrinter

Return lpszPrinter
