Thanks, Scott... this is CGIDEV2 specific that I'm looking
for, but this is a good resource for others that may be
looking to do it on their own.

Brad


On Thu, 2 Dec 2004 16:03:17 -0600 (CST)
 web400@xxxxxxxxxxxxxxxx wrote:
> Hello,
> 
> > How would I go about replacing the < with &lt; if that
> file
> > was loaded as a template before writing the template to
> the
> > web page?
> 
> First, let me disclaim:  I know absolutely nothing about
> CGIDEV2. I'm only
> familiar with "normal" CGI programming (i.e. without a
> toolkit)  Some day
> I'm going to learn CGIDEV2 (someday, someday...)
> 
> However, what I do is use the following subprocedure to
> convert the
> special characters into HTML-friendly variants:
> 
>
      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>       * FixChar():  This trims trailing blanks from a
> source record,
>       *             adds a newline and converts
>       *                  & to &amp;
>       *                  < to &lt;
>       *                  > to &gt;
>
      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>      P FixChars        B
>      D FixChars        PI
>      D   SrcDta                    1024A   const varying
> options(*varsize)
>      D   Output                    4096A   varying
>      D   html_format                  1N   const
>      D   HeavyTags                    1N   const
> 
>      D Len             s             10I 0
>      D x               s             10I 0
>      D Char            s              1A
> 
>       /free
>         Len = %len(%trimr(SrcDta));
>         %len(Output) = 0;
> 
>         for x = 1 to Len;
> 
>            Char = %subst(SrcDta: x: 1);
> 
>               if (html_format);
>                  if (Char = '<');
>                     Output += '&lt;';
>                  elseif (Char = '>');
>                     Output += '&gt;';
>                  elseif (Char = '&');
>                     Output += '&amp;';
>                  else;
>                     Output += Char;
>                  endif;
>               else;
>                  Output += Char;
>               endif;
> 
>         endfor;
> 
>         if (html_format and HeavyTags);
>           Output += '<br>';
>         endif;
> 
>         Output += x'0d25';
> 
>       /end-free
>      P                 E
> 
> I imagine that if you created a CGIDEV2 thinngy, you
> wouldn't need to add
> the <BR> or whatever to the end of the data.  You'd want
> your template to
> use <PRE> and </PRE> most likely instead.
> 
> Then, of course, I'd read the file in my RPG program and
> run line of input
> through the above subprocedure... then write it out to
> stdout (or in your
> case, to the CGIDEV2 template.)
> 
> _______________________________________________
> This is the Web Enabling the AS400 / iSeries (WEB400)
> mailing list
> To post a message email: WEB400@xxxxxxxxxxxx
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/mailman/listinfo/web400
> or email: WEB400-request@xxxxxxxxxxxx
> Before posting, please take a moment to review the
> archives
> at http://archive.midrange.com/web400.
> 

Bradley V. Stone
BVS.Tools
www.bvstools.com

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.