(*--------------------------------------------------------------------------*
 * DefIconer | Version 1.0 | released - 24.04.94                            *
 * Creates an appmenu from which the user can give files default icons      *
 * Lee Kindness - 8 Craigmarn Rd. Portlethen. ABERDEEN AB1 4QR SCOTLAND     *
 *                                                                          *
 * ToolType.PAS                                                             *
 *                                                                          *
 *--------------------------------------------------------------------------*)

Function GetArgString(Args : ppbyte; tooltype, Default : String) : String;

VAR
	tmpstr : STRPTR;
	RemKey : pRemember;
	
begin
	RemKey := NIL;
	tmpstr := FindToolType(Args, CStrConstPtrAR(@RemKey, tooltype));
	If tmpstr <> NIL then
		GetArgString := PtrToPas(tmpstr)
	else
		GetArgString := default;
	FreeRemember(@Remkey, True);
end;

Function GetArgBool(Args : ppbyte; tooltype : String; 
						default : Boolean) : Boolean; 

VAR
	tmpstr : STRPTR;
	RemKey : pRemember;
	
begin
	RemKey := NIL;
	tmpstr := FindToolType(Args, CStrConstPtrAR(@RemKey, tooltype));
	If tmpstr <> NIL then begin
		If MatchToolValue(tmpstr, CStrConstPtrAR(@RemKey, 'TRUE')) then
			GetArgBool := True;
		If MatchToolValue(tmpstr, CStrConstPtrAR(@RemKey, 'FALSE')) then
			GetArgBool := False;
	end else
		GetArgBool := Default;
	FreeRemember(@RemKey, True);
end;

Procedure GetToolTypes(VAR Args : tProgVars);

VAR
	dobj    : pDiskObject;
	CLIArgs : Array[1..6] of STRPTR;
	n, n2   : byte;
	Tmpstr  : STRPTR;
	RemKey  : pRemember;
	
CONST
	ArgPtr : ppbyte = NIL;
	ToolRead : Boolean = FALSE;
	
Begin
	RemKEy := NIL;
	If CmdLinePtr.Len >= 1 then begin
		if ParamCount > 5 then n2 := 5
		else n2 := paramcount;
		for n := 1 to n2 do
			CLIArgs[n] := CStrConstPtrAR(@RemKey, ParamStr(n));
		CLIArgs[n2+1] := NIL;
		ArgPtr := @CLIArgs;
	end else begin
		dobj := GetDiskObject(CStrConstPtrAR(@RemKey, Paramstr(0)));
		if dobj <> NIL then begin
			ArgPtr := dobj^.do_ToolTypes;
			ToolRead := True;
		end;
	end;
	
	If ArgPtr <> NIL then begin
		
		Args.REXXPORT := GetArgString(ArgPtr, 'REXXPORT', Args.REXXPORT);
		Args.REXXCMD := GetArgString(ArgPtr, 'REXXCMD', Args.REXXCMD);
		Args.TEXT := GetArgString(ArgPtr, 'TEXT', Args.TEXT);
		Args.REXX := GetArgBool(ArgPtr, 'REXX' ,Args.Rexx);
			
		IF ToolRead then FreeDiskObject(dobj);
	
	end;
	FreeRemember(@RemKey, True);
end;