_PDQ: LESS BAGGAGE, FASTER CODE_
by Bruce W. Tonkin

[EXAMPLE 1]

DEFINT A-Z
DIM flags(8190)
CLS
PRINT "25 iterations"
x# = TIMER
FOR j = 1 TO 25
count = 0
FOR i = 0 TO 8190
flags(i) = 1
NEXT i
FOR i = 0 TO 8190
IF flags(i) THEN
prime = i + i + 3
k = i + prime
WHILE k <= 8190
flags(k) = 0
k = k + prime
WEND
count = count + 1
END IF
NEXT i
NEXT j
xx# = TIMER
PRINT USING "#### primes in ##.### seconds";count;xx#-x#
END

[EXAMPLE 2]

rem \$include: 'pdqdecl.bas'
DIM flags(8190)
CLS
PRINT "25 iterations"
start&=pdqtimer&
FOR j = 1 TO 25
count = 0
FOR i = 0 TO 8190
flags(i) = 1
NEXT i
FOR i = 0 TO 8190
IF flags(i) THEN
prime = i + i + 3
k = i + prime
WHILE k <= 8190
flags(k) = 0
k = k + prime
WEND
count = count + 1
END IF
NEXT i
NEXT j
done&=pdqtimer&
tot&=(10*(done&-start&))\182 'convert timer ticks to seconds.
frac&=(10000&*(10*(done&-start&) mod 182))\182 'and decimal.
PRINT count;"primes in ";rtrim\$(str\$(tot&));".";frac&;"seconds."
END

[EXAMPLE 3]

defint a-z 'by default, all variables are integers
call initstr(a\$,128) 'initialize a\$ to 128 characters
call initstr(b\$,8192) 'buffer for file is 8K bytes
a\$=command\$ 'look at the command line
if rtrim\$(a\$)="" then 'no file named; give help.
print"Syntax:"
print"UCASE filename"
print"The named file will be converted in place to upper-case."
end
end if
open rtrim\$(a\$) for binary as #1 'no random files in PDQ
size&=lof(1) 'file size
if size&=0 then close 1:kill rtrim\$(a\$):end 'no such file