Jump to content

A quick For....Next question


Jkeith247
 Share

Recommended Posts

Hello all,

A quick question... well hopefully

I am trying to read 366 lines of an ini file and instead of typing every line individually, I am trying to use For....Next to read them to an array and then write them to a GuiCtrlCreateList. For some reason when I execute this snippet of code I am getting this error "Error: Expected a "=" operator in assignment statement." I am sure that this snippet of code is the cause as when I block comment it, the error goes away. Could someone please help? Thanks!

Func Exceptions()
For $i = 1 To 366 Step 1
$aArray[$i] = IniRead($sini, $i, "Exception", "")
Next
For $element In $aArray
$string = GUICtrlSetData($events, $element)
Next
EndFunc ;==>Exceptions
Edited by Jkeith247
Link to comment
Share on other sites

  • Moderators

Jkeith247,

Firstly you do not need the [ ] around the $i in the IniRead statement - if you fix that you will at least read the ini data correctly. Other than that the snippet is syntactically correct and I am not sure why you get that particular error. :)

What exactly are you trying to to with the For...In loop? At the moment you seem to be setting $string to the result of the final GUICtrlSetData command and setting the text of $events to the value of the final element of the array. Is that the desired result? :graduated:

Can we have a bit of context? What kind of control is $events? And can we see a bit of the ini file to make sure you are getting what you think you are? ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Yeah, lol I saw those [ ] in the ini and fixed.... silly syntax mistake.

Basically I have written a scheduling program and when the person opens this program, I want it to display any exceptions that they have created in a GuiCtrlCreateList. So to avoid having to write 366 lines of ini reads and then manually type all 366 variables in a GuiCtrlSetData($events.... I am trying to use For...In to place all of the variables from the previously created array in the GuiCtrlSetData. The syntax in the ini will include the "|" appended to each entry so hopefully the end result will be a correctly populated list. Here is an example of the ini text

[1]

Exception=All on at 3:30|

[2]

Exception=All off at 4:25|

[3]

Exception=All on at 3:30|

[10]

Exception=All off at 4:20|

Also, there may not be entries for every single day of the year wich explains why I am skipping 4-9 in this snippet of ini. I have set the default of the INIread to "" in the assumption that if the variable is empty then it will not show appear in the GuiCtrlCreateList as a blank line.

Thank you for your help!

Edited by Jkeith247
Link to comment
Share on other sites

Silly silly silly.... I forgot to state the size of my array in the beginning of my code.... So I no longer get the error when executing the script, but now I am on to another question.

As you mentioned earlier,

What exactly are you trying to to with the For...In loop? At the moment you seem to be setting $string to the result of the final GUICtrlSetData command and setting the text of $events to the value of the final element of the array. Is that the desired result? :graduated:

I think I am only getting the last entry in the array. Is there a way to include all entries of the array in the For...In? In the online documentation it appears as though every element of the array will be included with For...In, but this does not seem to be the case. Am I gonna be stuck with a 366 entry GuiCtrlSetData? Basically, I am searching for a way to take all elements of a single array and make them into one long string....

Edited by Jkeith247
Link to comment
Share on other sites

  • Moderators

Jkeith247,

Basically, I am searching for a way to take all elements of a single array and make them into one long string....

Then perhaps:

_ArrayToString - Places the elements of an array into a single string, separated by the specified delimiter

might be the solution? :graduated:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

HAHA! That did the trick!

Thank you very much for the help! I think I may need to get out of the habit of using the online documentation and start using the help file more. I wish I saw that yesterday, as this would have made life way easier. Thank you so much!

Link to comment
Share on other sites

  • Moderators

Jkeith247,

My pleasure. :graduated:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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...