Topher Posted March 16, 2012 Share Posted March 16, 2012 It seems straight forward but the code below does not exit when $lhDeActivate button is pressed. What am I not seeing? Func SectorSensors() Local $lMsg, $lTemp Local $lhScan = GUICreate("Sector Sensors", 600, 460, -1, -1, $WS_CAPTION, -1, $ghComputer) ;BitOR($WS_CAPTION, $WS_SYSMENU)) Local $lhDeActivate = GUICtrlCreateButton("Done", 500, 420, 80, 23) Local $lhFunctions = GUICtrlCreateCombo("Sector Scan - 5 Units", 80, 60, 200, 30, BitOR($CBS_SIMPLE, $CBS_SORT, $CBS_DROPDOWNLIST, $WS_VSCROLL)) ; GUICtrlSetData($lhFunctions, "") ; add other items GUICtrlCreateLabel("Location: ", 25, 35) $lTemp = EncodeLocation($gCurrentX, $gCurrentY, $gCurrentZ, $gCurrentSX, $gCurrentSY, $gCurrentSZ) GUICtrlCreateLabel($lTemp, 80, 30, 200) GUICtrlSetFont(-1, 12, 600) GUICtrlCreateLabel("Objects: ", 25, 65) Local $lhScan = GUICtrlCreateButton("Scan", 300, 60, 80, 23) GUISetState() Do $lMsg = GUIGetMsg() If $lMsg = $lhScan Then Switch GUICtrlRead($lhFunctions) Case "Sector Scan" SectorScan() EndSwitch EndIf Until $lMsg = $lhDeActivate GUIDelete($lhScan) EndFunc [left][hr] $mood = "whimsy" $mode = "confused" $randomChaos = True Do Something() Until $Tired[/left][left]Reflex (Arcade game)[/left][left]IX (Board game)[/left][left]The Word Game (Word game)[/left][left]Plastic Sliding Squares Puzzle (Puzzle)[/left] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 16, 2012 Moderators Share Posted March 16, 2012 Topher,It does for me. But it will not work if you are within the EncodeLocation or SectorScan functions. Try adding some errorchecking code to show when you enter and leave those functions and see if that is indeed the problem. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
BrewManNH Posted March 16, 2012 Share Posted March 16, 2012 I'm guessing that whatever you're doing in Sectorscan isn't returning to your message loop, or is taking a long time to return to this function. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Topher Posted March 16, 2012 Author Share Posted March 16, 2012 Those routines are currently just empty functions. It works for you? Do you mind if I post the whole code? It isn't very long yet. [left][hr] $mood = "whimsy" $mode = "confused" $randomChaos = True Do Something() Until $Tired[/left][left]Reflex (Arcade game)[/left][left]IX (Board game)[/left][left]The Word Game (Word game)[/left][left]Plastic Sliding Squares Puzzle (Puzzle)[/left] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 16, 2012 Moderators Share Posted March 16, 2012 Topher, Please do. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Topher Posted March 16, 2012 Author Share Posted March 16, 2012 Thank you. Feel free to critique the coding style as well expandcollapse popup; AutoIt Version: 3.0 ; Language: English ; Platform: Win9x/NT ; Author: Garth Bigelow <garthabigelow@gmail.com> ; Modified: ; ; Script Function: ; A space trading game ; ; Changes ; - #NoTrayIcon Opt("MustDeclareVars", 1) #include <Array.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #Include <Misc.au3> #include <WindowsConstants.au3> Global Const $gcFileName = "Starflight" Global Const $gcFileNameVersion = $gcFileName & " ver 0.0.1" ; Always placed here so I can easily change the version number. Global Const $gcFileNameShip = $gcFileName & ".ship" ; Ship Structure File Name Global Const $gcFileNameUniverse = $gcFileName & ".uni" ; Galaxy Database File Name Global Const $gcFileNameIni = $gcFileName & ".ini" ; Global Const $gcMsgBoxStop = 262144 + 16 + 0 Global Const $gcMsgBoxWhat = 262144 + 32 + 4 Global Const $gcMsgBoxWhoa = 262144 + 48 + 0 Global Const $gcMsgBoxInfo = 262144 + 64 + 0 Global Const $gcGalaxySize = 40 Global Const $gcSectorSize = 20 Global Const $gcLineSep = chr(164) ; Sector Coords of Ship ; Sector Coord passing variables Global $gX, $gY, $gZ, $gSX, $gSY, $gSZ ; Computer GUI handle Global $ghComputer ; The Ship Global $gCurrentX = 0, $gCurrentY = 0, $gCurrentZ = 0, $gCurrentSX = 8, $gCurrentSY = -10, $gCurrentSZ = 5 Global $gShipEnergy = 200 Global $gShipDateTime = 0 Global $gShipName = "Sally" ; Only allow one instance of the program If _Singleton($gcFileNameVersion, 1) = 0 Then WinActivate($gcFileNameVersion) MsgBox(0, "Multiple Instance Error", "This program is already running.") Exit EndIf ; create the universe if needed If FileExists($gcFileNameUniverse) = 0 Then BigBang() ; first time running so make the galazy Endif If FileExists($gcFileNameIni) = 0 Then If IniWrite($gcFileNameIni, "Main","Universe", 1) = 0 Then ErrorStop(@ScriptLineNumber, "Can't create the Ini file") Endif LoadUniverseToArray() SetupComputer() ; ; ; Func SetupComputer() Local $lMsg, $lTemp, $lhSector $ghComputer = GUICreate("Ship's Computer (Sally)", 600, 500, -1, -1, BitOR($WS_CAPTION, $WS_SYSMENU)) GUICtrlCreateLabel("Location: ", 25, 35) $lTemp = EncodeLocation($gCurrentX, $gCurrentY, $gCurrentZ, $gCurrentSX, $gCurrentSY, $gCurrentSZ) $lhSector = GUICtrlCreateLabel($lTemp, 80, 30, 200) ; DecodeLocation($lTemp) GUICtrlSetFont(-1, 12, 600) GUICtrlCreateLabel("Functions: ", 25, 65) Local $lhFunctions = GUICtrlCreateCombo("Sector Sensors", 80, 60, 200, 30, BitOR($CBS_SIMPLE, $CBS_SORT, $CBS_DROPDOWNLIST, $WS_VSCROLL)) GUICtrlSetData($lhFunctions, "Idle|QB Transceiver|Long Range Sensors|QB Drive|Thrusters|Slipstream Generators|Cargo Containers|Maglinker Bases|Life Support") ; add other item snd set a new default Local $lhActivate = GUICtrlCreateButton("Activate", 300, 60, 80, 23) GUISetState() Do $lMsg = GUIGetMsg() If $lMsg = $lhActivate Then Switch GUICtrlRead($lhFunctions) Case "Sector Sensors" SectorSensors() Case "QB Drive" QBDrive() GUICtrlSetData($lhSector, EncodeLocation($gCurrentX, $gCurrentY, $gCurrentZ, $gCurrentSX, $gCurrentSY, $gCurrentSZ)) EndSwitch EndIf Until $lMsg = $GUI_EVENT_CLOSE GUIDelete($ghComputer) EndFunc ; ; Main Computer Functions ; Func QBDrive() If MsgBox($gcMsgBoxWhat, "QB Drive","Activating the QB Drive will deposit this ship into a random location." & @CRLF & "Activate?") = 6 Then $gCurrentX = Rand($gcGalaxySize) - ($gcGalaxySize/2) $gCurrentY = Rand($gcGalaxySize) - ($gcGalaxySize/2) $gCurrentZ = Rand($gcGalaxySize) - ($gcGalaxySize/2) $gCurrentSX = Rand($gcSectorSize) - ($gcSectorSize/2) $gCurrentSY = Rand($gcSectorSize) - ($gcSectorSize/2) $gCurrentSZ = Rand($gcSectorSize) - ($gcSectorSize/2) Return EndIf EndFunc Func SectorSensors() Local $lMsg, $lTemp Local $lhScan = GUICreate("Sector Sensors", 600, 460, -1, -1, $WS_CAPTION, -1, $ghComputer) ;BitOR($WS_CAPTION, $WS_SYSMENU)) Local $lhDeActivate = GUICtrlCreateButton("Done", 500, 420, 80, 23) Local $lhFunctions = GUICtrlCreateCombo("Sector Scan - 5 Units", 80, 60, 200, 30, BitOR($CBS_SIMPLE, $CBS_SORT, $CBS_DROPDOWNLIST, $WS_VSCROLL)) ; GUICtrlSetData($lhFunctions, "") ; add other items GUICtrlCreateLabel("Location: ", 25, 35) $lTemp = EncodeLocation($gCurrentX, $gCurrentY, $gCurrentZ, $gCurrentSX, $gCurrentSY, $gCurrentSZ) GUICtrlCreateLabel($lTemp, 80, 30, 200) GUICtrlSetFont(-1, 12, 600) GUICtrlCreateLabel("Objects: ", 25, 65) Local $lhScan = GUICtrlCreateButton("Scan", 300, 60, 80, 23) GUISetState() Do $lMsg = GUIGetMsg() If $lMsg = $lhScan Then Switch GUICtrlRead($lhFunctions) Case "Sector Scan" SectorScan() EndSwitch EndIf Until $lMsg = $lhDeActivate GUIDelete($lhScan) EndFunc ; ; Main Computer sub functions ; Func SectorScan() EndFunc ; ; Initialize the universe's stars and planets ; Func BigBang() Local $lX, $lY, $lZ, $lSX, $lSY, $lSZ, $lTemp ; Local $lNumberOfStars = 2000 + Rand(1200) ; between 2000 and 3200 stars (from 1 sector in 20 to 1 in 32) Local $lNumberOfStars = 200 + Rand(120) ; between 2000 and 3200 stars (from 1 sector in 20 to 1 in 32) Local $lFile = FileOpen($gcFileNameUniverse, 2) ;WriteErase + Binary If $lFile = -1 Then ErrorStop(@ScriptLineNumber, "Can't create Galaxy File") Earth($lFile) For $lSector = 0 To $lNumberOfStars $lX = Rand($gcGalaxySize) - ($gcGalaxySize/2) $lY = Rand($gcGalaxySize) - ($gcGalaxySize/2) $lZ = Rand($gcGalaxySize) - ($gcGalaxySize/2) $lSX = Rand($gcSectorSize) - ($gcSectorSize/2) $lSY = Rand($gcSectorSize) - ($gcSectorSize/2) $lSZ = Rand($gcSectorSize) - ($gcSectorSize/2) $lTemp = "*" & $gcLineSep $lTemp &= $lX & $gcLineSep $lTemp &= $lY & $gcLineSep $lTemp &= $lZ & $gcLineSep $lTemp &= $lSX & $gcLineSep $lTemp &= $lSY & $gcLineSep $lTemp &= $lSZ & $gcLineSep $lTemp &= 0 If FileWriteLine($lFile, $lTemp) = 0 Then ErrorStop(@ScriptLineNumber, "Can't write Star to Galaxy File") BigBangPlanets($lX, $lY, $lZ, $lFile) Next If FileClose($lFile) = 0 Then ErrorStop(@ScriptLineNumber, "Can't close Galaxy File") EndFunc ; ; initialize the planets of a sector with a sun ; Func BigBangPlanets($pX, $pY, $pZ, $pFile) Local $lSX, $lSY, $lSZ, $lTemp ; determine number of planets from 0 to 9 weighted toward 0 to 5 Local $lNumberofPlanets = Rand(10) - Rand(4) if $lNumberofPlanets < 0 Then $lNumberofPlanets = Rand(4) + Rand(2) ; create location of planets For $lSector = 1 To $lNumberOfPlanets $lSX = Rand($gcSectorSize) - ($gcSectorSize/2) $lSY = Rand($gcSectorSize) - ($gcSectorSize/2) $lSZ = Rand($gcSectorSize) - ($gcSectorSize/2) $lTemp = "P" & $gcLineSep $lTemp &= $pX & $gcLineSep $lTemp &= $pY & $gcLineSep $lTemp &= $pZ & $gcLineSep $lTemp &= $lSX & $gcLineSep $lTemp &= $lSY & $gcLineSep $lTemp &= $lSZ & $gcLineSep $lTemp &= 0 If FileWriteLine($pFile, $lTemp) = 0 Then ErrorStop(@ScriptLineNumber, "Can't write Planet to Galaxy File") Next EndFunc ; ; add the Sol system with its nine planets in the center of the universe ; Func Earth($pFile) Local $lSX, $lSY, $lSZ, $lTemp $lTemp = "*" & $gcLineSep $lTemp &= 0 & $gcLineSep $lTemp &= 0 & $gcLineSep $lTemp &= 0 & $gcLineSep $lTemp &= 0 & $gcLineSep $lTemp &= 0 & $gcLineSep $lTemp &= 0 & $gcLineSep $lTemp &= 0 If FileWriteLine($pFile, $lTemp) = 0 Then ErrorStop(@ScriptLineNumber, "Can't write Sol to Galaxy File") For $a = 1 to 8 $lSX = Rand($gcSectorSize) - ($gcSectorSize/2) $lSY = Rand($gcSectorSize) - ($gcSectorSize/2) $lSZ = Rand($gcSectorSize) - ($gcSectorSize/2) $lTemp = "P" & $gcLineSep $lTemp &= 0 & $gcLineSep $lTemp &= 0 & $gcLineSep $lTemp &= 0 & $gcLineSep $lTemp &= $lSX & $gcLineSep $lTemp &= $lSY & $gcLineSep $lTemp &= $lSZ & $gcLineSep $lTemp &= 0 If FileWriteLine($pFile, $lTemp) = 0 Then ErrorStop(@ScriptLineNumber, "Can't write Planet to Galaxy File") Next ; Earth $lTemp = "P" & $gcLineSep $lTemp &= 0 & $gcLineSep $lTemp &= 0 & $gcLineSep $lTemp &= 0 & $gcLineSep $lTemp &= $gCurrentSX & $gcLineSep $lTemp &= $gCurrentSY & $gcLineSep $lTemp &= $gCurrentSZ & $gcLineSep $lTemp &= 0 If FileWriteLine($pFile, $lTemp) = 0 Then ErrorStop(@ScriptLineNumber, "Can't write Planet to Galaxy File") EndFunc ; ; Coordinates of Objects in the universe copied into memory ; Enables scans and such ; Func LoadUniverseToArray() Local $lItem, $lCount, $lTemp, $lArray Local $lFile = FileOpen($gcFileNameUniverse, 0) ; read only If $lFile = -1 Then ErrorStop(@ScriptLineNumber, "Can't open Galaxy File") ; Determine Number of Objects in the universe ; to determione the size of the array $lCount = 0 ProgressOn("Activating Computer","Boot Sequence") While True FileReadLine($lFile) If @error = -1 Then ExitLoop $lCount += 1 WEnd ; load objects into computer array Local $lProgressUnit = $lCount / 100 Dim $lArray[$lCount][8] ProgressOn("Computer Boot Sequence","Accessing Universal Database", "Please Wait") Local $lLastUnit = 0 For $a = 1 To $lCount Local $lBlock = int($a/$lProgressUnit) If $lLastUnit <> $lBlock Then ProgressSet($lBlock) $lLastUnit = $lBlock EndIf $lItem = FileReadLine($lFile, $a) $lTemp = StringSplit($lItem, $gcLineSep, 2) For $b = 0 To 7 $lArray[$a-1][$b] = $lTemp[$b] Next Next ProgressOff() If FileClose($lFile) = 0 Then ErrorStop(@ScriptLineNumber, "Can't close Galaxy File") EndFunc ; ; Turn Coordinates into Display form ; Func EncodeLocation($pX, $pY, $pZ, $pSX, $pSY, $pSZ) Local $lTemp = $pX & "." & $pY & "." & $pZ & "/" & $pSX & "." & $pSY & "." & $pSZ Return $lTemp EndFunc ; ; Turn Entry format Coordinates in Coordinates ; Func DecodeLocation($pLocationString) Local $lCoords = StringSplit($pLocationString, "./") msgbox(0,"",$lCoords[0]) If $lCoords <> 6 Then return False $gX = $lCoords[1] $gY = $lCoords[2] $gZ = $lCoords[3] $gSX = $lCoords[4] $gSY = $lCoords[5] $gSZ = $lCoords[6] Return True EndFunc ; ; bend random() function to my needs ; Func Rand($pMax) Return Random(0, $pMax, 1) EndFunc ; ; System Error ; Display offending line and message ; then exit the program ; Func ErrorStop ($pLineNumber, $pLine) MsgBox($gcMsgBoxStop, "Error at " & $pLineNumber, $pLine) Exit EndFunc [left][hr] $mood = "whimsy" $mode = "confused" $randomChaos = True Do Something() Until $Tired[/left][left]Reflex (Arcade game)[/left][left]IX (Board game)[/left][left]The Word Game (Word game)[/left][left]Plastic Sliding Squares Puzzle (Puzzle)[/left] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 16, 2012 Moderators Share Posted March 16, 2012 Topher, Look carefully at this section: Func SectorSensors() Local $lMsg, $lTemp Local $lhScan = GUICreate("Sector Sensors", 600, 460, -1, -1, $WS_CAPTION, -1, $ghComputer) ;BitOR($WS_CAPTION, $WS_SYSMENU)) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Local $lhDeActivate = GUICtrlCreateButton("Done", 500, 420, 80, 23) Local $lhFunctions = GUICtrlCreateCombo("Sector Scan - 5 Units", 80, 60, 200, 30, BitOR($CBS_SIMPLE, $CBS_SORT, $CBS_DROPDOWNLIST, $WS_VSCROLL)) ; GUICtrlSetData($lhFunctions, "") ; add other items GUICtrlCreateLabel("Location: ", 25, 35) $lTemp = EncodeLocation($gCurrentX, $gCurrentY, $gCurrentZ, $gCurrentSX, $gCurrentSY, $gCurrentSZ) GUICtrlCreateLabel($lTemp, 80, 30, 200) GUICtrlSetFont(-1, 12, 600) GUICtrlCreateLabel("Objects: ", 25, 65) Local $lhScan = GUICtrlCreateButton("Scan", 300, 60, 80, 23) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUISetState() Do you notice anything about the variables assigned in the 2 lines I have marked? M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Topher Posted March 16, 2012 Author Share Posted March 16, 2012 I knew it was something simple (although hard to spot) thank you very much for your help [left][hr] $mood = "whimsy" $mode = "confused" $randomChaos = True Do Something() Until $Tired[/left][left]Reflex (Arcade game)[/left][left]IX (Board game)[/left][left]The Word Game (Word game)[/left][left]Plastic Sliding Squares Puzzle (Puzzle)[/left] 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