+Philsan Posted December 1, 2018 Share Posted December 1, 2018 In Basic, I would like to PRINT score variable right justified. For example SCORE 100 SCORE 1000 SCORE 10000 instead of SCORE 100 SCORE 1000 SCORE 10000 Which is the best way? Quote Link to comment Share on other sites More sharing options...
+Larry Posted December 1, 2018 Share Posted December 1, 2018 The implied decimal place should line up, so the first way that you show is better. But to provide a little "wiggle room," it might also depend on what else (if anything) would be printed on that same line after the score. Quote Link to comment Share on other sites More sharing options...
vitoco Posted December 1, 2018 Share Posted December 1, 2018 In Atari BASIC, use LEN(STR$(SCORE)) to get the size of the score. So, use something like: POSITION 10-LEN(STR$(SCORE)),0 ? SCORE; But you must be sure that it will always increase, or you'll have to clean that space before updating, or use something like: POSITION 0,0 ? SPACE$(1,10-LEN(STR$(SCORE)));SCORE; where SPACE$ is a string initialized with a given number of spaces, at least 9 in this example. The first method should work in the latest verisions of Fastbasic, but for the second one, the method to get a substring is different from Atari Basic, and the bracket operator should be used: POSITION 0,0 ? SPACE$[LEN(STR$(SCORE))];SCORE; But for scores higher than 9999 you probably need to use a floating point score variable SCORE%, or limit it to 4 variable digits and a fixed multiplier string (adding "0" or "00" at the end of the print). 1 Quote Link to comment Share on other sites More sharing options...
+Philsan Posted December 1, 2018 Author Share Posted December 1, 2018 Thank you very much Victor! The first example works with FastBasic. In my game score always increases and I will add "00" at the end of the print. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.