;
; This piece of code is Copyright © 1992-1995 by Stefano Reksten
; (GUNDAM) of 3AM - The Three Amigos!!
;

	incdir include:
	include LVO3.0/exec_lib.i
	include LVO3.0/intuition_lib.i
	include LVO3.0/dos_lib.i

	include intuition/intuition.i

	move.l	$4,a6
	lea	DosName,a1
	move.l	#36,d0
	jsr	_LVOOpenLibrary(a6)
	tst.l	d0
	beq.w	nodos
	move.l	d0,DOSBase

	lea	IntuiName,a1
	move.l	#36,d0
	jsr	_LVOOpenLibrary(a6)
	tst.l	d0
	beq.w	nointui
	move.l	d0,IntuiBase

	move.l	DOSBase,a6
	move.l	#ArgTemplate,d1
	move.l	#ReqArgs,d2
	moveq	#0,d3
	jsr	_LVOReadArgs(a6)
	tst.l	d0
	beq.b	noargs
	move.l	d0,Args

	move.l	Body,a0
nxtchar
	tst.b	(a0)
	beq.b	nosubst
	cmp.b	#'|',(a0)
	bne.b	nochange
	move.b	#10,(a0)
nochange
	adda	#1,a0
	bra.b	nxtchar
	
nosubst
	move.l	IntuiBase,a6
	sub.l	a0,a0
	lea	ReqStruct,a1
	sub.l	a2,a2
	sub.l	a3,a3
	jsr	_LVOEasyRequestArgs(a6)
	mulu.w	#5,d0
	move.l	d0,Result

	move.l	DOSBase,a6
	move.l	Args,d1
	jsr	_LVOFreeArgs(a6)
noargs
	move.l	IntuiBase,a1
	move.l	$4,a6
	jsr	_LVOCloseLibrary(a6)
nointui
	move.l	DOSBase,a1
	move.l	$4,a6
	jsr	_LVOCloseLibrary(a6)
nodos
	move.l	Result,d0
	rts
	
Result
	dc.l	0
DOSBase
	dc.l	0
IntuiBase
	dc.l	0
ReqStruct
	dc.l	EasyStruct_SIZEOF
	dc.l	0
ReqArgs
Title
	dc.l	0
Body
	dc.l	0
GadgetString
	dc.l	DefaultGadgets
Args
	dc.l	0
DosName
	dc.b	"dos.library",0
IntuiName
	dc.b	"intuition.library",0
ArgTemplate
	dc.b	"Title/A,Body/A,Gadgets",0
ReqString
	dc.b	"$VER: Request v1.1 (01-01-95)",0
DefaultGadgets
	dc.b	"OK|Cancel",0

	END
