/* (gH) -_- catv.rex ; TimeStamp (unix) : 24 Novembre 2012 vers 20:21 */ parse arg f1 f2 nbesp l1max . if words(f2)=0 then do say say " catv : ??? -- titre masqué par (gH) pour exercice M1 info" say " syntaxe : catv fic1 fic2 [nbesp longueurMax] " say " exemples : catv a.txt b.txt " say " catv a.txt b.txt 5 " say " catv a.txt b.txt 5 70" say return end /* fin de si */ if nbesp = "" then nbesp = 0 entre = copies(" ",nbesp) nbl. = 0 lig. = "" /* lecture des deux fichiers */ call litf 1 f1 call litf 2 f2 nbl = nbl.1 if nbl.2 > nbl then nbl = nbl.2 /* écriture du fichier résultat */ fics = "catv.sor" rf = fileut("delFile^"fics) do i = 1 to nbl if l1max="" then do call lineout fics , lig.1.i entre lig.2.i end ; else do call lineout fics , rexxut("surncarg^"l1max"^"lig.1.i) entre lig.2.i end /* fin si */ end /* fin de tant que */ call lineout fics say " vous pouvez utiliser " fics return /* ========== sous-programme ========== */ litf: parse arg nf nomf say " lecture " nf " : " nomf do while lines(nomf)>0 nbl.nf = nbl.nf +1 n = nbl.nf lig.nf.n = linein( nomf ) end /* fin de tant que */ if nbl.nf = 0 then say " attention fichier " nom " vide " call lineout nomf return