/* Ce script inscrit les numéros de bornes des composants
   sur les pastilles (ou à côté)
   Version 1.00, 31 décembre 2001
   Version 1.01, 03-Feb-2002, German localization by A. Greve
   $VER: ShowPadNumbers.AmiPCB 1.01, © R.Florac, 3/2/2002 */

options results     /* indispensable pour récupérer le résultat des macros */

signal on error     /* pour l'interception des erreurs */
signal on syntax

lf='0a'x
fr='ARexx/InitVars.AmiPCB'()

'INIT(PAD,_GN_,_HS_,_VS_,_WW_,_ROT_,_SYM_,_SIDE_):PAD=-7:_HS_=HSCALE(0):_VS_=VSCALE(0):SAVEALL:SETSCALE(0,80,80):_SIDE_=SETSIDE(0,4):_WW_=SETWIDTH(0,15):_ROT_=ROTATE(0,0):_SYM_=SYMMETRY(0,0):FINDOBJ(0,PAD,-1,-1)'
pad=result
if pad<1 then do
    select
	when fr=1 then 'REQUEST("Aucune pastille n''est sélectionnée'lf'Voulez-vous marquer TOUTES'lf'les pastilles du document ?")'
	when fr=2 then 'REQUEST("Es ist kein Pad ausgewählt.'lf'Möchten Sie ALLE Pads'lf'im Dokument auswählen ?")'
	otherwise      'REQUEST("No pad is selected'lf'Do you want to mark ALL'lf'the pads of the document ?")'
    end
    if result ~=1 then exit
    'PAD=7:FINDOBJ(0,PAD,-1,-1)'
    pad=result
end

if pad<1 then do
    select
	when fr=1 then 'MESSAGE("Aucune pastille à marquer")'
	when fr=2 then 'MESSAGE("Kein zu markierendes Pad")'
	otherwise      'MESSAGE("No pad to mark")'
    end
    'SETSCALE(0,_HS_,_VS_):SETWIDTH(0,_WW_):SETSIDE(0,_SIDE_):ROTATE(0,_ROT_):SYMMETRY(0,_SYM_)'
    exit
end

select
    when fr=1 then 'SELECT("Emplacement des numéros","Dessus","Dessous","À droite","À gauche","Au centre")'
    when fr=2 then 'SELECT("Platzierung der Pin-Nummern","Oben","Unten","Rechts","Links","Zentriert")'
    otherwise	   'SELECT("Placement of pin numbers","Top","Bottom","Right","Left","Center")'
end
place=result

do while pad>0
    'PADNUM('pad',-1)'
    pin=result
    if pin>99 then l=1750
    else if pin>9 then l=1100
    else l=450
    select
	when place=1 then do	    /* Dessus */
	    'WRITE("'pin'",COL('pad')-'l',LINE('pad')-HEIGHT('pad')/2-50)'
	    pintext=result
	end
	when place=2 then do	    /* Dessous */
	    'WRITE("'pin'",COL('pad')-'l',LINE('pad')+HEIGHT('pad')/2+1350)'
	    pintext=result
	end
	when place=3 then do	    /* À droite */
	    'WRITE("'pin'",COL('pad')+WIDTH('pad')/2+20,LINE('pad')+500)'
	    pintext=result
	end
	when place=4 then do	    /* À gauche */
	    'WRITE("'pin'",COL('pad')-WIDTH('pad')/2-'l'-95,LINE('pad')+500)'
	    pintext=result
	end
	when place=5 then do	    /* Au centre */
	    'WRITE("'pin'",COL('pad')-'l',LINE('pad')+500)'
	    pintext=result
	end
	otherwise do
	    'SETSCALE(0,_HS_,_VS_):SETWIDTH(0,_WW_):SETSIDE(0,_SIDE_):ROTATE(0,_ROT_):SYMMETRY(0,_SYM_)'
	    exit
	end
    end
    'MARK('pintext'):IF(GROUP('pad')>0,_GN_=GETNAME(GROUP('pad')):SETNAME(GROUP(-GROUP('pad'),'pintext'),_GN_),0)'
    'FINDOBJ('pad',PAD,-1,-1)'
    pad=result
end

'SETSCALE(0,_HS_,_VS_):SETWIDTH(0,_WW_):SETSIDE(0,_SIDE_):ROTATE(0,_ROT_):SYMMETRY(0,_SYM_)'
exit

/* Traitement des erreurs, interruption du programme */
syntax:
erreur=RC
Call 'ARexx/_Syntax.rexx'(fr,'ShowPadNumbers.AmiPCB',SIGL,erreur)
'SETSCALE(0,_HS_,_VS_):SETWIDTH(0,_WW_):SETSIDE(0,_SIDE_):ROTATE(0,_ROT_):SYMMETRY(0,_SYM_)'
exit

error:
Call 'ARexx/_Error.rexx'(fr,'ShowPadNumbers.AmiPCB',SIGL)
'SETSCALE(0,_HS_,_VS_):SETWIDTH(0,_WW_):SETSIDE(0,_SIDE_):ROTATE(0,_ROT_):SYMMETRY(0,_SYM_)'
exit
