PACKAGE NETREXX 'hhns' (Version NetRexx/2) SOMMAIRE Intro : buts et utilisation A - Methodes de la classe hhutils B - Methodes de la classe webutils C - Methodes de la classe Rxqueue ------------------------------------------------------------------------- Buts : a) simulation de finction et entrees/sorties Rexx traditionnelles b) outillage WEB de type 'Common Rexx Interface' HHNS c) simulation de la stack Rexx Utilisation : - hhns.jar : dans $JAVA_HOME/jre/lib/ext, ou dans $CLASSPATH - A utiliser avec import hhns. ... class .... uses hhutils, hhstk, Rxqueue .... -- ( pour eviter la qualification, sinon : hhutils.popen ... ) Compile et teste avec NetRexx V2 et : - jdk 1.3 (Linux, Win32) - jdk 1.1.8 (AIX 4.3) ------------------------------------------------------------------------- A - Methodes de la classe hhutils popen - Recuperation du resultat d'une commande systeme Proto : method popen(cmd=Rexx) public static returns hhstk Exemple : h = popen(cmd) -- mais sans pipe (a | b) if h = null then say " --> null" else loop z = h.pull -- mais si, mais si ! if z = null then leave say " ["z"]" end h.close -- merci, thank you, Danke schoen, grazie, spaciba, misaoutr ... charout - ecriture string sur fichier ou console (fid = null) Proto : method charout(ofid=Rexx) public static -- (retuns void) method charout(ofid=Rexx, z=Rexx) public static -- (retuns void) method charout(ofid=Rexx, z=String) public static -- (retuns void) Exemple : charout(ofid, any_rexx_expression) -- ofid peut etre null charout(ofid, any_String) -- ofid peut etre null charout(ofid) -- ferme le fichier (='rembobinage') lineout - ecriture d'une ligne sur fichier ou console (fid = null) Proto : method lineout(ofid=Rexx) public static -- (retuns void) method lineout(ofid=Rexx, z=Rexx) public static -- (retuns void) method lineout(ofid=Rexx, z=String) public static -- (retuns void) Exemple : lineout(ofid, any_rexx_expression) -- ofid peut etre null lineout(ofid, any_String) -- ofid peut etre null lineout(ofid) -- ferme le fichier (='rembobinage') chars et lines : test de fin de fichier Proto : method lines(ifid=Rexx) public static returns Rexx method chars(ifid=Rexx) public static returns Rexx Exemple : loop while chars(ifid) > 0 -- ou lines(ifid) z = linein(ifid) ... end linein - lecture d'une ligne depuis fichier ou console (fid null) Proto : method linein(ifid=Rexx) public static returns Rexx Exemple : z = linein(ifid) -- ifid peut etre null = stdin charin - lecture de n octets depuis fichier ou console (fid null) Proto : method charin(ifid=Rexx, null, lgmax=Rexx) public static returns Rexx Exemple : z = charin(ifid, null, lgmax) -- ifid peut etre null = stdin state - verification de l'existence d'un fichier Proto : method state(fid=Rexx) public static returns boolean Exemple : if state(fid) then ... -- il existe unlink - delete d'un fichier Proto : method unlink(fid=Rexx) public static Exemple : unlink(fid) -- deleted if exist. date, time : a la mode Rexx Proto : method date(typ=Rexx) public static returns Rexx method time(typ=Rexx null) public static returns Rexx Exemple : say date("E") time() file2stem - chargement d'un fichier dans un stem Proto : method file2stem(fid=Rexx, stem=Rexx) public static returns Rexx Returns : le nbre de lignes chargees ( = t[0]) Exemple : t = rexx('') n = file2stem("myfile.data", t) loop i = 1 to n ... t[n] ... end ------------------------------------------------------------------------- B - Methodes de la classe webutils webit - traduction d'une string en marques html (accentuation ...) Proto : method webit(a=Rexx) returns Rexx static tags - generation d'une marque complete avec ses 2 tags Proto : method tags(t=Rexx, m=Rexx) static returns Rexx tbkHdr - generation d'une marque 'en-tete' de table Proto : method tblHdr(a1=Rexx, a2=Rexx null, a3=Rexx null, a4=Rexx null, a5=Rexx null, a6=Rexx null, a7=Rexx null, a8=Rexx null) static returns Rexx tbkHdr - generation d'une marque 'rang' de table Proto : method tblRow(a1=Rexx, a2=Rexx null, a3=Rexx null, a4=Rexx null, a5=Rexx null, a6=Rexx null, a7=Rexx null, a8=Rexx null) static returns Rexx img - generation d'une marque 'image' Proto : method img(i=Rexx, a=Rexx null, o=Rexx null) returns Rexx static href - generation d'une marque 'lien hyper texte' Proto : method href(newu=Rexx, z=Rexx) returns Rexx static frmHdr - generation d'une marque 'form' Proto : method frmhdr(action=Rexx, meth=Rexx null) returns Rexx static frmInp - generation d'une marque d'element en saisie dans une forme Proto : method frmInp(typ=Rexx, name=Rexx, val=Rexx, ...) -- depending on typ -- see frmInp in the classic rexx package whichOs - determination de l'Operating System Proto : method whichOs static returns Rexx --------------------------------------------------------------------------- C - Methodes de la classe Rxqueue Protos: method queued() returns Rexx method push(z= Rexx) method queue(z=Rexx) signals IOException method pull() returns Rexx Exemple : q = Rxqueue() q.queue("ligne1") q.queue("ligne2") q.push("ligne3") n = q.queued() say "2 queue, 1 push ->" n "in Q." loop for n say q.pull end n = q.queued() say "now ->" n "in Q."