GETPARAMETER()

From Lianjapedia
Jump to: navigation, search

Purpose

Function to return the value of a parameter passed to a .rsp script or return an alternative value if the parameter was not passed

Syntax

GETPARAMETER(<expC1>, <expC2>)

See Also

FUNCTION, GETMEMBER(), GETSESSIONVAR(), PARAMETERS, PARAMETERS(), PCOUNT(), PROCEDURE, RETURN, SET PROCEDURE, STR_QUOTEARGS()

Description

The GETPARAMETER() function is used in .rsp scripts to return the value of a parameter passed to a .rsp script or return an alternative value if the parameter was not passed. Parameters are read from the _request dynamic array, which contains the keys and values from the URL request. The name of the parameter is specified in <expC1>. An alternative value for the parameter is specified in <expC2> and this will be read if the parameter is not passed.

This function is also available in Python .pysp files and JavaScript .jssp files.

Note: the STR_QUOTEARGS() function (from v6.1) can be used to place quotes around each item in a comma separated list, so is particularly useful when parsing such parameters.

Example

// WebView URL Attribute
quickreport.rsp?database=southwind&table=example&fields=*&heading=Client List (all)&columns=2,4,3,5,6,7,8,9,10,11,12&subtotals=9,10,11&gridlines=true
 
//--
// quickreport.rsp?parameter=value&parameter=value...
//
// parameters 
//--
private database   = getParameter("database", "southwind") 
private table      = getParameter("table", "example") 
private fields     = getParameter("fields", "*") 
private groupby    = getParameter("groupby", "") 
private heading    = getParameter("heading", "Report for all clients by state") 
private headings   = getParameter("headings", "") 
private filter     = getParameter("filter", "") 
private hyperlink  = getParameter("hyperlink", "") 
private columns    = getParameter("columns", "") 
private subtotals  = getParameter("subtotals", "") 
private gridlines  = getParameter("gridlines", "")
// ...
// library:/chartview.rsp
// ...
// get parameters
local p_sectionid        = getParameter("sectionid", "")
local p_charttype        = getParameter("charttype", "pie")
local p_labels           = getParameter("labels", "'red','green','blue', 'rgba(255, 99, 132, 0.2)'")
p_labels                 = str_quoteargs(p_labels)
local p_caption          = getParameter("caption", "# of Votes")
local p_backgroundcolors = getParameter("backgroundcolors", "'rgba(255, 99, 132, 1)';
,'rgba(54, 162, 235, 1)','rgba(255, 206, 86, 1)'")
p_backgroundcolors       = str_quoteargs(p_backgroundcolors)
local p_bordercolors     = getParameter("bordercolors", "'rgba(255, 99, 132, 1)';
,'rgba(54, 162, 235, 1)','rgba(255, 206, 86, 1)'")
p_bordercolors           = str_quoteargs(p_bordercolors)
// ...