Forum Discussion

sandhyaramesh's avatar
sandhyaramesh
New Contributor
8 years ago

Global Variable Issue : Unable to access parameter value across script units

Hi,

 

I am not able to access variable value across script units.

In below code we have 2 function in 2 different units and have declared as global variable and useunit, but still we are not able to get parameter value when the control passes to T() function in another unit and we are getting error "Type mismatch: 'Parameter'".

 

/////Script Unit1

'USEUNIT Unit2

 

Dim Parameter, Increment

 

Function Test
Increment = ""
For k = 1 to 5
Increment = Increment & k & ";"
Next
Parameter = Split(Increment,";")
Unit2.T()
End Function

 

////Script Unit2

 

Dim Parameter

 

Function T()
log.message Parameter(2)
log.message Parameter(3)
End Function

 

Regards

Sandhya

2 Replies

  • Hi,

     

    Basically i want to retrieve data from different column of single row in  excel and store it in array, later split it to different parameter name like parameter1, parameter2..etc to use  further in different script unit. 

     

    With the above code, it did not work, so tried with project.variables as below, but here i am facing error while adding normal variable itself. But i want to add different variable name like parameter1, parameter2...etc through loop where 1,2... are variables.

     

     

    • baxatob's avatar
      baxatob
      Community Hero

      When you are using AddVariable method, you should pass variable type as a second argument, but you tried to assign the value. In your case you need:

       

      Project.Variables.AddVariable("FPath", "String")
      Project.Variables.FPath = "C:/"