I'm sure there was a line routine on the code archives that clips to the screen boundary, by Skidracer I think, which may be helpful. From memory though it may be embedded in another bit of code by Blitz Support.
Here... http://www.blitzbasic.co.nz/codearcs/codearcs.php?code=380
Edit. You could of course just use a viewport but if you need the new endpoints then an adaptation of this should be able to provide them.
Here... http://www.blitzbasic.co.nz/codearcs/codearcs.php?code=380
Edit. You could of course just use a viewport but if you need the new endpoints then an adaptation of this should be able to provide them.