Olsson Posted November 13, 2008 Share Posted November 13, 2008 Hi guys! I've searched around and look in the help for anything that could help me create a queue list. I haven't found really what I'm looking for so I'm turning to you guys. I'm not looking for you to make it for me, but I'd love ideas, example code and anything that could help me with this. I want the list to look and function like this: QUEUE ITEM #1 QUEUE ITEM #2 QUEUE ITEM #3 QUEUE ITEM #4 When #1 is done, the second one "starts". Ex. Build <Building> Build <Building #2> Train 100 <unit> Train 10 <unit #2> Thanks for any links/posts. Thanks, Olsson Link to comment Share on other sites More sharing options...
martin Posted November 14, 2008 Share Posted November 14, 2008 Hi guys!I've searched around and look in the help for anything that could help me create a queue list. I haven't found really what I'm looking for so I'm turning to you guys. I'm not looking for you to make it for me, but I'd love ideas, example code and anything that could help me with this.I want the list to look and function like this:QUEUE ITEM #1QUEUE ITEM #2QUEUE ITEM #3QUEUE ITEM #4When #1 is done, the second one "starts".Ex.Build <Building>Build <Building #2>Train 100 <unit>Train 10 <unit #2>Thanks for any links/posts.Thanks,OlssonNot enough information for me to understand what you need.Is the list being added to while the list is being dealt with? How is the list created? The example doesn't make sense to me.New items in a list could be added to an array or a listbox. Items can be dealt with by reading the first element in the array then either incrementing a variable which indicates the next item to deal with or moving all the elements down one place so what was the second item becomes the first and so on. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Olsson Posted November 14, 2008 Author Share Posted November 14, 2008 Well, the item's are added through buttons and inputs via an GUI, when I click Button #1 It's action will be added to Item #1 in the list. I would like it to be shown in a GUI, not only behind the curtains. Thank you. Olsson Link to comment Share on other sites More sharing options...
jvanegmond Posted November 14, 2008 Share Posted November 14, 2008 That will be $20 please. expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> Global $Queue[1] #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 464, 300, 193, 115) $Group1 = GUICtrlCreateGroup("Action Queue", 5, 5, 455, 290) $Label1 = GUICtrlCreateLabel("Current action: ", 15, 25, 76, 17) $Label2 = GUICtrlCreateLabel("", 93, 23, 340, 21, -1, $WS_EX_CLIENTEDGE) GUICtrlSetBkColor(-1, 0xFFFFFF) $Label3 = GUICtrlCreateLabel("Remaining actions:", 15, 50, 94, 17) $List1 = GUICtrlCreateList("", 15, 70, 431, 201) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $myBuilding1 = _AddToQueue( "Build <Building>" ) $myBuilding2 = _AddToQueue( "Build <Building #2>" ) $myUnit1 = _AddToQueue( "Train 100 <unit>") $myUnit2 = _AddToQueue( "Train 10 <unit #2>" ) $start = TimerInit() $disable = False While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch If ( Not $disable AND TimerDiff($start) > 2000 ) Then _RemoveFromQueue($myBuilding1) $disable = True EndIf WEnd Func _AddToQueue($sText) Local $i = UBound($Queue) ReDim $Queue[$i+1] $Queue[$i] = $sText _RebuildQueue() EndFunc Func _RemoveFromQueue($iID) Local $newQueue[UBound($Queue)-1] For $n = 2 to UBound($Queue)-1 $newQueue[$n-1] = $Queue[$n] Next $Queue = $newQueue _RebuildQueue() EndFunc Func _RebuildQueue() Local $i = UBound($Queue) GUICtrlSetData($List1,"") If ( $i > 1 ) Then GUICtrlSetData($Label2,$Queue[1]) Else GUICtrlSetData($Label2,"Idle") EndIf If ( $i > 2 ) Then For $n = 2 to UBound($Queue)-1 GUICtrlSetData($List1,$Queue[$n]) Next EndIf EndFunc github.com/jvanegmond Link to comment Share on other sites More sharing options...
SkinnyWhiteGuy Posted November 14, 2008 Share Posted November 14, 2008 Another way to do a queue. I like this one mainly because, if you use Manadar's method, if you insert/remove a lot, or your list gets long, it's going to take longer and longer due to it having to rebuild the array after each time. This method only rebuilds the array when it gets too full. You'll have to add your own GUI code, I do less and less with GUI's these days. Global $g_size = 100 Global $g_front = 0 Global $g_count = 0 Global $g_queue[$size] Func _Push($item) If $g_size = $g_count Then Local $temp[Floor(UBound($g_queue) * 1.5)] Local $count = $g_count, $i = 0 $g_size = UBound($temp) While $g_count > 0 $temp[$i] = _Top() $i += 1 _Pop() WEnd $g_queue = $temp $g_count = $count $g_front = 0 EndIf $g_queue[Mod(($g_front + $g_count), $g_size)] = $item $g_count += 1 EndFunc Func _Pop() If $g_count > 0 Then $g_count -= 1 $g_front += 1 If $g_front = $g_size Then $g_front = 0 EndIf EndFunc Func _Top() Return $g_queue[$g_front] EndFunc Link to comment Share on other sites More sharing options...
jvanegmond Posted November 14, 2008 Share Posted November 14, 2008 Another way to do a queue. I like this one mainly because, if you use Manadar's method, if you insert/remove a lot, or your list gets long, it's going to take longer and longer due to it having to rebuild the array after each time.Or use _ArrayPop and _ArrayPush. I didn't feel I needed it, but looking back at it I do need to ... github.com/jvanegmond Link to comment Share on other sites More sharing options...
SkinnyWhiteGuy Posted November 14, 2008 Share Posted November 14, 2008 You and your fancy, already made includes included with AutoIt... Link to comment Share on other sites More sharing options...
Olsson Posted November 24, 2008 Author Share Posted November 24, 2008 Thanks for the help guys! Been away, but I'll try it and get back too you! 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