/* 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) */
/* Version 1.03: 4 mars 2002 (adaptation Amitex 4.00) */
/* Version 1.04: 6 avril 2002 (correction bug fonction NEW) */
/* $VER: EditScript.AmiPCB 1.04 (© R.Florac, 6-Avr-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 55, 57, 58, 62, 64, 67 doivent être modifiées pour être
 * conformes à votre système ou à un autre éditeur de texte. */

/* 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: 55, 57, 58, 62, 64, 67 */

/* 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: 55, 57, 58, 62, 64, 67 */

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.0") then do     /* à améliorer... (Amitex.0, Amitex.1...) */
    f=0 			    /* il n'y avait pas de fenêtre ouverte */
    'run > nil:' "SYS:tools/Amitex/AmiTex"  /* chargement de l'éditeur */
    waitforport "Amitex.0"
end
else f=1			    /* il y a déjà une fenêtre active */

ADDRESS('Amitex.0')

if ~exists(script) then script=script||".AmiPCB"
if f=1 then 'OPEN("'script'")'      /* demande l'ouverture d'une autre fenêtre */
else '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
