|
Code Example 24 - Generating HTML
|
Generate a set of homogeneous buttons for an HTML form.
Lines 6-9 show an example of variable number of arguments
provided to a Tefigel subroutine.
|
|
Source code - File "language/html/formbuttons"
|
1 #
2 # HTML document browsing buttons
3 #
4 <table cellpadding=0 cellspacing=0>
5 <tr>
6 @ language/html/formbutton(First)
7 @ language/html/formbutton(Prev,Prev.)
8 @ language/html/formbutton(Next)
9 @ language/html/formbutton(Last)
10 </tr>
11 </table>
|
|
Output of
"/opt/somusar/bin/tefigel language/html/formbuttons"
|
1 <table cellpadding=0 cellspacing=0>
2 <tr>
3 <td>
4 <input type="BUTTON" width=60 name="First" value="First">
5 </td>
6 <td>
7 <input type="BUTTON" width=60 name="Prev" value="Prev.">
8 </td>
9 <td>
10 <input type="BUTTON" width=60 name="Next" value="Next">
11 </td>
12 <td>
13 <input type="BUTTON" width=60 name="Last" value="Last">
14 </td>
15 </tr>
16 </table>
|
|
HTML subroutine - File "language/html/formbutton"
|
1 #
2 # HTML form button
3 #
4 @ interface(NAME,label)
5 @ if label=
6 @ set label=NAME
7 @ endif
8 @ set WIDTH=60
9 <td>
10 <input type="BUTTON" width=WIDTH name="NAME" value="label">
11 </td>
|
|
|
Source code - File "language/xml.in"
|
1 @ dash $
2 @ language/xml(Tag1=Value1,Tag2=Value2)
3
4 @ linebreak \
5 @ language/xml(\
6 TagA=ValueA,\
7 TagB=ValueB,\
8 TagC=ValueC,\
9 TagD=ValueD)
10
|
|
Output of
"/opt/somusar/bin/tefigel language/xml.in"
|
1 <Tag1>
2 Value1
3 <Tag2>
4 Value2
5 </Tag2>
6 </Tag1>
7
8 <TagA>
9 ValueA
10 <TagB>
11 ValueB
12 <TagC>
13 ValueC
14 <TagD>
15 ValueD
16 </TagD>
17 </TagC>
18 </TagB>
19 </TagA>
20
|
|
XML subroutine - File "language/xml"
|
1 @ set I=0
2 @ set INDENT=
3 @ set BLANKS=
4 #
5 # Scan list of arguments, printing
6 # out indented open tag clause and value
7 #
8 @ while I<REG_COUNT
9 @ set ITEM=REG_$I
10 @ set TAG$I=~field(ITEM,0,=)
11 @ set VAL$I=~field(ITEM,1,=)
12 @ set IND$I=INDENT
13 INDENT<~value(TAG$I)>
14 INDENT$BLANKS~value(VAL$I)
15 @ set INDENT=~value(IND$I)BLANKS
16 @ add I 1
17 @ endwhile
18 #
19 # Scan list of arguments backward, printing
20 # out indented close tag clause
21 #
22 @ while I>0
23 @ sub I 1
24 ~value(IND$I)</~value(TAG$I)>
25 @ endwhile
|
|
|
Source code - File "language/soap"
|
1 ---- Simple SOAP Request ----
2 @ language/soap_code(GetLastTradePrice,symbol/DIS)
3 ---- Simple SOAP Response ----
4 @ language/soap_code(GetLastTradePriceResponse,Price/34.5)
|
|
Output of
"/opt/somusar/bin/tefigel language/soap"
|
1 ---- Simple SOAP Request ----
2 <SOAP-ENV:Envelope
3 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
4 SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
5 <SOAP-ENV:Body>
6 <m:GetLastTradePrice xmlns:m="Some-URI">
7 <symbol>DIS</symbol>
8 </m:GetLastTradePrice>
9 </SOAP-ENV:Body>
10 </SOAP-ENV:Envelope>
11 ---- Simple SOAP Response ----
12 <SOAP-ENV:Envelope
13 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
14 SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
15 <SOAP-ENV:Body>
16 <m:GetLastTradePriceResponse xmlns:m="Some-URI">
17 <Price>34.5</Price>
18 </m:GetLastTradePriceResponse>
19 </SOAP-ENV:Body>
20 </SOAP-ENV:Envelope>
|
|
SOAP request/response fragment - File "language/soap_code"
|
1 #
2 # REQUEST_RESPONSE_ID contains id of request or response
3 #
4 @ interface(REQUEST_RESPONSE_ID,PARAM_INFO)
5 #
6 # PARAM_INFO contains tag/id of parameter #1 - note "/" used as a separator
7 #
8 @ set PARAM_TAG_1=~field(PARAM_INFO,0,/)
9 @ set PARAM_ID_1=~field(PARAM_INFO,1,/)
10 <SOAP-ENV:Envelope
11 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
12 SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
13 <SOAP-ENV:Body>
14 <m:REQUEST_RESPONSE_ID xmlns:m="Some-URI">
15 <PARAM_TAG_1>PARAM_ID_1</PARAM_TAG_1>
16 </m:REQUEST_RESPONSE_ID>
17 </SOAP-ENV:Body>
18 </SOAP-ENV:Envelope>
|
|
|
Source code - File "language/php"
|
1 @ set TITLEHEADER=<h4>
2 @ set TITLE=Generated PHP fragment
3 <?php
4 // Small fragment of PHP, printing out some HTML
5 print "TITLEHEADER\n";
6 print "TITLE\n";
7 ?>
|
|
Output of
"/opt/somusar/bin/tefigel language/php"
|
1 <?php
2 // Small fragment of PHP, printing out some HTML
3 print "<h4>\n";
4 print "Generated PHP fragment\n";
5 ?>
|
|
[Previous chapter]
[Next chapter]
[Back to top]
|
|