I have created a very simple udf to read an ini file and install the printers listed in that ini file. However, for some reason, the code is returning an extra return or item in the array. I have had to exclude empty lines to get rid of that extra result.

Here is the udf

 Code:
Function PrintInstall($Section)

	$Handle = Freefilehandle ()
	
	If $handle > 0
		If Open ($handle, $iniFile) = 0
			$PrintServer = ReadProfileString($iniFile, "PrintServer", "Printer")
			$printerKeys = split(ReadProfileString($iniFile, $Section, ""),chr(10))
			FOR each $printerKey in $printerKeys
				IF $printerKey <> ""
					$printer = ReadProfileString($iniFile, $Section, $printerKey)
			? "Install the $Printer"
				ENDIF
			NEXT
			
			IF Close($handle)
				Beep
				? "Error closing file!"
			ENDIF
		ELSE
			? "Unable to open" + $iniFile
		ENDIF
	ELSE
		? "Unable to obtain a free system handle."
	ENDIF
	
EndFunction


I have to put this line in - IF $printerKey <> "" - otherwise the code returns an extra entry. I think it is something to do with empty lines in the ini file.

This is the ini file sections that this coding is reading

 Quote:

[PrintServer]

Printer = ServerName

[Accounting Printers]

printer1 = Ricoh
printer2 = Sharp
printer3 = Brother
printer4 = Xerox