/* PointPlane.lwm -- CMD: Plane of Points
 * By Arnie Cachelin © 1992 NewTek Inc. */

points=50
sysnam = 'Planar Point Distribution'

Modeler= "LWModelerARexx.port"
L=SHOW('Libraries')
IF POS(Modeler ,L ) = 0 THEN ADDLIB("LWModelerARexx.port",0)
signal on error
signal on syntax

call req_begin sysnam

id_Nx   = req_addcontrol("X Points Per Side", 'n',0)
id_Ny   = req_addcontrol("Y Points Per Side", 'n',0)

call req_setval id_Nx,points
call req_setval id_Ny,points

if (~req_post()) then do
    call req_end
    exit
end

xpoints = abs(req_getval(id_Nx)) % 1
ypoints = abs(req_getval(id_Ny)) % 1
call req_end
points=xpoints*ypoints
if points>65000 then do
	call notify(1,'!'xpoints'x'ypoints' gives 'points' Points','   and that's just too many.)
	exit
	end
call add_begin
call meter_begin points+1, "Generating "points" Points"
dx=.01
dy=dx
x=0
y=0
z=0
N=0
do i=1 to ypoints
	do j=1 to xpoints
  	N=N+1
    x=x+dx
    call add_point x y z
    call add_polygon i
    call meter_step
		end j
 	y=y+dy
	x=0
end i
call add_end()
call notify( 1,'!'Sysnam,"@Drew "N" points")

exit

syntax:
error:
  call end_all
	t=Notify(1,'!Rexx Script Error','@'ErrorText(rc),'Line 'SIGL)
	exit