Forum Discussion

sguda's avatar
sguda
Regular Contributor
13 years ago

How do we declare the global,local variables of different type in script routine

I have script routine and unable to define variable of public type or loacl variables of different type. where can i see this information.

All i can define in the script routine is Dim Variable .

6 Replies

  • Hi Sri,



    There are no explicit variable types in VBScript. Since TestComplete uses Microsoft VBScript engine, I recommend that you see the following MSDN Library article for more information:


    http://msdn.microsoft.com/en-us/library/t0aew7h6.aspx





    Local variables are variables declared in a function's scope, global variables are variables declared outside of a function (that is, in a global context).
  • sguda's avatar
    sguda
    Regular Contributor
    Hi Allen,

    So do you mean that i cannot define the varables as Dim StudSSN as integer or Dim LastName as  String or Dim Cuurency as Double etc in the script routine.
  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi Sri,



    All variables in scripting languages are of OleVariant type. And even if some scripting language supports declaration like 'Dim str As String' this is just a syntax wrapping.

    VBScript does not support typed variables and all variables must be declared as

    Dim StudSSN

    Dim LastName

    Dim Currency



    All of them will be of OleVariant type unless you explicitly assign them typed value using CInt()/CStr/CLng() etc. functions.
  • Hi Team,



    How do I declare a variable with data type if based on the above description.

    Is there any other way?

    Thanks.



    -zean-


  • Global Variable Declaration:



    After double click on Project display the Proj info. Navigate to Variable page :

    Right click on Temporary Variable, create New Item and give the Variable name(var) and default value.



    Now you can access the above variable in your scripts :

    var1=Project.Variables.var



    You can override the deafult variables in your script and access.

        http://smartbear.com/forums/forum/post/?mode=singlethread&thread=0895e53c-3bfe-4de1-9e9f-af9522270c49

  • Hi Zean,





    If Praveen's suggestion does not help, please describe the task you need to accomplish in detail.