A powerful feature of Flynet Viewer is that its definition files are able to group screens. When multiple screens share the same recognition information, it may be useful to share the recognition information amongst the group. For example, when a sign on fails, the screen may not actually change, but only an error message be displayed.
For example, in the Insure application, when an invalid login attempt is made the message "User Profile not recognized" appears on the screen, while the rest of the screen remains the same:
By modifying the Insure definition file to the following, it would be able to determine whether the sign on failed:
<ScreenGroup name="Start" virtual="no">
<Recognize type="include" row="1" column="27" text="M U L T X T E R M"/>
<Recognize type="include" row="10" column="3" text="SWITCHIT"/>
<FieldMap name="default">
<Field name="Username" row="22" column="23" length="8"/>
<Field name="Password" row="22" column="53" length="8"/>
</FieldMap>
<Screen name="OK">
<Comment>No error messages</Comment>
<Recognize type="omit" row="24" column="3" text="User Profile"/>
</Screen>
<Screen name="Failed">
<Comment>Failed signon</Comment>
<Recognize type="include" row="24" column="3" text="User Profile"/>
</Screen>
</ScreenGroup>
Using this new definition the Start screen could be recognised as "Start.OK" and "Start.Failed". Note the recognise element for the "OK" screen which omits the text "User Profile", and "Failed" screen which includes the text "User Profile". The hierarchical nature of the recognition means that it is possible to create multiple levels of recognition. If the ScreenGroup element's "virtual" attribute is set to yes, then its name will not be used in identification of it children screens.
Refer to the ScreenGroup and Screen reference in the Screen Definitions Reference for more information.
The following code demonstrates the use of the above definition for the screen group.
Option Explicit
Dim objCon As New HostConnection 'Connection object
Dim objScr As HostScreen 'Screen object
Dim strSessionKey As String 'SessionKey
Sub ScreenGrouping()
'try to connect
connect
If objCon.connected Then
showGroups
disconnect
Else
Debug.Print "Connect to host failed!" & vbCrLf
End If
Set objScr = Nothing
Set objCon = Nothing
End Sub
'
'Connect to the host
Private Sub connect()
On Error Resume Next
objCon.HostName = "Insure" 'set to match the hostname settings in admin console
objCon.connect "standard"
If Err.Number > 0 Then
Debug.Print "Error: " & Err.Description & vbCrLf
Exit Sub
End If
Set objScr = objCon.getScreen
strSessionKey = objCon.sessionKey
End Sub
'
'Disconnect from the host
Private Sub disconnect()
objCon.disconnect "stop"
strSessionKey = ""
End Sub
'
'Show the names of the screens in the screen group
Sub showGroups()
Dim strScrName 'Name of screen
strScrName = objScr.getScreenName()
Debug.Print strScrName & vbCrLf
objScr.putCommand "[enter]", 2000 'force a failed signon
If "Start.Failed" = objScr.getScreenName() Then
Debug.Print "Failed to progress to next screen - currently on " & objScr.getScreenName() & vbCrLf
End If
objScr.mappedSet "Username", "simmy"
objScr.putCommand "[enter]", 1000 'signon correctly
If "SysSelect" = objScr.getScreenName() Then
Debug.Print "Progressed to next screen - currently on " & objScr.getScreenName() & vbCrLf
End If
End Sub
|
public class FSCProFunctions
{
private HostConnection con = new HostConnection();
private HostScreen scr;
private string sessionKey;
/// <summary>
/// Connect to the host, navigate to AcctTrans,
/// and demonstrate the use of Screen Groups.
/// Note that the definition file MUST be modified.
/// Refer to the definition information in the help file.
/// </summary>
public void ScreenGrouping()
{
//try to connect
connect();
if(con.connected)
{
showGroups();
disconnect();
}
else
Debug.WriteLine("Connect to host failed!");
}
/// <summary>
/// Connect to the host
/// </summary>
private void connect()
{
con.hostName = "Insure"; //set to match the hostname settings in admin console
con.connect("standard");
scr = con.getScreen();
sessionKey = con.sessionKey;
}
/// <summary>
/// Disconnect from the host
/// </summary>
private void disconnect()
{
con.disconnect("stop");
sessionKey = "";
}
/// <summary>
/// Show the names of the screens in the screen group
/// </summary>
private void showGroups()
{
string scrName; //Name of screen
scrName = scr.getScreenName();
Debug.WriteLine(scrName);
scr.putCommand("[enter]", 2000); //force a failed signon
if("Start.Failed" == scr.getScreenName())
Debug.WriteLine("Failed to progress to next screen - currently on " + scr.getScreenName());
scr.mappedSet("Username", "simmy");
scr.putCommand("[enter]", 1000); //signon correctly
if("SysSelect" == scr.getScreenName())
Debug.WriteLine("Progressed to next screen - currently on " + scr.getScreenName());
}
}
|
The code contains the following functions:
•connect
•disconnect
•showGroups
The connect and disconnect are self-explanatory.
showGroups displays the first screen name ("Start.OK"), then forces a signon attempt that will fail. This results in the error message being displayed which means that the error message with the screen name "Start.Fail" will be displayed. It then progresses to the next screen, displaying a message.