PRINT USR 49152

LET a = USR 49152

RANDOMIZE USR 49152

IF USR 49152 THEN REM

If the only purpose of the USR function is to call the m/c from which the code would never return back to BASIC then you can choose any of these. If the routine would return some number you have to print or to calculate with then you might use PRINT or LET to print or to store the returned value.

USR function has one more meaning. If you pass it a string (a single letter) it will return an address of the corresponding UDG character. For example PRINT USR “A” will not call any machine code but will (probably) print 65368.

]]>RANDOMIZE USR 24576 runs the code at address 24576, then uses the return value to seed the RNG. We don’t actually need to seed the RNG, we’re just using it as a convenient way to swallow that unwanted return value to satisfy BASIC’s syntax checker.

You can use PRINT, or LET, but RANDOMIZE seems to be a de facto standard.

]]> 1 LET k=VAL “10”: LET x=k: LET y=k: LET a=k: LET b=k: BORDER VAL “1”

2 PRINT AT y,x;” “;AT a,b;”*”: LET y=a: LET x=b

3 LET k=IN 31: IF k=0 OR k>31 THEN GO TO 3

4 IF k=16 THEN GO TO 11

5 IF k>=16 THEN LET k=k-16

6 IF k>=8 THEN LET k=k-8: IF y>0 THEN LET a=y-1

7 IF k>=4 THEN LET k=k-4: IF y=2 THEN LET k=k-2: IF x>0 THEN LET b=x-1

9 IF k AND x<31 THEN LET b=x+1

10 GO TO 2

11 REM

1 LET l=SGN PI: LET n=-l: LET o=NOT PI: LET p=INT PI: LET a=l+l: LET b=a+a: LET c=a+p: LET d=a+c: LET e=d*p: LET f=d+a: LET g=b*b: LET h=VAL “31”: LET j=b*p: DIM t(c): DIM m(c): LET t(l)=l: LET t(a)=a: LET t(p)=b: LET t(b)=b+b: LET t(c)=g: LET x=c+c: LET x2=x: LET y=x: LET y2=x: BORDER l

2 PRINT AT y,x;” “;AT y2,x2;”*”: LET y=y2: LET x=x2

3 LET k=IN h: IF k=o OR k>h THEN GO TO p

4 IF k=g THEN GO TO j

5 FOR i=c TO l STEP n: IF k>=t(i) THEN LET m(i)=l: LET k=k-t(i): GO TO d

6 LET m(i)=o

7 NEXT i: IF m(l) AND xo THEN LET x2=x-l

9 IF m(p) AND yo THEN LET y2=y-l

11 GO TO a

12 REM

10 RANDOMIZE 1

20 PRINT RND

30 GO TO 10

If you want the computer to generate different sequences of random numbers on every run, you need to seed the PRNG with something that’s not constant. RANDOMIZE (or RANDOMIZE 0) on it’s own does this by seeding the PRNG with the time since computer start up. Since time is always ticking, this seed is never the same on every run thus leading to new sequences every time.

HTH.

]]>