My first suggestion would be to get rid of all those GoTo's and GoSub's. They make the code messy and difficult to follow. This can easily be done with some Select-Case-Endselect or If-Else-Endif statements. See below for an example. The example below requires the PriMapState UDF from the UDF section of this board.

On this line $ipbyte3 = Val (LTrim (SubStr( @IPADDRESS0 , 9 ,3))) you are filling a variable based on the value of a left trim of a substring taken from @IPADDRESS0 \:o . You start reading at the 9th character and read 3 characters. This is not the third octet of the IP address but it results in something like “11.” or “ 1.” . The third octet starts at the 8th character and stops at the 10th. It looks like there is a lot of extra unneeded code in your script like the GoTo, GoSub, Val(Ltrim(…., etc…

If you can specify a bit what you need then we might be able to come up with a cleaner solution.
 Code:
;Set printer name.
$printer = "\\server\PrinterA"
;Check group membership.
If InGroup("GroupA")
	;Check if the printer is already installed.
	If Not PriMapState($printer)
		;Printer is not installed. Add printer.		
		$rc = AddPrinterConnection($printer)
	EndIf
EndIf

;Set printer name.
$printer = "\\server\PrinterB"
;Check group membership.
If InGroup("GroupB")
	;Check if the printer is already installed.
	If Not PriMapState($printer)
		;Printer is not installed. Add printer.		
		$rc = AddPrinterConnection($printer)
	EndIf
EndIf

;Check group membership.
If SubStr(@IPADDRESS0, 8, 3) = "111"
	$printer = "\\Server\PrinterA"
	If PriMapState($printer) <> "2"
		;Set default printer.
		$rc = SetDefaultPrinter($printer)
	EndIf
EndIf

;Check group membership.
If SubStr(@IPADDRESS0, 8, 3) = "222"
	$printer = "\\Server\PrinterB"
	If PriMapState($printer) <> "2"
		;Set default printer.
		$rc = SetDefaultPrinter($printer)
	EndIf
EndIf
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.