JED Macro: jedasp.sl

## jedasp.sl

tries to simulate Active Server Pages (MS IIS). The function asp_run_scripts searches for SLang code declared between arbitrary tags and executes it. It allways searches from the beginning of the buffer for the first occurence of tagged code and executes it.

### Scripts

The script is defined with arbitrary BEGIN and END tag, they are both passed to the asp_run_scripts function:

      asp_run_scripts ("<%", "%>")

The scripts are executed while there are any in the file.

If you need to insert raw text into the buffer within the script, use the %T comment. You can use SLang escape sequences in raw text. To insert the value of some SLang variable into raw text, you can do it using the `(%F, X%)` format, where F is the format, X is an arbitrary expression whose result has a valid type for F. The expression X may not contain string constants.

### Example

The file that we want to process:

        HTML table <BR>
        <%
           % SLang comment inside script
           %T <TABLE BORDER="2"> \n
           variable i;
           for (i = 0; i < 3; i++) {
              %T <TR>
              %T <TD> (%d, i %) * (%d, i %) </TD><TD> (%05d, i*i %) </TD>
              if (i mod 2 == 0) {
                 %T <TD> (%d, i%) mod 2 is "0" </TD>
              }
              else {
                 %T <TD> (%d, i%) mod 2 is "not 0" </TD>
              }
              %T </TR> \n
           }
           %T </TABLE>
        %>

When we call asp_run_scripts ("<%", "%>"), the file is transformed into:

        HTML table <BR>
        <TABLE BORDER="2">
     <TR><TD> 0 * 0 </TD><TD> 00000 </TD><TD> 0 mod 2 is "0" </TD></TR>
     <TR><TD> 1 * 1 </TD><TD> 00001 </TD><TD> 1 mod 2 is "not 0" </TD></TR>
     <TR><TD> 2 * 2 </TD><TD> 00004 </TD><TD> 2 mod 2 is "0" </TD></TR>
     </TABLE>

and the final result looks like this:

> HTML table

> 0 * 0 | 00000 | 0 mod 2 is "0"
> 1 * 1 | 00001 | 1 mod 2 is "not 0"
> 2 * 2 | 00004 | 2 mod 2 is "0"