Source: site.view [edit]
Function name: findPhone
Arguments: person
Description: A command to find phone for someone
Page type: webl
Render function:   tlidRender
Module: global

Page source:

var P;
var tmp1;
var context;

context = NLUtil_InitContext();

//|| go to http://cee.ai.sri.com
context = NLUtil_GetUrl(context, "http://cee.ai.sri.com", nil, nil);
P = NLUtil_GetContext(context, `P`);

//|| find all forms
P = NLUtil_GetContext(context,`P`);
context = NLUtil_SetContext(context,`form`, Elem(P, `form`) );

//|| field cee_login is "test"
context = NLUtil_SetField(context, "cee_login", `test`);

//|| submit
context = NLUtil_submitForm(context);
P = NLUtil_GetContext(context, `P`);

//|| click on the Directory link
P = NLUtil_GetContext(context,`P`);
context = NLUtil_SetContext(context,`a`, Elem(P, `a`) contain Pat(P, `(?i)Directory`));
context = NLUtil_clickLink(context);
P = NLUtil_GetContext(context, `P`);

context = NLUtil_SetContext(context, `P`, P);

//|| how many forms are there
P = NLUtil_GetContext(context,`P`);
context = NLUtil_SetContext(context,`form`, Elem(P, `form`) );

//|| field queryString is the person
context = NLUtil_SetField(context, "queryString", person);

//|| submit the form
context = NLUtil_submitForm(context);
P = NLUtil_GetContext(context, `P`);

//|| find all tables
P = NLUtil_GetContext(context,`P`);
context = NLUtil_SetContext(context,`table`, Elem(P, `table`) );

//|| find all tables that contain the person
P = NLUtil_GetContext(context,`P`);
context = NLUtil_SetContext(context,`table`, Elem(P, `table`)  contain Pat(P, `(?i)` + person));

//|| get the Phone for the person
tmp1 = NLUtil_GetTableCell(context, `Phone`, person);
if tmp1 != nil then
   context = NLUtil_SetContext(context,`td`,[tmp1]);
 end;

if Size(OPTIONALARGS) == 0 then
   NLUtil_LastValue(context);
else
   context;
end;