home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #4 / amigaacscoverdisc1998-041998.iso / utilities / commercialdemos / gestacomptedemo / scripts_arexx / tab2.rexx < prev    next >
OS/2 REXX Batch file  |  1997-11-13  |  8KB  |  247 lines

  1. /** $VER: Tab2 1.2 (05.09.97)
  2.  ** Auteur: Fabrice SABATIER
  3.  **
  4.  ** Commande Arexx sous GestaLivre V2.0.
  5.  **
  6.  ** Création des tableaux en ARexx pour un cabinet médical.
  7.  **
  8.  **/
  9.  
  10. OPTIONS RESULTS
  11.  
  12. NL                  = '0a'x
  13. SautPage            = '0C'x   /* caractère de saut de page */
  14. ESC                 = '1B'x
  15.  
  16. /*****************  Définit les variables d'environnement   ***********************/
  17.  
  18. ADDRESS COMMAND "SYS:Rexxc/rx ENV:GestaCompte.ARexxPréfs" /* execute le script de définitions des préférences */
  19. NOM_PORT_LIVRE   =GETCLIP('Port_Livre')
  20. NOM_ECRAN_PUB    =GETCLIP('Ecran_Livre')
  21.  
  22. /************************************************************************/
  23.  
  24. SIGNAL ON SYNTAX        /* détourne les messages d'erreurs */
  25.  
  26. /* ouvre la library rexxreqtools.library pour les messages d'erreurs */
  27. call addlib("rexxreqtools.library",0,-30,0)
  28.  
  29. ADDRESS VALUE NOM_PORT_LIVRE /* adresse du port Arexx */
  30.  
  31. nbre=0
  32. NumeroLigne=0        /* initialisation des variables */
  33. NumeroPage=1
  34. TotalLignes=30
  35. Somme590=0
  36. Somme730=0
  37. Somme600=0
  38. Somme610=0
  39. Somme611=0
  40. Somme620=0
  41. Somme620E=0
  42. SommeSC=0
  43. SommeSB1=0
  44. SommeSB2=0
  45. LettreMois.01='JANVIER'
  46. LettreMois.02='FEVRIER'
  47. LettreMois.03='MARS'
  48. LettreMois.04='AVRIL'
  49. LettreMois.05='MAI'
  50. LettreMois.06='JUIN'
  51. LettreMois.07='JUILLET'
  52. LettreMois.08='AOUT'
  53. LettreMois.09='SEPTEMBRE'
  54. LettreMois.10='OCTOBRE'
  55. LettreMois.11='NOVEMBRE'
  56. LettreMois.12='DECEMBRE'
  57. res=0
  58.  
  59. x=OPEN('infos','ram:Tableau2','w')  /* crée le fichier */
  60.  
  61. operation 1
  62. PARSE VAR result . '/' mois '/' .  /* récupère le mois sélectionné */
  63.  
  64. /* Entête du fichier */
  65. CALL Tableau2EnTete
  66.  
  67. numboperations             /* cherche le nombre d'opérations dans le mois */
  68. nbre= result
  69.  
  70. DO i=1 TO nbre             /* passe toutes les opérations une à une */
  71. operation i
  72.  PARSE VAR result jour '/' . '/' Nature '/' Somme '/' Libelle '/' Poste '/' .
  73.  
  74. IF i=TotalLignes THEN DO   /* toutes les 30ème opérations on passe à la page suivante */
  75.                        NumeroPage=NumeroPage+1
  76.                        CALL Tableau2Total
  77.                        res=WRITELN('infos',SautPage)
  78.                        NumeroLigne=0
  79.                        CALL Tableau2EnTete
  80.                        TotalLignes=TotalLignes+29
  81.                       END
  82.  
  83. /* Composition d'une ligne */
  84. ligne= '|'LEFT(libelle,20,' ')'|'
  85.  
  86. IF Nature="Bank1Outflow" THEN DO
  87.                                ligne= ligne||RIGHT(Somme,9,' ')
  88.                                SommeSB1=SommeSB1+Somme
  89.                                END
  90. ELSE ligne= ligne||"         "
  91. ligne= ligne'|'
  92.  
  93. IF Nature="Bank2Outflow" THEN DO
  94.                                ligne= ligne||RIGHT(Somme,9,' ')
  95.                                SommeSB2=SommeSB2+Somme
  96.                                END
  97. ELSE ligne= ligne||"         "
  98. ligne= ligne'|'
  99.  
  100. IF Nature="CashPayment" THEN DO
  101.                               ligne= ligne||RIGHT(Somme,9,' ')
  102.                               SommeSC=SommeSC+Somme
  103.                               END
  104. ELSE ligne= ligne||"         "
  105. ligne= ligne'||'
  106.  
  107. IF Poste="590   " THEN DO
  108.                        ligne= ligne||RIGHT(Somme,9,' ')
  109.                        Somme590=Somme590+Somme
  110.                        END
  111. ELSE ligne= ligne||"         "
  112.  
  113. ligne= ligne'|'
  114.  
  115. IF Poste="730   " THEN DO
  116.                        ligne= ligne||RIGHT(Somme,9,' ')
  117.                        Somme730=Somme730+Somme
  118.                        END
  119.  
  120. ELSE ligne= ligne||"         "
  121. ligne= ligne'|'
  122.  
  123. IF Poste="600   " THEN DO
  124.                        ligne= ligne||RIGHT(Somme,9,' ')
  125.                        Somme600=Somme600+Somme
  126.                        END
  127. ELSE ligne= ligne||"         "
  128. ligne= ligne'|'
  129.  
  130. IF Poste="610   " THEN DO
  131.                        ligne= ligne||RIGHT(Somme,9,' ')
  132.                        Somme610=Somme610+Somme
  133.                        END
  134. ELSE ligne= ligne||"         "
  135. ligne= ligne'|'
  136.  
  137. IF Poste="611   " THEN DO
  138.                        ligne= ligne||RIGHT(Somme,9,' ')
  139.                        Somme611=Somme611+Somme
  140.                        END
  141. ELSE ligne= ligne||"         "
  142. ligne= ligne'|'
  143.  
  144. IF Poste="620   " THEN DO
  145.                        ligne= ligne||RIGHT(Somme,9,' ')
  146.                        Somme620=Somme620+Somme
  147.                        END
  148. ELSE ligne= ligne||"         "
  149. ligne= ligne'|'
  150.  
  151. IF Poste="620(1)" THEN DO
  152.                        ligne= ligne||RIGHT(Somme,9,' ')
  153.                        Somme620E=Somme620E+Somme
  154.                        END
  155. ELSE ligne= ligne||"         "
  156. ligne= ligne'|'
  157.  
  158.  
  159. NumeroLigne=NumeroLigne+1
  160. ligneImp= RIGHT(NumeroLigne,2,' ')||ligne
  161. res=WRITELN('infos',ligneImp)
  162. END
  163.  
  164. CALL Tableau2Total
  165. x=CLOSE('infos')       /* ferme le fichier */
  166. EXIT
  167.  
  168. /*---------------- Total du Tableau 2 --------------*/
  169. Tableau2Total:
  170. res=WRITELN('infos',traitH)
  171. ligne="AR|                    |"
  172. CALL ComposeLigne
  173. res=WRITELN('infos',ligne || '|')
  174. res=WRITELN('infos',ESC||'[3w')
  175.  
  176. RETURN
  177.  
  178. /*---------------- Entête du Tableau 2 --------------*/
  179. Tableau2EnTete:
  180. traitH="  ---------------------------------------------------------------------------------------------------------------------------"
  181. Entete="  |      LIBELLE       | Banque1 | Banque2 |  Caisse ||   590   |   730   |   600   |   610   |   611   |   620   |  620(1) |"
  182. res=WRITELN('infos',ESC||'[4w')
  183. res=WRITELN('infos','                                            FEUILLE COMPTABLE (2ème Partie)                        page 'NumeroPage)
  184. showyear
  185. res=WRITELN('infos','     ANNEE: '||result)
  186. res=WRITELN('infos','      MOIS: 'lettremois.mois)
  187. res=WRITELN('infos',traitH)
  188. res=WRITELN('infos',Entete)
  189. res=WRITELN('infos',traitH)
  190.  
  191. /* Ecrit les lignes des données dans le fichier */
  192. ligne=" R|                    |"
  193. CALL ComposeLigne
  194. ligne= ligne'|'
  195.  
  196. res=WRITELN('infos',ligne)
  197.  
  198. RETURN
  199.  
  200. ComposeLigne:
  201. IF SommeSB1>0 THEN ligne= ligne || RIGHT(SommeSB1,9,' ')
  202. ELSE ligne= ligne||"         "
  203. ligne= ligne'|'
  204. IF SommeSB2>0 THEN ligne= ligne || RIGHT(SommeSB2,9,' ')
  205. ELSE ligne= ligne||"         "
  206. ligne= ligne'|'
  207. IF SommeSC>0 THEN ligne= ligne || RIGHT(SommeSC,9,' ')
  208. ELSE ligne= ligne||"         "
  209. ligne= ligne'||'
  210. IF Somme590>0 THEN ligne= ligne || RIGHT(Somme590,9,' ')
  211. ELSE ligne= ligne||"         "
  212. ligne= ligne'|'
  213. IF Somme730>0 THEN ligne= ligne || RIGHT(Somme730,9,' ')
  214. ELSE ligne= ligne||"         "
  215. ligne= ligne'|'
  216. IF Somme600>0 THEN ligne= ligne || RIGHT(Somme600,9,' ')
  217. ELSE ligne= ligne||"         "
  218. ligne= ligne'|'
  219. IF Somme610>0 THEN ligne= ligne || RIGHT(Somme610,9,' ')
  220. ELSE ligne= ligne||"         "
  221. ligne= ligne'|'
  222. IF Somme611>0 THEN ligne= ligne || RIGHT(Somme611,9,' ')
  223. ELSE ligne= ligne||"         "
  224. ligne= ligne'|'
  225. IF Somme620>0 THEN ligne= ligne || RIGHT(Somme620,9,' ')
  226. ELSE ligne= ligne||"         "
  227. ligne= ligne'|'
  228. IF Somme620E>0 THEN ligne= ligne || RIGHT(Somme620E,9,' ')
  229. ELSE ligne= ligne||"         "
  230. RETURN
  231.  
  232. /* Traite les messages d'erreurs */
  233. SYNTAX:
  234. IF RC=13 THEN call rtezrequest( "      Environnement serveur non trouvé !!!" || NL || NL ||,
  235.                                 "Le nom du port ARexx utilisé dans le script est : "|| NL || NL ||,
  236.                                 "-----------------------------------------------"|| NL ||,
  237.                                 "                  " || NOM_PORT_LIVRE || NL ||,
  238.                                 "-----------------------------------------------"|| NL || NL ||,
  239.                                 "Note : Pour réparer ceci, veuillez fermer le module"|| NL ||,
  240.                 "       'Livre' et modifier le type d'outil 'REXX' de"|| NL ||,
  241.                 "       l'icône, puis le relancer."|| NL || NL ||,
  242.                 "       ATTENTION aux minuscules/majuscules      ",,
  243.                 "OK", "Informations","rt_pubscrname="||NOM_ECRAN_PUB "rt_font=Gestacompte.font/8")
  244. ELSE call rtezrequest(errortext(RC),"Vu",,"rt_pubscrname="||NOM_PORT_LIVRE "rt_font=Gestacompte.font/8")
  245. EXIT
  246.  
  247.