

$include "windowssdk.inc"

 
DEF w1 as WINDOW
uint dwStyle = WS_VISIBLE | WS_CHILD | SS_CENTER

int w = 0
int x = 0
int y = 0
int z = 0

'Some numbers to right justify...
w = 8910
x = 12
y = 1000
z = 12567


int a = 0
int c = 0
int across,down,numbers = 0
int BoxNo = 0
string No[10]
string b[10,10]
int Longest = 0
int MaxLength = 0
int StartAcross = 0
int Gap = 0


OPENWINDOW w1,0,0,500,500,@MINBOX|@MAXBOX|@SIZE,0,"Right justify numbers.",&main


MaxLength = 6 'Maximum length of the numbers you want.

BoxNo = 1000 'Display static controls begin at this number (any you want). 

StartAcross = 200 'Starting across position on screen.
across = StartAcross
down = 200 'Starting down position on screen.
Gap = 8 'Spacing between numbers on each line.

'Read your numbers in...
ReadNumber(w)
ReadNumber(x)
ReadNumber(y)
ReadNumber(z)

'Center & print them...
CenterRight()
PrintNumbers()


WAITUNTIL w1 = 0

END


SUB main( ),INT

SELECT @MESSAGE

    CASE @IDCONTROL

        SELECT @CONTROLID


        endselect

	 CASE @IDCREATE
		   centerwindow w1

    case @IDCLOSEWINDOW
         closewindow w1
         end 

endselect

RETURN 0

ENDSUB


'Find the length of the longest number & specify the 'USING' format you require...
sub ReadNumber(int NumberIn),int 

    Numbers += 1
	 No[Numbers] = ltrim$ using("###,###",NumberIn)

    if len(No[Numbers]) > Longest
       Longest = len(No[Numbers])
    endif

return 0
endsub


'Offset the numbers to the right...
sub CenterRight(),int

for c = 1 to Numbers

    int Offset = 0
    Offset = Longest - len(No[c])

    int ab = 0

	  for a = Offset+1 to MaxLength
         ab = ab + 1
         b[c,a] = mid$(No[c],ab,1)
	  next a

next c

return 0
endsub

'Create stativs & print the numbers...
sub PrintNumbers(),int 
	 for c = 1 to numbers
		  for a = 1 to MaxLength
			   BoxNo += 1
			   CreateWindowEx(0, "STATIC",b[c,a],dwStyle,across,down,10,20, w1.hwnd, BoxNo, GetModuleHandle(0), 0)
			   across += Gap
		  next a
		  across = StartAcross
		  down += 25
	next c
return 0
endsub



