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

StartMacro:

	call InitMacro("Manual",0)
	call SetParms()
	call DoTheJob()
	call ExitMacro()

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

DoTheJob:

	action=LWE_VarRequester(macro_name,hsel.language,'@',1,0)
	if (action=0) then call ExitMacro()

	select
		when (action=DO_MANUAL) then call Manual()
		when (action=DO_HELP) then call Help()
	end
	
	return

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

Help:

	lcom="List FILES LFORMAT="'"%s"'" PAT=(#?."||ext.language||") TO"
	hpath=LWE_AddFile(macro_path,"Help")
 	address command lcom temp hpath
	address command "Sort >NIL: FROM" temp "TO" temp
	t=LWE_ListRequester(hmes.language,'@',0,sel,'F',temp,'S')
	address command "Delete >NIL:" temp
	if (t="") then call ExitMacro()
	topic=1; topics=words(t)
	do until (topic>topics)
		name=left(word(t,topic),length(word(t,topic))-4)
		h=LWE_Help(name); if (h=3) then call ExitMacro()
		topic=topic+1
	end
	return
	
/**************************************************************/

Manual:

	do forever
		topic=LWE_VarRequester(ames.language,asel.language,' ',1,0)
		if (topic=0) then call ExitMacro()
		t=LWE_Help(names.topic,"Manual",word(asel.language,topic))
		if (t=3) then call ExitMacro()
	end
	return

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

InitVariables:

	DO_MANUAL=1
	DO_HELP=2

	ext.0="ENG"
	ext.1="GER"

	names.1="General"
	names.2="Overview"
	names.3="Version"
	names.4="Requester"
	names.5="Formulas"
	names.6="Libraries"
	names.7="AdPro"
	names.8="Installation"

	ames.0="Select Topic"
	ames.1="Auswahl des Themas"
	asel.0="General Overview Version Requester Formulas Libraries ADPro Installation"
	asel.1="Allgemeines Kurzübersicht Version Requester Formeln Libraries ADPro Installation"
	hsel.0="Read Manual@Help Overview"
	hsel.1="Manual lesen@Hilfe Übersicht"
	hmes.0="Select Help"
	hmes.1="Hilfe Auswahl"

	return

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

SetParms:

	call SaveConfig()

	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 macro_path .
	call InitVariables(); 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()

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