Fly By Night Posted July 30, 2009 Share Posted July 30, 2009 (edited) I'm trying to build a GUI on the fly using a loop to generate the code needed. Array items are being read to get the values needed to build tabs, For $r = 0 To UBound($genreArr, 1) - 1 $tGenre = $genreArr[$r] $i = "$" & $tGenre & " = GUICtrlCreateTabItem(""" & $tGenre & """)" $j = "$" & $tGenre & "Edit = GUICtrlCreateEdit("""", 12, 33, 889, 484)" Eval($i) ; What goes here? Eval($j) ; What goes here? Next I've checked using MsgBox, $i and $j contains the strings to make the Tab elements needed in the correct format. I just used Eval in there as a placeholder but is there a function out there that can run the string like a line of code? I've tried searching for this as i'm sure it's been done loads of time but can't find the answer. Thanks. Edited July 30, 2009 by Fly By Night Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted July 30, 2009 Share Posted July 30, 2009 (edited) To "execute" a function contained in a string like that you can use Execute(). But it will most likely end up very messy, so I recommend you find a way to use arrays instead. Edited July 30, 2009 by AdmiralAlkex .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Fly By Night Posted July 30, 2009 Author Share Posted July 30, 2009 (edited) Cheers. I found what i was looking for after all. I did a search and came up with an "incremental variable names" post that provided a solution. Global $numGenres = 15 Global $genreArr[$numGenres] = ["House", "Dance", "Electronic", "Trance", "Hardstyle", "Drum_&_Bass", "Commercial", "Jumpstyle", "Pop", "Rock", "Hip-Hop", "R_&_B", "Techno", "Other", "Psychedelic"] Global $genreTabs[$numGenres], $genreEdit[$numGenres] _ArraySort($genreArr) $SBForm = GUICreate("TabsRUs", 914, 605, 193, 124) $Tab = GUICtrlCreateTab(8, 8, 897, 513) GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) For $r = 0 To UBound($genreTabs, 1) - 1 $genreTabs[$r] = GUICtrlCreateTabItem($genreArr[$r]) $genreEdit[$r] = GUICtrlCreateEdit("", 12, 33, 889, 484) Next GUICtrlCreateTabItem("") GUISetState(@SW_SHOW) Edited July 31, 2009 by Fly By Night Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now