; BINGO
;
; Program for Proteus
;
; (C) 1998-2004 Simone Zanella Productions
;
; Random drawing to console of numbers from 1 to 90 (no re-insert).
; Demonstrates the usage of queues and arrays;
; default input and output are ignored.
;!proteus -z
FUNCTION Extract(limit, numbers, extlist)
; Draw a random number
rn = INC(RANDOM(limit))
ENQUEUE(extlist, VECGET(numbers, rn))
VECDEL(numbers, rn, 1)
RETURN DEC(limit)
; Build the list of numbers to extract (1-90)
Numbers = VECNEW(90)
ExtList = QUEUENEW()
FOR NumExt = 1 TO 90
VECSET(Numbers, NumExt, NumExt)
NEXT
Limit = 90
; Draw each number
WHILE Limit
Limit = Extract(Limit, Numbers, ExtList)
LOOP
; Print the list of numbers
FOR NumExt = 1 TO 90
CONSOLELN "Number " PFORMAT("2d", NumExt) ": " \
PFORMAT("2d", DEQUEUE(ExtList))
NEXT
ABORT 0