Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Possible: a variable variable ?


  • Please log in to reply
11 replies to this topic
klim
  • Members
  • 22 posts
  • Last active: Jun 22 2011 06:45 AM
  • Joined: 22 Mar 2006
i need a variable variable, it it possible, please need help.

here an example code:

if LocationData%Counter% <>
	StatusData%Counter%=1
else StatusData%Counter%=0

[color=red]MsgBox %StatusData%Counter%%[/color]


temp01
  • Members
  • 120 posts
  • Last active: May 18 2013 08:27 PM
  • Joined: 09 Jul 2009
MsgBox % StatusData%Counter%


klim
  • Members
  • 22 posts
  • Last active: Jun 22 2011 06:45 AM
  • Joined: 22 Mar 2006
sometimes the answer is soooooo easy and soooooo far away.
thank you very much.

klim
  • Members
  • 22 posts
  • Last active: Jun 22 2011 06:45 AM
  • Joined: 22 Mar 2006
i've again a problem with a variable in a variable



Loop, %NumberOfDataDrives%
{
DataDriveCounter+=1
Menu, ListMenu, Add, &Files from % LocationData%DataDriveCounter%, CommandList
}

now it's also not working with your hint, please need help again

Delusion
  • Members
  • 272 posts
  • Last active: Jul 13 2014 09:04 PM
  • Joined: 16 Jul 2008
try this...it should work: (untested)

Loop, %NumberOfDataDrives%
{
DataDriveCounter+=1
Menu, ListMenu, Add, &Files from % LocationData . DataDriveCounter, CommandList
}

or

Loop, %NumberOfDataDrives%
{
DataDriveCounter+=1
Menu, ListMenu, Add,% "&Files from " LocationData . DataDriveCounter, CommandList
}

QuickSubs | Popcorn Movie Catalog
All my scripts are just in AutoHotkey v1.0.48.05

klim
  • Members
  • 22 posts
  • Last active: Jun 22 2011 06:45 AM
  • Joined: 22 Mar 2006
thank you very much, to bad that none of that was working.
i simply removed the static text, now it looks like this and is working:



Menu, ListMenu, Add,% LocationData%DataDriveCounter%, CommandList


klim
  • Members
  • 22 posts
  • Last active: Jun 22 2011 06:45 AM
  • Joined: 22 Mar 2006
now it is working like it shoud:



Loop, %NumberOfDataDrives%
{
DataDriveCounter+=1
DriveNumberForListCommand=%DataDriveCounter%
MsgBox, % LocationData%DataDriveCounter%
temp=% LocationData%DataDriveCounter%
Menu, ListMenu, Add, Data %DataDriveCounter% : %temp%, CommandList
}


jaco0646
  • Moderators
  • 3165 posts
  • Last active: Apr 01 2014 01:46 AM
  • Joined: 07 Oct 2006
Loop, %NumberOfDataDrives%

{

 DataDriveCounter+=1

 Menu, ListMenu, Add,% "&Files from " LocationData%DataDriveCounter%, CommandList

}


klim
  • Members
  • 22 posts
  • Last active: Jun 22 2011 06:45 AM
  • Joined: 22 Mar 2006
Is a dynamic variable possible in any way:

global ReadingStatusDrive%DriveLetter%


jaco0646
  • Moderators
  • 3165 posts
  • Last active: Apr 01 2014 01:46 AM
  • Joined: 07 Oct 2006
More than possible: dynamic variables are common; however they cannot be declared in functions.

...it is not currently possible to declare a dynamic variable such as global Array%i%.

If you explain what you're tying to do, there is almost certainly a workaround.

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
klim, an existing global variable/array does not need to be declared. If you need to create a global array, it must be done via a global subroutine or assume-global function.

Within a function, any dynamic variable reference such as Array%i% always resolves to a local variable unless no variable of that name exists, in which case a global is used if it exists. If neither exists and the usage requires the variable to be created, it is created as a local variable unless the assume-global mode is in effect.
Source: Functions



HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
[Moderator's note: Redundant quote removed.]

For example :)
GGV(var){ ;GetGlobalVar
   global
   local __TEMP
   __TEMP:=%var%
   Return __TEMP
}
SGV(var,value=""){ ;SetGlobalVar
   global
   %var%:=value
   Return
}