Forum Discussion

fayrehouse's avatar
fayrehouse
Frequent Contributor
12 years ago

String params not treated as regex's...

Hi All, I have a number of funtions that take a file/folder path as a parm - so for example "C:\users\steve\sample.txt" When calling the function, I have to pass this in as "C:\\users\\steve\\s...
  • Andrey_M's avatar
    12 years ago
    Hi Steve.



    I think you won't face problems with passing backslahed strings into your functions from KDTs.



    I played passing KDT variable, KDT parameter and constant into JScript function: variable and KDT parameter came thru without any modifications. As for constant parameter, TC replaces single backslashes with double ones (and backwards) automatically. Just tell your less techy colleagues not to modify parameters directly in parameter string but double click on parameters section and edit them in Operation Parameters dialog.



    I think the best solution for you is in using KDT/Project/Suite variables for your path definitions.



    I wrote function which posts parameter passed into TC log:





    function getFileName( pPathAndFile )

    {

      Log.Message( pPathAndFile );

      return;

    }



     

    This function was called from KDT passing constant, KDT parameter and KDT variable.

    See attached screenshots.