Ok, to test my insight I'll note what I think the script does, please correct me:

$sPrinter=GetDefaultPrinter() => declares $sPrinter as the value of GetDefaultPrinter
If $sPrinter
"Default printer for this user is "+$sPrinter+@CRLF => If there is a value for this variable it prints the message
Else
"No default printer found for this user."+@CRLF
EndIf => If there's no value for the variable it prints an error

; GetDefaultPrinter() - Returns the default printer.
; Sets @ERROR=0 when a printer is found, 2 if no printer is found.

Function GetDefaultPrinter() => declares function and between () the result is stated
Dim $iIndex,$sGroup => locally declares the variables $iIndex and $sGroup (is this the same as:
Dim $iIndex
Dim $sGroup
?)


$sGroup=EnumGroup($iIndex) => $sGroup is the return value of EnumGroup with value $iIndex
While @ERROR=0 AND $sGroup => as long as there is an value for $sGroup and no error continue
If InStr($sGroup,"\") $sGroup=SubStr($sGroup,InStr($sGroup,"\")+1) EndIf => If there is a \ in $sGroup $sGroup=value from \
If InStr($sGroup,"P-")=1 => if there is a P- in $sGroup
$GetDefaultPrinter=SubStr($sGroup,3) => $GetDefaultPrinter= value of $sGroup (does the 3 mean that it only shows the last 3 characters of the value?)
Exit 0 => exit on error 0
EndIf
$iIndex=$iIndex+1 => add 1 to $iIndex so the EnumGroup checks the next group during the loop
$sGroup=EnumGroup($iIndex) => $sGroup = the value of the number of the loop it is working
Loop
Exit 2 => exit on error 2
EndFunction


After reading the manual more carefully I noticed I misunderstood the EnumGroup function. A big case of RTFM .

Why there is a While...Loop construct
So every Group is stated

Why your use of @USERID was inappropriate
because an integer value is required for this function

What the $iIndex variable is being used for
so that all groups are returned

Why the line with the "\" substring is there
I'm not really sure, but I think to make sure it gets the group and not the domain

What the $GetDefaultPrinter variable is, and why it is set as it is.
declares function and between () the result is stated

What the "Exit" statements are being used for, and why they have numeric values
So that the loop quits when it has found it's value, when there is an error or if it has had all value's


What the line "While @ERROR=0 AND $sGroup" is doing.
As long as there is an value for $sGroup and no error continue

regards,

jeroen

ps.. hope this takes me of of the candidate list for the kixtart paralympics