Get param

Purpose: Get a parameter value.

 get-param <name> [ type <type> ]

get-param stores a parameter value in variable <name>. A parameter is a name/value pair kept by Gliimly for each request. The parameter's name must match <name>. A parameter can be of any type. A parameter is set either:
If a parameter is a string, it is  trimmed for whitespaces (both on left and right).
Types
By default, <name> is a string variable, unless <type> (in "type" clause) is specified. <type> can be "string" for a string variable (the default), "bool" for a boolean variable, "number" for a number variable, "message" for a message variable, "split-string" for a split-string variable, "array" for an array variable, "index" for an index variable, "index-cursor" for an index cursor variable, "fifo" for a FIFO variable, "lifo" for a LIFO variable, "list" for a list variable, "file" for a file variable, and "service" for a service variable.

The value obtained with get-param is checked to be of the proper <type>, and if it isn't, your request will error out. The exception to this is that a string parameter can be converted into a number or a boolean, assuming the string value represents a valid number or is "true"/"false".  Parameters of "number" and "bool" types are obtained by value, and others by reference. It means for instance, that you can pass an index to sub-handler and read and write nodes there, and such changes will be visible in the caller request.
Input parameters from a caller
Input parameters from an outside caller are specified as name/value pairs (see service or command-line). Input parameter name can be made up of alphanumeric characters, hyphen or underscore only and cannot start with a digit. Note that a hyphen is automatically converted to underscore, so for instance an input parameter "some-parameter" in HTTP request will be "some_parameter" in get-param.
- File uploads
File uploads are handled as input parameters as well, see file-uploading.
- Web input parameters
As an example, for HTML form input parameters named "param1" with value "value1" and "param2" with value "value2":
<input type='hidden' name='param1' value='value1'>
<input type='hidden' name='param2' value='value2'>

you can get these parameters and print out their values by using:
 get-param param1
 get-param param2

A request may be in the form of a web link URL, and getting the parameter values is the same:
http://<your web server>/<app name>/<request name>&param1=value1&param2=value2

Setting parameters during request's execution
Use set-param to replace the value of an existing parameter, or create a new one. For instance:
 get-param par1
 ...
 set-param par1="new value"

In this case the value of an existing parameter "par1" is replaced with "new value". In the following code a new parameter is created, which can be retrieved later with get-param:
 set-param par1="new value"
 get-param par1

See sub-handler for more examples.
Duplicate input parameter names
If there are multiple input parameters with the same name set by the request caller, such as
http://<web address>/<app name>/<request name>?par=val1&par=val2

the value of input parameter "par" is undefined. Do not specify multiple input parameters with the same name.
See also
Request data
get-param  
request-body  
set-param  
See all
documentation


Copyright (c) 2019-2024 Gliim LLC. All contents on this web site is "AS IS" without warranties or guarantees of any kind.