Source: site.view [edit]
Function name: searchGoogle
Arguments: term
Description: A command to search google for a term
Page type: webl
Render function:   tlidRender
Module: global

Page source:

var P;
var context;

context = NLUtil_InitContext();

//|| go to http://www.google.com
context = NLUtil_GetUrl(context, "http://www.google.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 q is the term
context = NLUtil_SetField(context, "q", term);

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

//|| find all links that contain the term
P = NLUtil_GetContext(context,`P`);
context = NLUtil_SetContext(context,`a`, Elem(P, `a`)  contain Pat(P, `(?i)` + term));

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