Forum Discussion

mooitc's avatar
mooitc
Occasional Contributor
2 years ago

TC: Array in KeywordTest

Hi,

how can I implement these VBScript lines in KeywordTest?

Sub INIT_ICO
Project.Variables.ICO_XX = "09"
For Each i In Array(Project.Variables.ICO_XX)
ProjectSuite.Variables("APP_" & i) = "APP_" & i
Next
End Sub

3 Replies

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Does your script actually work?

    What output are you expecting?

    • mooitc's avatar
      mooitc
      Occasional Contributor

      Hi rraghvani,
      thanks for the tip, here is the correction:

      Sub INIT_ICO
      'Project.Variables.ICO_XX = "09"
      'Project.Variables.APP_XX_NAME = "notepad"
      For Each i In Array(Project.Variables.ICO_XX)
      Project.Variables("APP_" & i) = Project.Variables.APP_XX_NAME
      Log.Message(Project.Variables("APP_" & i))
      Next
      End Sub
  • rraghvani's avatar
    rraghvani
    Champion Level 3

    You have your variables already defined in the project. In your keyword test use the For Loop statement with Code Expression for Array(Project.Variables.ICO_XX). Use Code Expression again for Project.Variables("APP_" & i) = Project.Variables.APP_XX_NAME, and then use Log to output the variable.

    You can convert your keyword test to scripts, and see if it matches with what you have written.