/* Script ARexx permettant la conversion d'un objet texte en MAJUSCULES
   Chez Corbin, 7 Octobre 1997,  Version 1.00, © R.Florac
		7 Décembre 1997, version 1.01: extension à tous les objets sélectionnés
	       13 avril 1998,	 version 1.02: ajout SAVEALL
	       27 Février 1999,  version 1.03: ajout INIT variable
	       13 avril 2000,	 version 1.04: adaptation version 2.05
	       10 novembre 2000, version 1.05: localisation anglais/français
$VER: Majuscules.AmiCAD 1.05 (© R.Florac, 10/11/2000) */

options results

signal on error
signal on syntax

'LANGUAGE'
if result="français.language" then fr=1
else fr=0

'INIT(OBJET):OBJET=FIRSTSEL'; objet = result
if objet = 0 then do
    if fr=1 then 'MESSAGE("Il n''y a aucun objet"+CHR(10)+"qui soit sélectionné"):INIT(OBJET)'
    else 'MESSAGE("There is no selected object"):INIT(OBJET)'
    exit
end

'SAVEALL'
do while objet > 0			/* version 1.01 */
    'TYPE(OBJET)'; type = result
    'READTEXT(OBJET)'; texte = result

    i = 1
    l = length(texte)
    do while i <= l

	curletter = substr(texte, i, 1)
	if curletter = ' ' then
	do
	       i = i + 1
	       iterate
	end

	texte = overlay(upper(curletter), texte, i)

	i = i + 1
    end

    select
	when type = 4 then 'SETTEXT(OBJET,"'texte'")'
	when type = 5 then 'SETTEXT(OBJET,"'texte'")'
	when type = 6 then 'SETTEXT(OBJET,"'texte'")'
	when type = 11 then 'SETTEXT(OBJET,"'texte'")'
	when type = 12 then 'SETTEXT(OBJET,"'texte'")'
	otherwise nop
    end

    'OBJET=NEXTSEL(OBJET)'; objet = result
    if objet=0 then leave
end
'INIT(OBJET)'
exit

/* Traitement des erreurs, interruption du programme */
syntax:
erreur=RC
if fr=1 then 'MESSAGE("Script Majuscules.AmiCAD:"+CHR(10)+"Erreur de syntaxe"+CHR(10)+"en ligne 'SIGL'"+CHR(10)+"'errortext(erreur)'"):INIT(OBJET)'
else 'MESSAGE("Majuscules.AmiCAD script"+CHR(10)+"Syntax error"+CHR(10)+"in line 'SIGL'"+CHR(10)+"'errortext(erreur)'"):INIT(OBJET)'
exit

error:
if fr=1 then 'MESSAGE("Script Majuscules.AmiCAD:"+CHR(10)+"Erreur en ligne 'SIGL'"):INIT(OBJET)'
else 'MESSAGE("Majuscules.AmiCAD script:"+CHR(10)+"Error in line 'SIGL'"):INIT(OBJET)'
exit
