3 Replies Latest reply: Feb 16, 2015 8:46 AM by Martyn Lloyd RSS

    Use script to write HTML

    Martyn Lloyd

      Hi everyone,

      I'm trying to produce an html snippet, using just scripting.  I am unable to use macros in this context.

      So close, but not there; the output looks like this:

       

      <HTML>,HTML
      <head>,
      <style>,
      body {background-color:lightgrey},
      h1   {color:blue},
      p    {color:green},
      </style>,
      </head>,
      <body>,
      ,2536
      </body>,

       

      How can I resolve the fact that I have two fields - the editor will not accept <HTML> as a field name...

       

      here is the script

       

      OrderMassTotal:
      LOAD 
           KPIYear,
          
      Sum(Volume) as [TotalRetailOrders]
      Resident KPIFACTS
      Where KPIID='S12' and KPIYear=2015
      Group By KPIYear;

      OrderHeadline:
      Load * Inline [
      <HTML>
      <head>
      <style>
        body {background-color:lightgrey}
        h1   {color:blue}
        p    {color:green}
      </style>
      </head>
      <body>
      ]
      ;

      Concatenate
      Load
      Peek(TotalRetailOrders, -1, 'OrderMassTotal') as HTML
      AutoGenerate(1)
      ;

      Concatenate
      Load * Inline [
      <HTML>
      </body>
      ]
      ;

      STORE OrderHeadline into [$(vQVDPath)\KPIOrderRetailHeadline.html] (txt);

       

      Best regards,

      Marty.

        • Re: Use script to write HTML
          Marcus Sommer

          Maybe this is helpful for you:

           

          OrderHeadline:

          Load *, rowno() as RowNo Inline [

          HTML-Code

          <HTML>

          <head>

          <style>

            body {background-color:lightgrey}

            h1   {color:blue}

            p    {color:green}

          </style>

          </head>

          <body>

          ];

           

          HTML:

          NoConcatenate Load

              concat([HTML-Code], chr(10), RowNo) as [HTML-Code]

          Resident OrderHeadline;

           

          drop tables OrderHeadline;

           

          - Marcus

          • Re: Use script to write HTML
            Jonathan Dienst

            Hi

             

            You were nearly there. Just change this line:

            Peek(TotalRetailOrders, -1, 'OrderMassTotal') as HTML

             

            It should read:

            Peek('TotalRetailOrders', -1, 'OrderMassTotal') as [<HTML>]

             

            Then it should work - it did when I tested it. This is what the output file contained (you will have a different value from the 500 below):

             

            <HTML>

            <head>

            <style>

            body {background-color:lightgrey}

            h1   {color:blue}

            p    {color:green}

            </style>

            </head>

            <body>

            500

            </body>

             

            HTH

            Jonathan