Video Screencast Help

WiseScript Variable Value in Variable

Created: 26 Apr 2013 • Updated: 02 May 2013 | 3 comments
This issue has been solved. See solution.

Hello,

I want to set a variable value with a variablename.

Sample:

Set Variable VALUE_1 to {02B6E651-686D-4BCD-8A93-C07B01761745}

Set Variable COUNTER to %COUNTER%+1

Set Variable EXECUTE to %VALUE_%COUNTER%%%

In this Sample is the Value of EXECUTE now %VALUE_1%.

But I need the Value of VALUE_1 to be EXECUTE. (In this case EXECUTE should be {02B6E651-686D-4BCD-8A93-C07B01761745})

Because i call the variable in an "Execute Programm" Action as Command Line Parameter.

Thanks for Help!

PS: My goal is to create an While-loop like this:

item: Set Variable
  Variable=VALUE_1
  Value={02B6E651-686D-4BCD-8A93-C07B01761745}
end
item: Set Variable
  Variable=VALUE_2
  Value={0607F297-8670-483C-8947-61A572473DEF}
end
item: Set Variable
  Variable=VALUE_3
  Value={0AAB121C-8EA7-49F5-B37C-DF117FB46771}
end
item: Remark
end
item: If/While Statement
  Variable=COUNTER
  Value=10
  Flags=00010001
end
item: Remark
end
item: Set Variable
  Variable=COUNTER
  Value=%COUNTER%
  Flags=00000100
end
item: Set Variable
  Variable=MSIGUID
  Value=%%VALUE_%COUNTER%%%
end
item: Set Variable
  Variable=EXECUTE
  Value=msiexec /x %MSIGUID% /qs
end
item: Remark
end
item: End Block
end
 

Operating Systems:

Comments 3 CommentsJump to latest comment

EdT's picture

If I understand your requirement correctly, what you are trying to create is an indexed array, but this is not available directly in Wisescript.  If you have a recent version of Wisescript (eg Wise Package Studio or Wise Installation Studio 7 or later) then you should be able to call a VBScript to do this, but there is another way.

Check whether the Set Variable command option "Evaluate Expression" offers you any solution.

However, the technique I sometimes use is the parse command.

So you can set a variable (eg GUIDS) that looks like this:

<GUID1>,<GUID2>,<GUID3>, etc.  Remember that variable can be up to 32 K long so that should not be an issue even for several hundred GUIDs.

Then you can do the following (my pseudoscript)

Count =1

While count not equal to 10

parse %GUIDS% into LEFT and GUIDS  (using the comma as the delimiter)

item: Set Variable

  Variable=EXECUTE

  Value=msiexec /x %LEFT% /qs

end

Count = Count +1   (Set variable count to %count% using the increment option

end block

Each parse command takes the leftmost guid and places it in the LEFT variable, with the remainder going back into the GUID variable.

Of course you can add other tests to make sure that GUID is not empty before you parse it, which could make it unnecessary to actually maintain a count, and then just exit when GUID is empty.

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

SOLUTION
Spiderschwein's picture

Hey EdT,

thank you very much!

You helped me to save a lot of time/work!

EdT's picture

Glad to have been of service. ;-)

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.