What is Declare Parameter?
Declare parameter is a parameter which we use to
assign values.
Its value must be initialized by script writer.
Its value cannot be changed Automatically.
In Legacy type script it should be declared and used in
script.capture file.
In C type script it should be declared in
registration.spec file and used in flow file (e.g xyz.c).
Declare Parameter’s GUI looks like as shown:-
Validations on Parameter name field of Declare
parameter
Parameter name should start with alphabet.
Other characters except first can be alphabet, numeric
and underscore(_) .
Special characters, comma(,) and spaces are not valid
characters for Parameter Name.
Steps to declare a Declare Parameter
Open Script Manager and select a script in which you
want to use Declare Parameter.
And select specific file means, if you use Legacy type
script then it should be script.capture and if you are
using C type script then it should be registration.spec.
Now there are two ways to get Declare Parameter GUI
One is from Menu Bar.
Another is by right click in the Right Pane of specific
file.
As you can see in below snapshots respectively.
Declare Parameter by Menu Bar
Declare Parameter by Right Click in Right Pane
Clicking on Declare Parameters you will get the
following screen.
Clicking on Add you will get following frame.
Write desired Parameter Name and then click on OK
Button.
Then click on Close.
After that you will get the following API in your file (in
registration.spec or in script.capture).
nsl_decl_var(sessionId);
Now we have to pass some value to our Declare
Parameter. For that we can use the following API
ns_save_string("75893.0884568651DQADHfApHDHfc
DtccpfAttcf", "sessionId");
Note :- How can we add the above API ? Steps are given below .
For adding ns_save_string ()API you should be in
script.capture file for Legacy type and in flow file for C
type .
This API will also be added by two ways
below.
By Menu Bar .
By Right Click in Right Pane in specific file.
as given
ns_save_string() API by Menu Bar
ns_save_string() API by Right Click in Right Pane
Click on C API you will get the following screen.
Select API from drop down list as shown below.
Now set the Variable Value field by the value which
you want to store in Declare Parameter
below.
as shown
Your Declare Parameter will automatically appear in
Variable Name drop down list. Select parameter in
which you want to store data as shown below.
Now click on OK. You will get the desired API in flow
file or in script.capture file.
Now Parameterize the desired page with Declare
Parameter sessionId.
Example :- I parameterized the login Page
Before Parameterization Page looked like
ns_web_url ("login",
"URL=http://192.168.1.35:83/cgibin/login?userSession=75893.0884568651DQADHfApHDHfcDtccpf
Attcf&username=001&password=Pass&JSFormSubmit=off&login.x=
49&login.y=10",
"HEADER=Accept-Language: en-us",
INLINE_URLS,
Page after parameterization is as follows :ns_web_url ("login",
"URL=http://192.168.1.35:83/cgibin/login?userSession={sessionId}&username=001&password=Pass
&JSFormSubmit=off&login.x=49&login.y=10",
"HEADER=Accept-Language: en-us",
INLINE_URLS,
Then click on Save Button below the Menu bar
Now execute the scenario .
Now for viewing the results how value will substitute to the
output
Type :
vi url_req_0_0_0_1_0_0_0_1_0.dat
You will get the following output:
GET /cgibin/login?userSession=75893.0884568651DQADHfApHDHfcDtccpfA
ttcf&username=001&password=Pass&JSFormSubmit=off&login.x=49&l
ogin.y=10 HTTP/1.1^M
Host: 192.168.1.35:83^M
User-Agent: Mozilla/5.0 [en] (X11; U; Linux 2.4.18-3d_epoll
i686)^MAccept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/p
lain;q=0.8,video/xmng,image/png,image/jpeg,image/gif;q=0.2,text/css,*/*;q=0.^M
Accept-Encoding: gzip, deflate, compress;q=0.9^M
Keep-Alive: 300^M
Connection: keep-alive^M
Accept-Language: en-us^M
^M
© Copyright 2026 Paperzz