/* Edition d'un script à l'aide de l'éditeur de texte AmiTex */
/* Version 1.00: 18 juillet 2001, Chez Corbin */
/* Version 1.01: 1er décembre 2001 (German localization by A. Greve) */
/* Version 1.02: 20 janvier 2002 (utilisation PCBPATH) */
/* $VER: EditScript.AmiPCB 1.02 (© R.Florac, 20-Jan-2002) */
/* Chargement automatique d'un script dans AmiTex depuis AmiPCB */
/* L'appel se fait en sélectionnant l'un des onze menus Macros/ARexx
 * et en enfonçant en même temps la touche CONTROL (Ctrl).
 *
 * Les lignes 53, 55, 56, 60, 62, 65 doit être modifiée pour être conforme à votre système */

/* This script is called for loading a script file in a text editor
 * while working with AmiPCB.
 * Push the CONTROL key while selecting an ARexx menu with AmiPCB
 * to call it.
 * This script is for my text editor Amitex, adapt it
 * to any other text editor to suit to your needs.
 * Affected lines: 53, 55, 56, 60, 62, 65 */

/* Dieses Skript wird aufgerufen, wenn Skripte während des Arbeitens
 * mit AmiPCB bearbeitet werden sollen.
 * Drücken Sie CONTROL während der Selektion eines ARexx Menüpunktes,
 * um es zu starten.
 * Dieses Skript wurde für meinen Texteditor AmiTex geschrieben. Sie
 * müssen es anpassen, wenn Sie einen anderen Editor benutzen.
 * Betroffene Zeilen: 53, 55, 56, 60, 62, 65 */

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

options results

parse arg script		    /* récupération du nom du script */

fr = 'ARexx/InitVars.AmiPCB'()

'PCBPATH'
pcbpath=result

if script = "" then do
    select
        when fr=1 then 'REQFILE("Fichier script à éditer", "'pcbpath'ARexx", "")'
        when fr=2 then 'REQFILE("Zu bearbeitendes Skript", "'pcbpath'ARexx", "")'
        otherwise      'REQFILE("Script file to edit", "'pcbpath'ARexx", "")'
    end
    script = result
    if script="" then exit
end

port = ADDRESS()                    /* lecture du nom du port AmiPCB */

address command
if ~show(p, "AMITEX") then do       /* à améliorer... (AMITEX0, AMITEX1...) */
    f=0 			    /* il n'y avait pas de fenêtre ouverte */
    'run > nil:' "SYS:tools/Amitex/AmiTex"  /* chargement de l'éditeur */
    waitforport "AMITEX"
end
else f=1			    /* il y a déjà une fenêtre active */

ADDRESS(AMITEX)

if f=1 then 'NEW("")'               /* demande l'ouverture d'une autre fenêtre */
if ~exists(script) then script=script||".AmiPCB"

'LOAD("'script'"):STOFRONT'         /* demande le chargement du script */

exit

/* Traitement des erreurs, interruption du programme */
syntax:
address (port)
erreur=RC
Call 'ARexx/_Syntax.rexx'(fr,'EditScript.AmiPCB',SIGL,erreur)
exit

error:
address (port)
Call 'ARexx/_Error.rexx'(fr,'EditScript.AmiPCB',SIGL)
exit
