Collaborama About Help Contact Anonymous [login] Source: site.view [edit] Function name: findPerDiem Arguments: year,city,state Description: A command to lookup the Per Diem rate for a year, a city, and a state - year (string): A year (e.g. 2007) - city (string): A city (e.g. Oakland) - state (string): A state (e.g. California) - returns (string): Per diem in dollars as an integer value Page type: webl Render function: tlidRender Module: global Page source: var P; var context; context = NLUtil_InitContext(); //|| go to http://www.gsa.gov/Portal/gsa/ep/contentView.do?programId=9704&channelId=-15943&ooid=16365&contentId=17943&pageTypeId=8203&contentType=GSA_BASIC&programPage=%2Fep%2Fprogram%2FgsaBasic.jsp&P=MTT context = NLUtil_GetUrl(context, "http://www.gsa.gov/Portal/gsa/ep/contentView.do?programId=9704&channelId=-15943&ooid=16365&contentId=17943&pageTypeId=8203&contentType=GSA_BASIC&programPage=%2Fep%2Fprogram%2FgsaBasic.jsp&P=MTT", nil, nil); P = NLUtil_GetContext(context, `P`); //|| how many forms are there P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`form`, Elem(P, `form`) ); //|| how many forms are there that contain "Rates for Fiscal Year" P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`form`, Elem(P, `form`) contain Pat(P, `(?i)` + `Rates for Fiscal Year`)); //|| field queryYear is the year context = NLUtil_SetField(context, "queryYear", year); //|| field queryState is the state context = NLUtil_SetField(context, "queryState", state); //|| submit the form context = NLUtil_submitForm(context); P = NLUtil_GetContext(context, `P`); //|| find all rows that contain the city P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`tr`, Elem(P, `tr`) contain Pat(P, `(?i)` + city)); //|| find all cells that are inside the row P = NLUtil_GetContext(context,`P`); context = NLUtil_SetContext(context,`td`, Elem(P, `td`) inside NLUtil_GetContext(context, `tr`)[0]); //|| select the third one context = NLUtil_SetContext(context,NLUtil_LastType(context), Select(NLUtil_LastSet(context),2,3)); //|| return it if Size(OPTIONALARGS) == 0 then NLUtil_LastValue(context); else context; end;