Forum Discussion

Oferv's avatar
Oferv
Super Contributor
14 years ago

Changing integer with variable that holds an integer doesn't work

Hi,

I', trying to click an item:

and i wonder why this is working fine

   Aliases["DesktopMainWindow"]["Source_MainWindow"]["MainWindow"]["LayoutRoot"]["NavigationDockPanel"]["NavigationPane"]["ContentPane"]["TOCTree"]["LayoutRoot"]["NavigationalPaneTOCTree"]["ClickItem"]("|[2]"); 

while this is not


Aliases["DesktopMainWindow"]["Source_MainWindow"]["MainWindow"]["LayoutRoot"]["NavigationDockPanel"]["NavigationPane"]["ContentPane"]["TOCTree"]["LayoutRoot"]["NavigationalPaneTOCTree"]["ClickItem"]("|[TabToUpdate]");



TabToUpdate is a random number i'm generating using random function and i just replaced the integer with TabToUpdate

i also tried using strToInt and it didn't work for me as well



Thanks

  

2 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    You need to use a concatenation for your variable to work.  Since TabToUpdate is a variable, you can't just embed it in a string, you need to indicate that it is a variable containing a string.



    so, change your line of code to the following:



    Aliases["DesktopMainWindow"]["Source_MainWindow"]["MainWindow"]["LayoutRoot"]["NavigationDockPanel"]["NavigationPane"]["ContentPane"]["TOCTree"]["LayoutRoot"]["NavigationalPaneTOCTree"]["ClickItem"]("|[" + TabToUpdate + "]");