/* Script ARexx permettant le tracé d'un cartouche dans une fenêtre AmiCAD */
/* Chez Corbin, Vendredi 3 Octobre 1997, Version 1.00, © R.Florac */
/* Version 1.01, 2 Novembre 1997, trait vertical rajouté dans cartouche */

options results

signal on error
signal on syntax

'WWIDTH(-1)'; l = result; lc = result % 3
'WHEIGHT(-1)'; h =result
'ROTATE(0,0):SYMMETRY(0,1)'

/* dessin du contour */
'DRAWMODE(2):DRAW(5,5,'l-5',5):DRAW('l-5',5,'l-5','h-5')'
'DRAW('l-5','h-5',5,'h-5'):DRAW(5,'h-5',5,5)'

'SELECT("Emplacement du cartouche"+CHR(10)+"En haut à gauche"+CHR(10)+"En haut à droite"+CHR(10)+"En haut au centre"+CHR(10)+"En bas au centre"+CHR(10)+"En bas à droite"+CHR(10)+"En bas à gauche")'
c = result

select
    when c = 1 then do	    /* En haut à gauche */
	x0 = 5
	x1 = lc + 5
	y0 = 5
	y1 = 60
	bh = 0
	bb = 1
	bg = 0
	bd = 1
    end
    when c = 2 then do	    /* En haut à droite */
	x0 = l - lc - 5
	x1 = l - 5
	y0 = 5
	y1 = 60
	bh = 0
	bb = 1
	bg = 1
	bd = 0
    end
    when c = 3 then do	    /* En haut au centre */
	x0 = l % 2 - lc % 2
	x1 = x0 + lc
	y0 = 5
	y1 = 60
	bh = 0
	bb = 1
	bg = 1
	bd = 1
    end
    when c = 4 then do	    /* En bas au centre */
	x0 = l % 2 - lc % 2
	x1 = x0 + lc
	y0 = h - 60
	y1 = h - 5
	bh = 1
	bb = 0
	bg = 1
	bd = 1
    end
    when c = 6 then do	    /* En bas à gauche */
	x0 = 5
	x1 = 5 + lc
	y0 = h - 60
	y1 = h - 5
	bh = 1
	bb = 0
	bg = 0
	bd = 1
    end
    when c = 5 then do	    /* En bas à droite */
	x0 = l - lc - 5
	x1 = l - 5
	y0 = h - 60
	y1 = h - 5
	bh = 1
	bb = 0
	bg = 1
	bd = 0
    end
    otherwise exit
end
if bh > 0 then 'DRAW('x0','y0','x1','y0')'
if bb > 0 then 'DRAW('x0','y1','x1','y1')'
if bg > 0 then 'DRAW('x0','y0','x0','y1')'
if bd > 0 then 'DRAW('x1','y0','x1','y1')'
'SETSCALE(0,1,1):WRITE("DATE",'x0+7','y1-5'):WRITE("TITRE",'x0+7','y1-35')'
'DRAWMODE(1):DRAW('x0+60','y0','x0+60','y1'):DRAW('x0','y0+35','x1','y0+35')'

exit

/* Traitement des erreurs, interruption du programme */
syntax:
erreur=RC
'MESSAGE("Script Cartouche.AmiCAD:"+CHR(10)+"Erreur de syntaxe"+CHR(10)+"en ligne 'SIGL'"+CHR(10)+"'errortext(erreur)'")'
exit

error:
'MESSAGE("Script Cartouche.AmiCAD:"+CHR(10)+"Erreur en ligne 'SIGL'")'
exit
