3. Filling up strings ~~~~~~~~~~~~~~~~~~ It is sometimes necessary to fill-up or 'pad' out strings to a fixed length. For example, you may want numbers to print out as 0045, 0001 etc., or you may want to add leading or trailing spaces onto character strings. The first example gives the obvious method, whereas the second shows a more elegant method which avoids the use of an IF statement. The third example shows a similar method in the form of a Function, with the addition that you can specify the amount of padding and the padding character to be used - it doesn't have to be a number. 30 IF LEN(X$)<4 THEN X$="0"+X$:GOTO 30 30 X$=STRING$(4-LEN(X$),"0")+X$ 10 INPUT"Enter up to 5 digits "A$ 20 A$=FNpad(A$,5,"0"):PRINT A$:END 30 : 100 DEFFNpad(st$,len%,char$):=STRING$(len%-LEN(st$),char$)+st$