home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 4 / CDPD_IV.bin / fish / 911-930 / ff925 / donsgenies / frenchgenies.lha / Rexx / TexteSauteur.pprx < prev    next >
Text File  |  1993-08-03  |  4KB  |  137 lines

  1. /*
  2. @BTexteSauteur @P @I Ecrit et © par Don Cox en août 1992
  3. @ICorrigé en Décembre 1992. N'est pas du Domaine Publique. Tous Droits
  4. @IRéservés
  5. Traduit et modifié par Fabien Larini le 30/07/93
  6.     
  7. Ce Génie applique une ligne de base aléatoire au bloc de texte 
  8. sélectionné. Avertissements : il augmente la taille du texte (ajout de 
  9. code de formatage) d'un facteur de 8 ou 9, et il ralenti PPage. Donc, 
  10. utilisez le à la fin de votre travail. Il demande et sauve dans
  11. son fichier de configuration le répertoire où il stocke ses fichiers 
  12. temporaires.
  13. */
  14.  
  15. /*JumpyText*/
  16. /* This Genie applies a random baseline shift to a selected block of text.
  17. Warnings: it is slow, it increases the length of the selected text by a 
  18. factor of 8 or 9 (because of all the style codes needed), and it slows 
  19. ProPage down to a crawl. So only do it at the end when you have got 
  20. everything else right.
  21.  
  22. Written by Don Cox  © August 92  Bug-fix Dec 92  Not Public Domain. All rights reserved. */
  23.  
  24. trace r
  25. signal on error
  26. signal on syntax
  27. address command
  28. numeric digits 3  /* for the random numbers  */
  29.            
  30. tempdir = ""
  31. pos = 0
  32. fichiercfg = "rexx:TexteSauteur.cfg"
  33. /* Demande si nouvelle config */
  34. if exists(fichiercfg) then
  35.     idem = ppm_Inform(2,"Utilisation de la configuration sauvée ?","Non","Oui")
  36.  
  37. /* Si fichier inexistant ou si utilisateur veut changer la config */
  38. if (~exists(fichiercfg) | idem=0) then do
  39.     /* Quel viewer */
  40.     tempdir = ppm_GetFileName("Choix du Répertoire Temporaire","","")
  41.     if tempdir = "" then exit_msg("Opération Annulée")
  42.     
  43.     /* Extrait le chemin */
  44.     pos = max(lastpos(":",tempdir),lastpos("/",tempdir))
  45.     tempdir = delstr(tempdir,pos+1)
  46.  
  47.     /* Sauver dans fichier ? */
  48.     if ppm_Inform(2,"Sauvegarder dans le fichier de configuration ?","Non","Oui") = 1 then do
  49.         if open(cfg,fichiercfg,"W") then do
  50.             call writeln(cfg,tempdir)
  51.             call close(cfg)
  52.         end
  53.         else
  54.             exit_msg("Impossible de sauvegarder le fichier de configuration")
  55.         end
  56.     end
  57. /* Chargement du fichier de config */
  58. else if idem = 1 then do
  59.         if open(cfg,fichiercfg,"R") then do
  60.             tempdir = readln(cfg)
  61.             call close(cfg)
  62.             end
  63.         else
  64.             exit_msg("Impossible de lire le fichier de configuration")
  65.         end    
  66.                                     
  67. tempfile = tempdir||"textefile.temp"
  68.     
  69.  
  70. if word(ppm_GetState(), 1) ~= 3 then exit_msg("Vous devez être en mode Edition pour utiliser ce Génie")
  71.  
  72. text = ppm_GetBlockText(0)
  73. if text = '' then exit_msg("Pas de Texte Sélectionné")
  74.  
  75.  
  76. factor = ppm_GetUserText(8,"Décalage Maximal (points)")
  77. if factor = "" then exit_msg("Abandon Utilisateur")
  78. if ~(datatype(factor,n)) then exit_msg("Saisie Invalide")
  79.  
  80. if factor>600 then factor = 600
  81.  
  82.  
  83. call ppm_ShowStatus("Traitement du Texte ...")
  84.  
  85. /* Split into sections to avoid trouble with ARexx's limit of 64k on length of strings  */
  86. sections = (length(text)%2000)+1
  87. do i=1 to sections
  88.     texts.i.endofsection = 2000
  89.     if i = sections then texts.i.endofsection = length(text)//2000
  90.     texts.i.thisSection = substr(text, (2000*(i-1))+1, texts.i.endofsection)
  91.     end
  92.                                     
  93. do i = 1 to sections
  94.     position = 1
  95.     newtext = ""
  96.     do until position = texts.i.endofsection+1
  97.         randbase = "\ls<"||randu()*factor||">"
  98.         nextchar = substr(texts.i.thisSection, position, 1)
  99.         newtext = newtext||randbase||nextchar
  100.         position = position+1
  101.         end
  102.     if i = 1 then call ppm_SaveText(tempfile,newtext)
  103.     if i>1 then call ppm_SaveMoreText(tempfile,newtext)
  104. end
  105.  
  106. call ppm_ShowStatus("Effacement de l'Ancien Texte ...")
  107. success = ppm_Cut()
  108. if success ~= 1 then exit_msg("Effacement Impossible")
  109. call ppm_ShowStatus("Insertion du Nouveau Texte ...")
  110. success = ppm_InsertFile(tempfile)
  111. if success~=1 then exit_msg("Insertion Impossible")
  112.                     
  113. if lastpos(" ",tempfile) ~= 0 then tempfile = '22'x||tempfile||'22'x
  114. "delete > nil: "tempfile
  115. call exit_msg()
  116. end
  117.  
  118.  
  119.  
  120. /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
  121.  
  122. error:
  123. syntax:
  124.     do
  125.     exit_msg("Arrêt du Génie dû à l'erreur: "errortext(rc))
  126.     end
  127.  
  128. exit_msg:
  129.     do
  130.     parse arg message
  131.     if message ~= "" then
  132.     call ppm_Inform(1,message,)
  133.     call ppm_ClearStatus()
  134.     exit
  135.     end
  136.  
  137.