 /*************************************************************\
/                                                               \                              
           SetGlobals V2.0, by Reinhard Grams © 1995
\                                                               / 
 \*************************************************************/

StartMacro:

	call InitMacro("SetGlobals",0)
	call DoTheJob()
	call ExitMacro()

/**************************************************************/

DoTheJob:

	call LWE_GlobalsRequester()

	return

/**************************************************************/

SaveConfig:

	success=open(state,config,'W')
	if (success) then do
		s=1; do while (s<=used_file_sel_nrs)
			writeln(state,sel_drawer.s); writeln(state,sel_file.s); s=s+1
		end
		call close state
	end
	return success

/**************************************************************/

LoadConfig:

    success=open(state, config, 'R')
	if (success) then do
		s=1; do while (s<=used_file_sel_nrs)
			sel_drawer.s=readln(state); sel_file.s=readln(state); s=s+1
		end
    	call close state
	end
	return success

/**************************************************************/
/**************************************************************/
			
InitMacro: PARSE ARG macro_name, used_file_sel_nrs

	signal on error; signal on syntax
	mathlib="rexxmathlib.library"
	rexxlib="rexxsupport.library"
	supplib="LWE.library"
	modport="LWModelerARexx.port"

	if (~show('L',rexxlib)) then do
		if (~addlib(rexxlib,0,-30,0)) then exit 14
		if (~show('L',rexxlib)) then exit 14
	end
	if (~show('L',mathlib)) then do
		if (~addlib(mathlib,0,-30,0)) then exit 14
		if (~show('L',mathlib)) then exit 14
	end
	if (~show('L',supplib)) then do
		if (~addlib(supplib,0,-30,0)) then exit 14
		if (~show('L',supplib)) then exit 14
	end
	p=addlib(modport,0); if (p!=0) then exit 14

	parse value LWE_GetSettings(macro_name) with,
		config selection temp language help verbose digits .
	success=LoadConfig()
	if ((help=1 & ~success) | help=2) then do
		t=LWE_Help(macro_name); if (t=3) then call ExitMacro()
	end
	return

/**************************************************************/

ExitMacro: PARSE ARG status, add_string

	call end_all()
	if (status~="") then do
		t=LWE_ErrorRequester(macro_name,status,add_string)
		if (t=1) then signal StartMacro
		if (t=2) then t=LWE_Help(macro_name)
		if (t=1) then signal StartMacro
	end
	call remlib(modport); exit 0

/**************************************************************/

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

/**************************************************************/
