Special tags for template files

These special tags in a .sch, .scj or .scx file are recognised and processed by nph-srep.


Sculptor template files

The files with extension *.sch, *.scj or *.scx are Sculptor template files which may contain any of the special tags defined below.

These type of file must be processed by nph-srep, which in combination with a specified SCPROG will replace the tags with the tag “excuted” content and produce a dynamic result.

Depending on the file extension the default output content type changes:

Extension

Content type

Use

sch

text/html

Generate normal HTML file

scj

application/json

Generate JSON content file (normally a REST service response)

scx

application/xml

Generate XML content file (normally a REST service response)

Note: scj and scx extensions supported since Sculptor version 6.1.0.


<SCPROG>

<SCPROG [NAME=progname.q]>

[<PARAM NAME=parameter_name VALUE = parameter_value>

…]

</SCPROG>

The <SCPROG> tag defines the .q file to be loaded by nph-srep, and any optional parameters. This tag can be used if the required .q file is not specified by an SCPROG parameter in the URL that calls nph-srep. See Special variables. The optional parameters will be read by the program just like any other web parameter.

The variables SCPROG and SCHPAGE should not be defined if the <SCPROG> tag is used.


<SCRUNREPORT>


<SCRUNREPORT NAME=report_id [OUTFILE = filename] [PPF = printer]

The <SCRUNREPORT> tag tells nph-srep to include the output from the specified report in the web page at that point. The named report must be a !report section in the .q program that has been loaded. This program may have been specified in the URL or parameter that called nph-srep , or by the <SCPROG> tag described above. Any number of reports can be run in a single .sch file.


<SCFIELD>


<SCFIELD NAME = field_name[[subscript]]>

The <SCFIELD> tag places the current value of the specified field into the HTML. The subscript, if present, can be a constant or a Sculptor field name. If it is not an integer it is assumed to be a field name, and the current value of the field is used as the subscript.

Note: Since Sculptor version 6.2.0 the nested record and record array features are supported, e.g:

<SCFIELD NAME=Record[1].SubRec[2].Cell1[tmp.Index]>

<SCFOR>


<SCFOR INDEX=index_field FROM=integer | start_field TO=integer | end_field>

 HTML statements

</SCFOR>

Repeat HTML statements, incrementing the index field.

index_field, start_field and end_field are all fields in the Sculptor program. They may be subscripted.

Sculptor repeats the block of HTML statements, incrementing index_field from the start value to the end value in steps of 1. The steps may be upward or downward, because the FROM value can be bigger than the TO value. Both FROM and TO have the default value 1.

If a function call (defined by the <SCFUNCTION> tag) in the HTML statements returns the value ERROR, the loop is broken and control passes to the line following </SCFOR>.

EXAMPLE

This example demonstrates the use of <SCFOR> to output the rows of a table:

<TABLE>
  <SCFOR INDEX=tmp.index FROM=1 TO=tmp.NumRows>
    <TR>
      <TD>
       <SCFIELD NAME=tmp.Cell1[tmp.Index]>
      </TD>
      <TD>
       <SCFIELD NAME=tmp.Cell2[tmp.Index]>
      </TD>
    </TR>
  </SCFOR>
</TABLE>

<SCREPEAT>


<SCREPEAT [INDEX=index_field]>

 HTML statements

</SCREPEAT>

Repeat HTML statements until a function call returns ERROR.

If an index_field is specified, Sculptor sets it to the number of the current iteration, with the first iteration counting as 1.

There should be at least one <SCFUNCTION> tag in the HTML statements. A function return value of ERROR causes the loop to terminate, with control passing to the line following </SCREPEAT>.


<SCFUNCTION>


<SCFUNCTION NAME=function_name [PARAM=param_text1 PARAM=param_text2 …]>

Since Sculptor version 6.2.0 the maximum number of PARAM’s has been increased from 1 to 32.

The <SCFUNCTION> tag calls the specified function in the Sculptor program. The function can be used to set up field values and to control a repeat or for loop. The param_text* are the function arguments. Can be omited if not used.

The function should return OKAY or ERROR. A return value of ERROR causes Sculptor to break out of the innermost <SCFOR> or <SCREPEAT> loop if one exists. This makes it easy to create a loop that outputs values from a file.

EXAMPLE

<TABLE>
  <SCREPEAT>
    <SCFUNCTION NAME=GetNextCellValues PARAM=name_order>
    <TR>
      <TD>
       <SCFIELD NAME=STOCK.Code>
      </TD>
      <TD>
       <SCFIELD NAME=STOCK.Name>
      </TD>
      <TD>
       <SCFIELD NAME=STOCK.Price>
      </TD>
    </TR>
  </SCREPEAT>
</TABLE>

<SCIF>


<SCIF NAME=test_field [CONSTANT=constant | FIELD=value_field]>

 HTML statements

[<SCELSE>

 HTML statements]

</SCIF>

Generate a block of HTML statements conditionally. Sculptor outputs the HTML statements only if the field test_field has the specified value, which may be provided in the form of a constant or of a field. If neither a constant nor a field is specified to provide the value, the test field is checked against a null string (alphanumeric fields) or 0 (numeric fields).

The optional <SCELSE> tag defines a block of statements to be executed if the <SCIF> test proves false.


RELATED TOPICS

Creating web pages with Sculptor