Jump to content

Recommended Posts

Posted (edited)

I don't remember reading that it was impossible, or that it was possible for that matter. Why won't the code below work?

$Filters_FilterNames = IniReadSectionNames(@WorkingDir & "\Filters.ini")
For $iFilter = 1 To $Filters_FilterNames[0]
    $Filters_Filter[$iFilter] = GUICtrlCreateMenuItem($Filters_FilterNames[$iFilter], $Filters)
Next

I get

Expected a "=" operator in assignment statement.:

$Filters_Filter[$iFilter] = GUICtrlCreateMenuItem($Filters_FilterNames[$iFilter], $Filters)

$Filters_Filter^ ERROR

->00:30:59 AutoIT3.exe ended.rc:1

Edited by Zachlr
Posted

Well, your example isn't complete enough to be sure, but declaring the array might get you a bit further along...

$Filters_FilterNames = IniReadSectionNames(@WindowsDir & "\win.ini")
Dim $Filters_Filter[$Filters_FilterNames[0] + 1]
For $iFilter = 1 To $Filters_FilterNames[0]
    $Filters_Filter[$iFilter] = GUICtrlCreateMenuItem($Filters_FilterNames[$iFilter], $Filters)
Next
Posted (edited)

first you use:

$Filters_FilterNames = IniReadSectionNames(@WindowsDir & "\win.ini")

then

$Filters_FilterNames[$iFilter]

so you have a var and array with the same name. if you look @ this source.

easy example

Local array[20]
$temp = 0

While temp > 20
    array[$temp] = $temp
    $temp = $temp + 1
Wend

gl

Edited by Mike23
Posted

Well, your example isn't complete enough to be sure, but declaring the array might get you a bit further along...

$Filters_FilterNames = IniReadSectionNames(@WindowsDir & "\win.ini")
Dim $Filters_Filter[$Filters_FilterNames[0] + 1]
For $iFilter = 1 To $Filters_FilterNames[0]
    $Filters_Filter[$iFilter] = GUICtrlCreateMenuItem($Filters_FilterNames[$iFilter], $Filters)
Next
But IniReadSectionNames() declares an array doesn't it?

first you use:

$Filters_FilterNames = IniReadSectionNames(@WindowsDir & "\win.ini")

then

$Filters_FilterNames[$iFilter]

so you have a var and array with the same name. if you look @ this source.

easy example

Local array[20]
$temp = 0

While temp > 20
    array[$temp] = $temp
    $temp = $temp + 1
Wend

gl

I'm not sure I quite understand what you mean. Maybe I should explain what I am trying to do first.

Upon start-up my script is supposed to read an ini file that contains information about each filter. I then creates a menu item from the section name. It also must declare a variable different from that of the filter names, so that the script can tell when it is clicked. I want to create an array of control IDs for each menu item, using a loop. The loop should repeat for each new filter name, and write a variable (the control ID) in an array.

I hope that makes a little more sense. Thanks.

Posted

Yes, IniReadSectionNames() declares and returns an array for you.

Your second array you build in your loop that consists of control ID's returned by GUICtrlCreateMenuItem wasn't declared though. Didn't inserting a Dim/Local/Global for the second array get you past this trouble spot?

Posted

Yes, IniReadSectionNames() declares and returns an array for you.

Your second array you build in your loop that consists of control ID's returned by GUICtrlCreateMenuItem wasn't declared though. Didn't inserting a Dim/Local/Global for the second array get you past this trouble spot?

Alternatively, is it just a typo? Did you mean to create the menu item and store its control ID in place of the section name in the same array? Then you just need to fix the array names to match: "$Filters_FilterNames" gets the output from IniReadSectionNames(), then you used "$Filters_Filter" inside the loop.

^_^

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Posted

Yes, IniReadSectionNames() declares and returns an array for you.

Your second array you build in your loop that consists of control ID's returned by GUICtrlCreateMenuItem wasn't declared though. Didn't inserting a Dim/Local/Global for the second array get you past this trouble spot?

Doh! I was declaring a variable instead of an array. My script now works as it should. Thanks.

Alternatively, is it just a typo? Did you mean to create the menu item and store its control ID in place of the section name in the same array? Then you just need to fix the array names to match: "$Filters_FilterNames" gets the output from IniReadSectionNames(), then you used "$Filters_Filter" inside the loop.

^_^

No, I the section names and the control IDs are both referenced later, so the need to be different. Thanks for the reply though.

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
×
×
  • Create New...