This is a nice little function to use if you wish to print scores, timers, highscores etc. but require to use a fixed number of characters so the numbers don't jump about as they increase and decrease in value.
Function
// .------------------------------------.
// | Pad INTEGER with leading zeros |
// `------------------------------------'
FUNCTION PrintPaddedNumber: num, zeros, numx, numy
text$ = FORMAT$(zeros, 0, num)
text$ = REPLACE$(text$," ","0")
PRINT text$, numx, numy
ENDFUNCTION
Usage
PrintPaddedNumber(20000, 6, 5, 5)
This will print the number 020000 in the top left of the screen at co-ordinates 5,5. Obviously using 6 for the zeros parameter only gives a range of 000000...999999, alternatively if the zeros parameter was 3 we have a range of 000...999 handy for a timer :)
Again I hope you guys find it useful =)
It is easier something like
PRINT right$("0000000000"+score,lenght),x,y
(this code can be used as GLBasic do not add a space (" ") before the number when converting it to a string, as most languages do)
Useful ;)
Definitely useful :good:
Just make sure you LOCAL text$ explicitly - anything not localled is implicitly made GLOBAL in GLB.