*=====================================================================
* RPG ILE MODULE CGIDEV2/ESCUNESC
*
* CRTBNDRPG CGIDEV2/ESCUNESC DFTACTGRP(*NO) ACTGRP(*NEW) DBGVIEW(*SOURCE)
*
*=====================================================================
/copy CGIDEV2/qrpglesrc,hspecs
/copy CGIDEV2/qrpglesrc,hspecsbnd
/copy CGIDEV2/qrpglesrc,prototypeb
/copy CGIDEV2/qrpglesrc,variables3
/copy CGIDEV2/qrpglesrc,usec
*=====================================================================
* Input variables from the browser
D xrequest s 20
D tobeescaped s 5000 varying
D tobeunescaped s 5000 varying
D xoptions1 s 10 varying
D xoptions2 s 10 varying
*
D trimRightInd s n
D CRLF s 2 inz(x'0D25')
*
D extHtml s 2000 inz('/cgidev/html/escunesc.txt')
* Indicators for GetHtmlIfsMult subprocedure
D IfsMultIndicators...
d ds
D NoErrors n
D NameTooLong n
D NotAccessible n
D NoFilesUsable n
D DupSections n
D FileIsEmpty n
*
*=====================================================================
/free
// Load external html
IfsMultIndicators=getHtmlIfsMult(%trim(exthtml):'«as400»');
// Receive and parse input input variables from the browser
nbrVars=zhbgetinput(savedquerystring:qusec);
xrequest=zhbgetvarUpper('xrequest');
tobeescaped=zhbgetvar('tobeescaped');
tobeunescaped=zhbgetvar('tobeunescaped');
xoptions1=zhbgetvar('xoptions1');
xoptions2=zhbgetvar('xoptions2');
// replica some input variables
if xoptions1='1';
updhtmlvar('checked1':'checked');
else;
updhtmlvar('checked1':' ');
endif;
if xoptions2='1';
updhtmlvar('checked2':'checked');
else;
updhtmlvar('checked2':' ');
endif;
// Select process
select;
when xrequest='ESCAPE';
exsr DoEscape;
when xrequest='UNESCAPE';
exsr DoUnescape;
other;
exsr Start;
endsl;
// Provide HTML output
wrtsection('top *fini');
// Back to caller
return;
/end-free
*=====================================================================
* Start
*=====================================================================
/free
Begsr Start;
updhtmlvar('tobeescaped':' ');
updhtmlvar('tobeunescaped':' ');
Endsr;
/end-free
*=====================================================================
* Escape string "tobeescaped" into string "tobeunescaped"
*=====================================================================
/free
Begsr DoEscape;
trimRightInd=*on;
tobeunescaped=UrlEscSeq(tobeescaped:trimRightInd:xoptions1);
updhtmlvar('tobeescaped':tobeescaped);
updhtmlvar('tobeunescaped':tobeunescaped);
Endsr;
/end-free
*=====================================================================
* Unescape string "tobeunescaped" into string "tobeescaped"
*=====================================================================
/free
Begsr DoUnEscape;
tobeescaped=UrlUnescSeq(tobeunescaped:xoptions2);
updhtmlvar('tobeescaped':tobeescaped);
updhtmlvar('tobeunescaped':tobeunescaped);
Endsr;
/end-free
|