Jump to content

read from more varibles in a FOR ..TO


Recommended Posts

Hi.

I'm trying to do the following:

#include <MsgBoxConstants.au3>
Local $i, $Var0 = "Check", $Var1 = "this", $Var2 = "out", $Var3 = "girls."
For $i = 0 to 3
   MsgBox($MB_SYSTEMMODAL,"Strings",$Var[$i])
Next

But I get this error:

warning: $Var: possibly used before declaration.
   MsgBox($MB_SYSTEMMODAL,"Strings",$Var[$i])
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
error: $Var: undeclared global variable.
   MsgBox($MB_SYSTEMMODAL,"Strings",$Var[$i])
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
 

How can I fix this?

Yours sincerely

Kenneth.

Link to comment
Share on other sites

Do something like.

 

#include <MsgBoxConstants.au3>
Local $i, $Var0 = "Check", $Var1 = "this", $Var2 = "out", $Var3 = "girls."
For $i = 0 to 3
   MsgBox($MB_SYSTEMMODAL,"Strings",Execute("$Var" & $i))
Next

 

So a more elegant way should be using array.

#include <MsgBoxConstants.au3>
Local $i, $Var[] = ["Check",  "this","out",  "girls."]
For $i = 0 to 3
   MsgBox($MB_SYSTEMMODAL,"Strings",$Var[$i])
Next

Saludos

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...