/* Either calculates the edges of the first 24bit */
/* file and displays, or adds triangles based on  */
/* the edgess                                     */
/* $VER: EdgePoints_MPM 4.4 (23.2.97)
 */

/* Lock the gui								*/
LockGui
/* Check points open							*/
options results
GetAttr openpoints var openpoints
options
if (openpoints = "0") then do
	address command 'requestchoice "MPMorph EdgePoints" "Image windows must be open" "OK"'
	UnlockGui
	exit
end
numeric digits 12
options results
GetAttr file1 var file1
GetAttr file2 var file2
GetAttr file241 var file241
GetAttr file242 var file242
GetAttr width var width
GetAttr height var height
GetAttr pubscreen var pubscreen
GetAttr saved var saved
GetAttr hook var hook
options
if (saved = "0") then do
	address command 'requestchoice "MPMorph EdgePoints Error" "File not saved" "OK"'
	UnlockGui
	exit
end
if (file241 = "") then do
	file241 = file1
end
if (file242 = "") then do
	file242 = file2
end
/* parameters for the gui					*/
if pubscreen="" then do
	params = '"'file241'" "'file242'" 'width' 'height' "" 'hook
end
else do
	params = '"'file241'" "'file242'" 'width' 'height' "PUBSCREEN='pubscreen'" 'hook
end

/* Display the gui							*/
if pubscreen="" then do
	address command 'MPMorph:RunMPGui MPMorph:gui/EdgePoints.gui to t:EdgePoints.temp help=MPMorph:EdgePoints.guide relmouse params='params
end
else do
	address command 'MPMorph:RunMPGui MPMorph:gui/EdgePoints.gui to t:EdgePoints.temp help=MPMorph:EdgePoints.guide relmouse params='params' pubscreen="'pubscreen'"'
end
/* quit if cancelled							*/
if (rc > 4) then do
	if (rc > 9) then do
		address command 'requestchoice "MPMorph EdgePoints Error" "Failure calling RunMPGui" "OK"'
	end
	UnlockGui
	exit
end
unlockgui
address command 'delete t:temp.mpm'
SetMessage "Edging_Points"
address command 'execute t:EdgePoints.temp'
if (rc = 0) then do
	if exists('t:temp.mpm') then do
		lockgui
		SetMessage "Adding_Points"
		'newpoints force'
		't:temp.mpm'
		'triangulate force'
		UnlockGui
	end
end
else do
	address command 'requestchoice "MPMorph EdgePoints Error" "Failure calling EdgePoints" "OK"'
end
/* the end!										*/
exit