Listing 1
Listing 1, showing HTML code that produces Figure 2 below.
/***************************************************************
* CGIGet is a routine we extracted from the NCSA *
* routine post-query.c, by Rob McCool. We'll go into *
* this routine in greater detail next issue. For now, *
* simply be aware that it returns a pointer to a string *
* containing the value for the variable requested, or *
* NULL if the variable didn't have a value. *
***************************************************************
*/
// Get the selected challenge
Selected = CGIGet("Select");
if (Selected != NULL)
iSelected = atoi(Selected);
else
{
show_error_screen(sPageInfo, "You have not selected a
challenge. Please select a challenge and try again.");
iSelected = 0;
return 0;
}
// Figure out which button was hit and process it.
// SELCT1 is the name of the bitmap. We gave it that name in the
// <INPUT TYPE=IMAGE NAME=> tag. Because it is a bitmap,
// the browser returns the X and Y coordinates of the hit. Since
// we're only interested in the X (Horizontal) position, we don't
// check the Y value.
cXpos = CGIGet("SELCT1.x");
if (cXpos != NULL)
{
// Convert the char to an integer
sscanf(cXpos, "%d", &Xpos);
if (Xpos < 75)
{
// User hit the first button (Play)
.
.
Code to start playing a challenge
.
.
}
else if (Xpos < 150)
{
// User hit the second button (Details)
.
.
Code to show the challenge details
.
.
}
else if (Xpos < 225)
{
// User hit the third button (Delete)
.
.
Code to remove a player from a challenge
.
.
}
else if (Xpos < 300)
{
// Display the login page
show_user_login(sPageInfo);
}
else
{
// Help screen
sPageInfo->iCurrentChallenge = iSelected;
iSelChlng = iSelected;
WriteItAll(sPageInfo);
show_help_screen(sPageInfo);
}
}
Listing 1, showing HTML code that produces Figure 2 below.
Figure 2
For Figure Two please see:
http://smc.sierra.com/
Back To Main Article