{ Random Sampling macros v 1.0 copyright ©1995 Arizona Board of Regents Written by John E. Morrow } var sSize, {width and height in pixels of each square} nhSquares, {# of squares horizontally} nvSquares, {# of squares vertically} :integer; procedure Setup(w,h,n); begin nhSquares:=w; nvSquares:=h; sSize:=n; end; macro '[S] Select Random Plots...' var i,j,x,y,n,maxSelections :integer; noDup,OK:boolean; theWindow:string; begin theWindow:=WindowTitle; sSize:=0; RevertToSaved; {€€€€€€€ Modify these lines to auto recognize images €€€€€€} {if theWindow='Your Image Name'then Setup(#across,#down,width)} { --------------- ------- ----- ----- } if theWindow='Regular Dots with Grid' then Setup(8,6,66); if theWindow='Clustered Dots with Grid' then Setup(8,6,66); if theWindow='Random Dots in Plots' then Setup(8,6,66); if theWindow='Regular Dots' then Setup(16,12,33); if theWindow='Clustered Dots' then Setup(16,12,33); if theWindow='Random Dots-small plots' then Setup(16,12,33); {€€€€€€€ €€€€€€€ €€€€€€€ €€€€€€€ €€€€€€€ €€€€€€€ €€€€€€€ €€€€€€} if sSize=0 then begin PutMessage('I do not recognize this image!'); nhSquares:=GetNumber('How many squares across?',20); nvSquares:=GetNumber('How many squares down?',10); sSize:=GetNumber('Length of a side of the squares?',30); end; maxSelections:=nhSquares*nvSquares; repeat OK:=true; n:=GetNumber('How many selections?',trunc(.1*maxSelections)); if n>maxSelections then begin PutMessage('You have picked too large of a number!'); OK:=false; end; until OK; selectAll; killRoi; for i:=1 to n do begin repeat noDup:=true; x:=round(random*(nhSquares-1)); y:=round(random*(nvSquares-1)); {check for duplicate coordinates} if not (i=1) then begin for j:= 1 to i-1 do begin if ((x=rX[j]) and (y=rY[j])) then noDup:=false; end; {for j} end;{if not(i=1)} until noDup; rX[i]:=x; rY[i]:=y; makeRoi(x*sSize,y*sSize,sSize,sSize); changevalues(1,1,255); killRoi; end; {for i} end; {macro} macro '[R] Revert'; begin RevertToSaved; end; { macro 'Make Grid' var x,y,i:integer; begin for i:=0 to 16 do begin x:=i*33; moveto(x,0); Lineto(x,396); end; for i:=0 to 12 do begin y:=i*33; moveto(0,y); lineto(528,y); end; }