![]()
![]()
![]()
HHNS Common REXX Interface Package
(updated Oct. 27 2000)
The Common Rexx Interface package offers a set of functions of general interest and CMS emulation.
It is contained in a Shared Library, whose name depends upon the various platforms :
Operating System Interpretor Shared Library resides in AIX Object Rexx liborxcri.so /usr/lib (*) Regina librxcri.a /usr/lib (*) LINUX Object Rexx liborxcri.so /usr/lib (*) Regina librxcri.so /usr/lib (*) Win32 Object Rexx ORXCRI.DLL (Path) Regina RXCRI.DLL (Path) (*) Or in any other directory in the environment variable LIBPATH (AIX) or LD_LIBRARY_PATH (LINUX, AIX)
It is automatically loaded by the REXX SETDLL procedure, which does the necessary 'Function Register'
That procedure is called by :call setdllwith the optional parameters "cms", "rxd", "com" if one wants to use the VM/CMS, RexxDate, or communication functions.The following tables give the available functions.
Main module : general interest and CGI web functions
(call Setdll)
ENTRY Categ. ARGS RETURNS Description delay - sss.msec - passive wait inkey - Wait/Nowait kbd input, one char keyboard scan getkwd - kwd, string value keyword parmaeter getenv - varname value system environment getpid - - process_id process id getwparm - kwd,hive,file value parm. value from '.ini' filesize - fileid size gives a file's size parsefid - fileid path fn.ft parse a file-id popen - commande stack stacks command results CgiInit WEB [HDR=NO/TITLE=..] - CGI environment CgiSetup WEB - - CGI environment CGI CgiEnd WEB - - CGI end CgiWebit WEB normal string web string deals with accents ... TblHdr WEB hdr1,hdr2,... string generate a table Header TblRow WEB col1,col2,... string generate table Row FrmHdr WEB prog <form ...> begins a form FrmInp WEB type,name,val,... <input...> input in a form CgiImg WEB img, alt <IMG src...> IMG tag CgiHref WEB link, text <A href=link>texte</A> HTTP link r4Sh WEB Shell statement Shell string unescape a Shell cmd CgiRefr WEB next URL <meta ...> returns immed to ... GetCookie WEB cookie name value value of a cookie var. Tags WEB generic tags pair <any_tag...>...</tag> a quick pair of tags ... atan math x atan(x) - atan2 math a,b atan2(y,x) - cos math x cos(x) - sqrt math x sqrt(x) - exp math x exp(x) - fact math x fact(x) - log math x log(x) - pow math r1,r2 r1**r2 - sin math x sin(x) - CMS module : some VM/CMS functions emulation
(call Setdll "cms")
ENTRY ARGS RETURNS Description stm2file stem, fileid - stem to file stm2var stem, varname - stem to var file2stm stem, fileid - file to stem var2stm stem, varname - variable to stem makefid fname ftype fpath fpath\fname.ftype use VM/CMS fn ft fm Rexxdate module : VM/CMS REXXDATE package emulation
(call Setdll "rxd")
ENTRY ARGS RETURNS Description d2date JDN , format date, specified form RexxDate date2d date, format JDN (Julian Day Number) RexxDate Modure rxcom : future extension.
(call Setdll "com")
ENTRY ARGS RETURNS fonctionnalités ttyver " " " transpac " " " ttyclose " " " ttycnt " " " ttyget " " " ttygetc " " " ttygete " " " ttyopen " " " ttypull " " " ttyput " " " ttystat " " " ttywcnx " " " ttywstr " " " nwkver " " " nwkclose " " " nwkcnt " " " nwkgetc " " " nwkopen " " " nwkmake " " " nwkpull " " " nwkput " " " nwkstat " " " nwkwait " " " Module rxgex : future extension.
(call Setdll "gex")
ENTRY ARGS RETURNS fonctionnalités RXSETGEX - - initialisation gex map_name, IOS3270_options Attention Id saisie full-screen
ATAN Math syntax : r = atan(a) args : real returns: radians
(Top) ATAN2 Math syntax : r = atan2(y,x) args : real returns: radians
(Top) CGIEND termine une cgi syntax : call cgiEnd args : - returns: - note : just "</body></html>" + empty line
(Top) CGIHREF generate an Hyper-Text link syntax : say cgiHref(URL, text) args : URL, text to click returns: a full <A ...>... </A> tag example: say cgiHref("www.hhns.fr", "A small trip to HHNS")
(Top) CGIIMG generate a <IMG> tag syntax : say cgiImg(image [, alt] [, alignment]) args : Image URI, alt text, Right/Left/Middle ... returns: a full IMG tag example: say cgiImg("www.hhns.fr/imglib/sigles/rexx.gif", "Rexx")
(Top) CGIINIT Initialization of a CGI: setup Rexx variables and generate a CGI header syntax : call cgiInit "HDR=NO" ou 'TITLE="..." BGCOLOR="..." JAVASRC="script_file"' args : "HDR=NO" if you don't wanr the CGI header returns: none example: call cgiInitf "TITLE=test BGCOLOR=FFFFFF"
(Top) CGIREFR generate a 'GOTO immed' to another URL syntax : say cgiRefr(URL); exit 0 args : the other URL returns: the 'GOTO' HTML page. example: say cgiRefr("www.hhns.fr")
(Top) CGISETUP Initialization of a CGI: setup REXX variables only syntax : call cgiSetup args : none returns: none note: 'call CgiSetup' == 'call CgiInit "HDR=NO"'
(Top) CGIWEBIT process non alphanum chars in a string syntax : say cgiWebit(string) args : a string returns: the same string, with 'Webization' of non alphanum charrs. example: say cgiWebit("a statement with a lot of accents and spec. chars...")
(Top) COS Math syntax : a = cos(b) args : radians returns: real
(Top) D2DATE Compute a date from a JDN syntax : say D2Date(Jdn, format) args : JDN (as for Jan 1st 1601), date format returns: date example: d2date(145731, "V") /* gives 'Jan 1, 2000' */
(Top) DATE2D Compute a JDN (Julian Day Number) from a date syntax : n = date2d(date, format) args : format ('A', 'E', 'U', 'O', 'S', 'V), date at that format returns: Jdn as for Jan 1st 1601 formats : 'A' : dd Mon yyyy (format par defaut) 'E' : dd/mm/yy 'U' : mm/dd/yy 'O' : yy/mm/dd 'S' : yyyymmdd 'V' : Mon dd, yyyy example: date2d("31/12/99, "E") /* gives 145730' */
(Top) DELAY passive wait in seconds and ms. syntax : call delay duration args : duration = seconds.millisec examples : call delay 3 ( 3 sec.) call delay 2.5 ( 2 sec. and half) call delay 0.01 ( 10 millisec.) returns: none
(Top) EXP Math syntax : a = exp(b) args : reals returns: exponent ( 'e' constant raised to the power b)
(Top) FACT Math syntax : r = fact(n) args : integer returns: factorial (real)
(Top) FILE2STM File to Stem syntax : call file2stm 'stem.', 'fileid' args : full filename returns: nbre d'objets dans le stem (stem.0) example: call file2stm "thost.", "/etc/hosts"
(Top) GETWPARM extract a parameter from a '.ini'-like file syntax : v = getwparm(parm, hive, fileid) args : parm name, 'hive' name [xxxxx], paramater file id returns: value of parm, or empty example: (have a look on your 'Win.ini' file) n = getwparm("COM1:", "PORTS", "C:\Windows")
(Top) FILESIZE File size syntax : n = filesize(fileid) args : full filename returns: size in bytes example: n = filesize("\winnt\MyModem.txt")
(Top) FRMHDR generate a <FORM ACTION=... tag syntax : say frmHdr(action) args : action = URL wich will process the form's data returns: a full FORM tag example: say frmHdr("/cgi-bin/appli/prg1") ... say frmInp(...) ... See also example Input form
(Top) FRMINP generate an INPUT tag within a form syntax : say frmInp(type, varname, value, ...) args : depending on type : frmInp('T', varname, value, maxlen, size) <- Text field frmInp('A', varname, value, nlines, ncol) <- Text Area frmInp('P', varname, value, maxlen, size) <- Password frminp('F', varname, value, maxlen) <- File frminp('H', varname, value) <- Hidden frminp('S', varname, value) <- Submit frminp('R', varname, value) <- Reset frminp('I', varname, src) <- Image frminp('B', varname, value, 1/0) <- radioButton frminp('C', varname, value, 1/0) <- checkBox frminp('L', varname, size, opt1,opt2...) <- lstBox returns: a full <INPUT> tag example: say frmHdr("/cgi-bin/prg2") say "<br>Your name :" FrmInp('T', "name", "", 30, 30) say "<br>your code :" FrmInp('P', "pwd", "", 8 , 8 ) say "<br>Country :" FrmInp('L', "cntry", 1, "Uk", "Ge", "Sp", "It") say "<br>Color :" FrmInp('B', "colr", "Blanc", 0) say FrmInp('B', "colr", "gren" , 0) say FrmInp('B', "colr", "Blue" , 1) say FrmInp('B', "colr", "blak" , 0) say "<br>Options :" FrmInp('C', "v1" , "xxx1" , 1) say FrmInp('C', "v2" , "xxx2" , 0) say FrmInp('C', "v3" , "xxx3" , 1) say "<center>" FrmInp('S', "vok", "Send") FrmInp("R", "void", "Clear") say FrmInp('H', "vcntx", "value transmitted in the vcntx REXX variable") say "</center></form>" See also example of Input form
(Top) GETENV environment value syntax : v = getenv(variable) args : variable name returns: value, or empty example: if getenv("LIBPATH") = "" then ...
(Top) GETCOOKIE extract a value from the current cookie ('HTTP_COOKIE') syntax : v = getcookie(variable) args : variable name returns: value, or empty example: if getcookie("NAME") = "" then ... Note: This works only when the system environment "HTTP_COOKIE" is setup by the Web server before calling your CGI program.
(Top) GETKWD Parse a keyword parameter list syntax : v = getkwd(kwd, string) args : desired keyword, parameter string returns: value, or empty example: w = "A=3 B=(r, 2) C='some texte' PARM=(1, no_entry, 19)" ... a = getkwd("A", w) /* gives : 3 */ b = getkwd("B", w) /* gives : r, 2 */ c = getkwd("C", w) /* gives : un texte */ d = getkwd("PARM", w) /* gives : 1, no_entry, 19 */
(Top) GETPID current process id syntax : v = getpid() args : none returns: process_id example: tempfile = "AAAA"right(d2x(getpid()), 4, 0)
(Top) INKEY blocking/non blocking keyboard scan syntax : c = inkey(["Nowait"]) args : "N" ou Nowait [optional] returns: byte read, or empty examples: a = inkey() /* blocked until some key hit */ do forever b = inkey('N') /* non blocking */ if b <> "" then leave /* there is key */ call delay 0.3 /* else keyboard buffer empty */ end
(Top) LOG Math syntax : a = log(b) args : real returns: real (natural logarithm)
(Top) MAKEFID convert a CMS 'fn ft fm' into a WIN/DOS/UNIX name syntax : fileid = makefid(fn ft fm) args : fn ft fm (fm = path) returns: a alid WIN/DOS/UNIX* name examples: a = makefid(fn ft 'c:\tmp') --> c:\tmp\fn.ft (win32) a = makefid(fn ft '/tmp') --> /tmp/fn.ft (Unix)
(Top) PARSEFID parse a Win/Dos/Unix filename syntax : parse value parsefid(fileid) with path fn '.' ft args : a system valid filename returns: path fn.ft (2 words) examples: f = "/usr/local/bin/myfile.ext" ... parse value parsefid(f) with fm fnt /* gives fm = '/usr/local/bin', et fnt = 'myfile.ext' */ f = "myfile2.exb" ... parse value parsefid(f) with fm fn '.' ft /* gives fm = './', fn = 'myfile2' et ft = 'exb' */
(Top) POPEN (Compatibility REGINA - Object REXX) syntax : n = popen("Operating system command") args : expression representing any OS valid command returns : retcode of the command
(Top) POW Math syntax : a = pow(b, c) args : 2 reals returns : real
(Top) R4Sh Unescape a Web Sring syntax : s2 = r4sh(s1) args : A Web string for a CGI program returns : string example : if at entry of a CGI, s1 = 'myprog.cgi \(2\*cos\(ph\)\)', r4sh(s1) will give : 'myprog.cgi (2*cos(ph))'
(Top) TAGS Generate a pair of tags syntax : say tags(Html_tag, string1, string2) args : An Html tag, an optionnal string to put in the leading tag, an optionnal string to put between the leading and trailing tags. returns : string examples: tags('h4',, 'This is a header') : '<h4>This is a Header</h4>' tags('Span', 'class=xyz', 'aaaa') : '<Span class=xyz>aaaa</Span>'
(Top) SIN Math syntax : a = sin(b) args : radians returns: real
(Top) SQRT Math syntax : a = sqrt(b) args : real returns: real
(Top) STM2FILE Stem to File (see CMS) syntax : call Stm2file "stem.", fileid args : stem name, FIle name (Append) returns: number of written lines (= stem.0)
(Top) STM2VAR Stem to REXX Variable (see CMS) syntax : call stm2var "stem", "varname" args : stem name, var name returns: nbre of objects in the variable ( = stem.0)
(Top) TBLHDR generate a table header syntax : say tblhdr("title_1", title_2', ..., title_n") args : titles of the table columns returns: a full HTML '<tr><th align=left> ...' tag example: say TblHdr("Reference", "Name", "Quantity", "Price") See also Input form
(Top) TBLROW generate a table row syntax : say tblrow(e1, e2, ..., en) args : expressions that will comme in the row, one arg per column returns: a full HTML '<tr><td align=...> ...' tag notes : alignment depending upon each column content : numeric (real, interger) : align=right else if 1st char is blank: align=middle else align=left example: say TblRow(Refer, " "libel, qty, pr, format(pr*qty, 7, 2)) See also Input form Q : Can the tables be nested ? A : Yes Ma'am, but the crew's nerves will always crack before the boat!
(Top) VAR2STM Rexx Variable to Stem syntax : call var2stm "stem.", "varname" args : stem name, var name returns: number of objects (# of words in the variable, = stem.0)
(Top) An example : building an Input Table/Form (you may cut and paste it) /* Sample Input Form s */ /* Regina - ObjRexx - all platforms */ call setdll call cgiInit "BGCOLOR=FFFFFF" say FrmHdr('/cgi-bin/my_appli_dir/my_cgi_prog?my_arg1+my_arg2') say '<center>' say '<h4>Input Form</h4>' say '(* : mandatory)' say '<p>' say '<table>' say TblRow('*', "Your last name :" , frminp('T', nom, "", 30, 30) ) say TblRow(' ', "Your first name:" , frminp('T', pre, "", 30, 30) ) say TblRow('*', "Password :" , frminp('P', pwd, "", 10, 10) ) say TblRow(' ', "Tel. Number :" , frminp('T', tel, "", 4 , 4 ) ) say TblRow('*', 'Division:',, frminp('L', "ser", 3,, /* --- REXX syntax : --- */ "Admin", "Client",, /* the double comma is for : "Dev", "Esc",, /* a) indicate next paramater */ "Production",, /* b) indicate contination on next line */ "Network", "System") ) say TblRow('*', 'Using ABCD :',, frminp('B', "abc", "N", 0)"Never. ", /* final comma = continuation, */ frminp('B', "abc", "P", 1)"Always.", /* not 'next param' */ frminp('B', "abc", "S", 0)"Often." ) say TblRow(' ', '' , frminp('C', "c1", "y", 0)"Options-1") say TblRow(' ', 'Options :' , frminp('C', "c2", "y", 0)"Options-2") say TblRow(' ', '' , frminp('C', "c3", "y", 0)"Options-3") /* space as first char of a column = center that column */ say TblRow(' ', " "FrmInp("S", "Bok", "Ok"), " "FrmInp("R", "reset", "reset")) say '</table> </form> </center>' call cgiEnd

English
