Forum Discussion

Morgan's avatar
Morgan
Frequent Contributor
14 years ago

Incrementing Values

I am trying to create a script that increments the variable number by 1 each time around and then appends it to the wndcaption and saves the region file to regions. So far, I have the script below which only seems to be resulting in regions with names of 2Dog, 2Bears, 2Cats... I want to see 1Dog, 2Bears, 3Cats.



I have the project variable set up as an integer with a default value of 1.



Sub Test

Set w = Sys.Desktop.ActiveWindow().Picture

Regions.AddPicture w, VarToStr(Project.Variables.Num +1) + VarToStr(Sys.Desktop.ActiveWindow.WndCaption)

End Sub



Thank you!

Morgan

2 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Try this.  The key is to increment the number and assign it to itself.  Test would then be called within the loop and you should get your desired output.



    Sub Test

    Set w = Sys.Desktop.ActiveWindow().Picture

    Regions.AddPicture w, VarToStr(Project.Variables.Num) + VarToStr(Sys.Desktop.ActiveWindow.WndCaption) 

    Project.Variables.Num = Project.Variables.Num+1

    End Sub
  • Morgan's avatar
    Morgan
    Frequent Contributor
    That's what I'm looking for!  Thank you for the prompt response!



    Morgan