Hello,

even though this is the DBC board, the methods should be the same.

The string functions are a bit slow, but the speed you describe seems like somethings wrong. Maybe there's a problem with how you built your string parser?

Anyway, here's an example of a method that accompllishes what you seem to describe. This runs from the command line 5 seconds on my old single core 1.5ghz machine (using DBC) - when testing for 10000 primes starting at 0.

sync on
sync rate 0
tim=timer()
cmd$=cl$()
rem the command line is read in as one long string so we have to
rem divide it up. The parameters for this example will be two
rem inputs - a and b
rem a is the starting number
rem b is how many prime numbers to return
rem from the command line, a space or some other token separates the input.
rem That works to our advantage if yuse VAL() because that will return
rem a value up to the first non numeric entry. If there is no spearator,
rem then the value is read as one long entry
a=val(cmd$)
a1=a
rem for b, we can start with the length of a, and use VAL() again
ln=len(cmd$)
cmdstart=len(str$(a))+1
for n=cmdstart to ln
rem check for numeric character
testbyte=asc(mid$(cmd$,n))
if testbyte > 47 and testbyte < 58
rem if true we have our number
b=val(right$(cmd$,(ln-n)+1))
exit
endif
next n
rem show b number of primes starting at a1
countprime=0
while countprime < b
if isprime(a1)
inc countprime
print a1;" ";
endif
inc a1
endwhile
sync
rem show time it took
result=timer()-tim
ink 0,0
box 0,0,screen width()-1,40
ink rgb(255,255,255),0
set cursor 0,0
print "time = ";result/1000.0;" seconds to find ";countprime;" prime numbers starting at ";a
print "press enter"
wait key
end
function isprime(num)
sqnum=sqrt(num)
if mod(num,2)=0 then exitfunction 0
for n=3 to sqnum step 2
if mod(num,n)=0 then exitfunction 0
next n
endfunction 1
function mod(num,modulus)
value=num-((num/modulus)*modulus)
endfunction value

Enjoy your day.