 |
Click on any item to view...
Contents

|
 |

This lesson introduces you to the tags you use to manage and control the interaction between the request made by a client (either HTML, Cold Fusion or ASP) and the host session. In this lesson, the following skills are introduced:
SurferScript is a very simple language intended to provide a very compact and fast execution environment. To maintain the simplicity and flow of HTML that is intermixed with the SurferScript tag extensions, there are only a few control tags needed to implement any level of logic necessary.
|
Control tags in SurferScript
The following tags provide flow-of-control or are key in implementing flow-of-control in SurferScript:
Tag/Function | Used For |
<TEIF> | Open tag - if TRUE, display/perform following SurferScript |
<TEELIF> | Alternate optional open tag - if <TEIF> or <TEELIF> that preceeds is FALSE, works like <TEIF> |
<TEELSE> | Alternate optional open tag - if all <TEIF> and <TEELIF> tags preceeding are FALSE, display/perform following SurferScript |
</TEIF> | Terminates <TEIF> block |
<TELOOP> | Open a LOOP - iterate through integer as defined, displaying/performing contained SurferScript |
<TEBREAK> | Break out of a <TELOOP> block |
</TELOOP> | Close a loop - continue when loop terminates normally or through the execution of a <TEBREAK> tag |
<TEFIND> | Searches for text on the active screen -- can use TIMEOUT attribute to WAIT for a screen to display |
<TEACTION RETURN> | Stops execution of all SurferScript and returns control immediately to the client |
<TEACTION RELEASE> | Releases client from the active session and by default closes the session - returns control immediately to the client |
Screen(row,col,length) function | Reads text from the active screen session - use in a <TEIF> tag to control flow based on data found on the screen |
Any Variable | Use the value of any variable, including the dynamic web. variables in <TEIF> tags to control flow through your SurferScript |
|
Multiple Screen Transitions
ScreenSurfer provides a number of alternatives in addressing the procedural control of moving from one screen to another. In this section we will cover a simple and very reliable approach that can be used in a variety of circumstances to assure a transition from one screen to the next.
|
The following example demonstrates the entry of a userid and password provided in a user defined transaction in order to logon the user and then advance past a "news" screen to the primary menu. This example will work regardless of the inexact nature of logons, where in many cases there are screens that "flash" on a regular 3270 device, but cause problems in an HTML environment (you see the flashed screen and need to click on the Refresh link in order to restore the correct screen in the browser).
<TESECTION DoConnect
WHEN TranPath_1 is "connect"
AND TranPath_2 is "CICS1">
<!-- The following will use a well-coded
<TECONNECTED tag to assure a session
is ready -->
<TEACTION CONNECT LU_GROUP_1>
<!-- Logon screen should be ready -->
<TEIF Screen(1,20,5) != "Logon">
<TEPUTSECTION LogonError>
<TEACTION RETURN>
</TEIF>
<TEACTION ENTER
web.userid+"[tab]"+web.password+"[enter]"
SKIPSCAN>
<!-- We now use the <TEFIND> tag to
assure the next screen is ready, since
there is a "flash" screen in-between -->
<TEFIND text="News" varRoot=Found
StartRow=1 EndRow=1 TimeOut=10000>
<!--The above will wait up to 10 seconds for
the right screen to display -->
<TEIF Found.offset == -1>
<TEPUTSECTION LogonError>
<TEACTION RETURN>
</TEIF>
<!-- Okay, enter past the news screen -->
<TEACTION ENTER "[enter]" SKIPSCAN>
<TEFIND text="Main Menu" varRoot=Found
StartRow=1 EndRow=1 TimeOut=10000>
<!--All set, let the section that recognizes the
main menu handle presenting to the user, by
performing a TEACTION RETURN WITHSCAN -->
<TEACTION RETURN WITHSCAN>
|
Looping Through Multiple Rows
A common requirement in translating host screens into HTML pages is to make them easier to read, as well as easier to use. Quite often, a user makes a request to see a list which is subsequently presented in multiple rows, many times on multiple screens. In this short section we will present an example of how to convert a screen with multiple rows displayed on multiple screens.
|
<TESECTION ShowRows>
<!-- This section is called by other sections
using the <TEPUTSECTION. It displays order
information which starts on line 4 and ends on
line 21, with 2 lines per order. When there are
more orders on the next screen, the text "MORE"
appears on line 24, column 60. A PF8 key is
used to page down to see more rows. To prevent
excessive searching, a limit of 4 screens is
provided. A blank line on any screen also
indicates the end of the list-->
<TABLE Border>
<TR>
<TH>
Part Number
</TH>
<TH>
Quantity
</TH>
<TH>
Price
</TH>
<TH>
Description
</TH>
</TR>
<TELOOP name=ScreenID First=1 Last=4 Step=1>
<TELOOP name=RowID First=4 Last=20 Step=2>
<TEIF Screen(RowID, 2, 1) == " ">
<TEBREAK>
</TEIF>
<TR>
<TH>
<!-- Each row column 2 is partnum -->
<TEDATA RowID 2 10>
</TH>
<TH>
<!-- Each row column 15 is Qty -->
<TEDATA RowID 15 8>
</TH>
<TH>
<!-- Each row column 40 is Price -->
<TEDATA RowID 40 10>
</TH>
<TH>
<!-- On each second row, column 3 is Desc -->
<TEDATA RowID+1 3 70>
</TH>
</TR>
</TELOOP>
<TEIF Screen(24,60,4) != "MORE">
<TEBREAK>
</TEIF>
</TELOOP>
</TABLE>
</TESECTION>
|
Exercise 7.1
Create a new template named EXERCISE71.STML. Create SurferScript for the "Employee List" screen from the "toy mainframe" to do the following:
- Recognize the "Employee List" screen by the "Employee List" text string
- Loop through a maximum of three pages of employees and display them all on one web page
- Create a button for the PF3 key and create Refresh and Exit links
Click on Solution for Exercise 7.1 for a possible solution
End of Exercise 7.1
Solutions for Exercises
Solution for Exercise 7.1
<TESECTION employee_list
WHEN Screen_1_11 IS "Employee List">
<TEPUTSECTION GLOBAL.HEADER>
<center>
<h3>Employee List Screen</h3>
<br>
<TABLE Border>
<TR>
<TH>
Name
</TH>
<TH>
Department
</TH>
<TH>
Employee Number
</TH>
</TR>
<TELOOP name=ScreenID First=1 Last=3 Step=1>
<TELOOP name=RowID First=5 Last=21 Step=1>
<TEIF Screen(RowID,5,1) == " ">
<TEBREAK>
</TEIF>
<TR>
<TH>
<!-- Each row column 5 is employee name -->
<TEDATA RowID 5 23>
</TH>
<TH>
<!-- Each row column 28 is department -->
<TEDATA RowID 28 25>
</TH>
<TH>
<!-- Each row column 53 is employee number -->
<TEDATA RowID 53 6>
</TH>
</TR>
</TELOOP>
<TEIF Screen(24,72,3) != "PF8">
<TEBREAK>
<TEELSE>
<TEACTION ENTER "[pf8]" skipscan>
</TEIF>
</TELOOP>
<TR><TD>
<FORM name="end"
ACTION="/surfer/end?SessionKey=<TEMACRO SESSIONKEY>&Ticks=<TEMACRO CLOCKTICKS>"
METHOD="POST">
<input type="submit" name="PF3_Key" value="End">
</form>
</TD></TR><TR><TD VALIGN="TOP">
<A HREF="/surfer/refresh/<TEMACRO SESSIONKEY>/<TEMACRO CLOCKTICKS>">Refresh</a>
<A HREF="/surfer/exit/<TEMACRO SESSIONKEY>/<TEMACRO CLOCKTICKS>">Exit</a><BR>
</TD></TR>
</TABLE>
<TEPUTSECTION GLOBAL.FOOTER>
</TESECTION>
<TESECTION end
When Tranpath_1 is "end">
<TEACTION GETSESSION>
<TEIF web.PF3_Key != "">
<TEACTION ENTER "[pf3]">
</TEIF>
</TESECTION>
End of Solution for Exercise 7.1
 |
 |