Are you trying to get the width of the screen you are using?
If so it is _Width in text screens maybe even console, _Width/8 for graphics screens.
(Assuming default font when get _Width and _Height)
Likewise _Height gives you rows in text screens not console! and _Height/16 for graphics screens.
So:
DistanceToEdgeInChars = _Width/8 - ColumnYouAreAt ' for graphics screens
or
DistanceToEdgeInPixels = _Width - Xpixel ' for graphics
If so it is _Width in text screens maybe even console, _Width/8 for graphics screens.
(Assuming default font when get _Width and _Height)
Likewise _Height gives you rows in text screens not console! and _Height/16 for graphics screens.
So:
DistanceToEdgeInChars = _Width/8 - ColumnYouAreAt ' for graphics screens
or
DistanceToEdgeInPixels = _Width - Xpixel ' for graphics
b = b + ...