The following line will take the first 8 chars from the left end of the @UserID macro and assign it to the $username variable.

Code:
$username = Left(@UserID,8)