Intermec PM43/PM43c Fingerprint Developer's Guide (PC23d, PC43d/t, PM23c, PM43 - Page 55
Generating Random Numbers, Calling the RANDOM Function, Using a RANDOMIZE Statement
View all Intermec PM43/PM43c manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 55 highlights
Chapter 4 - Managing Input and Output Generating Random Numbers The Fingerprint commands RANDOM and RANDOMIZE are used to generate random numbers for test programs or other applications. Calling the RANDOM Function The RANDOM function generates a random integer within a specified interval. This example tests a random dot on the printhead of a 12 dots/mm printer: 10 MIN%=HEAD(-7)*85\100: MAX%=HEAD(-7)*115\100 20 DOTNO%=RANDOM(0,1279) 30 IF HEAD(DOTNO%)MAX% THEN 40 BEEP 50 PRINT "ERROR IN DOT "; DOTNO% 60 ELSE 70 BEEP 80 PRINT "HEADTEST: OK!" 90 END IF RUN Using a RANDOMIZE Statement To obtain a higher degree of randomization, the random number generator can be reseeded using the RANDOMIZE statement. You can either include an integer with which the generator will be reseeded, or a prompt will appear asking you to do so. This example prints a random pattern of dots after the random number generator has been reseeded: 10 RANDOMIZE 20 FOR Q%=1 TO 100 30 X%=RANDOM(50,400) 40 Y%=RANDOM(50,400) 50 PRPOS X%,Y% 60 PRLINE 5,5 70 NEXT 80 PRINTFEED RUN The printer returns: Random Number Seed (0 to 99999999) ? (prompt) For a higher degree of randomization, you can reseed the random integer generator with another random integer provided by a function such as TICKS: 10 A%=TICKS 20 RANDOMIZE A% 30 B%=RANDOM(1,100) 40 PRINT B% RUN The printer returns: 42 Fingerprint Developer's Guide 43