Forum Discussion

Cetherinefoster's avatar
Cetherinefoster
New Contributor
3 years ago

How to call only a part of the procedure into another vbscript?

I've a script named script 1 that creates a text file and stores some string values into it. I need to call this script script 1 into another script file named script 2 but only part of it (script 1). I don't want to call the part of the script (script 1) that will store string values. How can I call only part of the script 1 into script 2? I'm using TestComplete to run these scripts.  DQFanFeedback Survey

  • Hi Cetherinefoster 

     

    I would suggest additional function parameter (boolean will work) that will exclude the code if you set it to true.  Maybe something like this could work. I hope it helps.

     

    function script1(fileName, text, optionalExcludeCode)
    {
      // code that always runs

      // optionalExcludeCode is null or false then run code in if statement
      if (optionalExcludeCode == null || !optionalExcludeCode)
      {
        // code that will be excluded if optionalExcludeCode is set to true
      }

      // code that always runs

      // optionalExcludeCode is null or false then run code in if statement
      if (optionalExcludeCode == null || !optionalExcludeCode)
      {
        // code that will be excluded if optionalExcludeCode is set to true
      }

      // repeat as needed....
    }

    function script2 (fileName, text)
    {
      script1(fileName, text, true)
    }