Ok - I was putting the finishing touches on the v1 of the EQ2Megabot buffbot and added a few buttons to help with some things you can do while the script is running and all heck broke loose! My script was crashing all over the place, to the desktop - very frustrating.
After several hours this morning tracking it down, it appears to be the buttons causing the issue, and as usual, when I find a problem, I try to simply it and reproduce it consistently, which I have.
Below is a very simple script, it just pops up a window with a counter and a Quit button. The Quit functionality is commented out as actually quitting doesn't show the issue.
Wyv - can you please run this script and see if you can find out what is making the buttons so unstable. To make it crash consistently, simply run the script, hit the Quit Button (which does nothing right now) a few times, then hit F1, F2, F1, F2, and shortly it will crash.
When I use these functions in EQ2MegaBot - the script crashes almost immediatly after you hit a button - not good.
I know it has something to do with the handler, but I have reviewed all sample code I can find from the site and it looks like I'm doing everything right.
If you don't ever hit the Quit button, everything is good, you can't make it crash. Seems to me like some memory error with the handler, but I'm stumped.
Here is the code:
(!empty($user->lang['CODE'])) ? $user->lang['CODE'] : ucwords(strtolower(str_replace('_', ' ', 'CODE'))):
Dim QuitNow
Sub StatusBar(sTxt)
objStatusWindow.SetStatusBar(sTxt)
End Sub
Class QuitButtonHandlerClass
Public Function Accepted(nID)
StatusBar("QUITTING!!")
'QuitNow = TRUE
End Function
End Class
' =============================================================
' =============================================================
Class OutputStatusWindowClass
Private bQuit
Private Window 'The Script Window
Private StatusBar
Private szSchema
Private handler ' Handles button press
Private Sub Class_Initialize()
szSchema = ""
szSchema = szSchema & "<?xml version=""1.0""?> " + vbCrlf
szSchema = szSchema & "<XML ID=""XUInterfaceDefinitionLanguage""> " + vbCrlf
szSchema = szSchema & " <Schema xmlns=""XUnleashedData"" xmlns:dt=""XUnleashedDataTypes""/> " + vbCrlf
szSchema = szSchema & " <Window> " + vbCrlf
szSchema = szSchema & " <Title>MessageBox</Title> " + vbCrlf
szSchema = szSchema & " <Left>500</Left> " + vbCrlf
szSchema = szSchema & " <Top>20</Top> " + vbCrlf
szSchema = szSchema & " <Height>100</Height> " + vbCrlf
szSchema = szSchema & " <Width>400</Width> " + vbCrlf
szSchema = szSchema & " <DrawBackground>TRUE</DrawBackground> " + vbCrlf
szSchema = szSchema & " <CloseBox>FALSE</CloseBox> " + vbCrlf
szSchema = szSchema & " <Container> " + vbCrlf
szSchema = szSchema & " <DefaultControlContainer> " + vbCrlf
szSchema = szSchema & " <Control> " + vbCrlf
szSchema = szSchema & " <StaticText> " + vbCrlf
szSchema = szSchema & " <Name>StatusBar</Name> " + vbCrlf
szSchema = szSchema & " <Location> " + vbCrlf
szSchema = szSchema & " <X>5</X> " + vbCrlf
szSchema = szSchema & " <Y>40</Y> " + vbCrlf
szSchema = szSchema & " </Location> " + vbCrlf
szSchema = szSchema & " <Size> " + vbCrlf
szSchema = szSchema & " <CX>390</CX> " + vbCrlf
szSchema = szSchema & " <CY>40</CY> " + vbCrlf
szSchema = szSchema & " </Size> " + vbCrlf
szSchema = szSchema & " <Text>** Status Bar **</Text> " + vbCrlf
szSchema = szSchema & " </StaticText> " + vbCrlf
szSchema = szSchema & " </Control> " + vbCrlf
szSchema = szSchema & " <Control> " + vbCrlf
szSchema = szSchema & " <Button> " + vbCrlf
szSchema = szSchema & " <Name>btnQuit</Name> " + vbCrlf
szSchema = szSchema & " <Location> " + vbCrlf
szSchema = szSchema & " <X>340</X> " + vbCrlf
szSchema = szSchema & " <Y>55</Y> " + vbCrlf
szSchema = szSchema & " </Location> " + vbCrlf
szSchema = szSchema & " <Size> " + vbCrlf
szSchema = szSchema & " <CX>50</CX> " + vbCrlf
szSchema = szSchema & " <CY>16</CY> " + vbCrlf
szSchema = szSchema & " </Size> " + vbCrlf
szSchema = szSchema & " <Text>QUIT</Text> " + vbCrlf
szSchema = szSchema & " </Button> " + vbCrlf
szSchema = szSchema & " </Control> " + vbCrlf
szSchema = szSchema & " </DefaultControlContainer> " + vbCrlf
szSchema = szSchema & " </Container> " + vbCrlf
szSchema = szSchema & " <Background> " + vbCrlf
szSchema = szSchema & " <SkinImage>Window-Background</SkinImage> " + vbCrlf
szSchema = szSchema & " </Background> " + vbCrlf
szSchema = szSchema & " <Moveable>TRUE</Moveable> " + vbCrlf
szSchema = szSchema & " </Window> " + vbCrlf
szSchema = szSchema & "</XML> " + vbCrlf
Set handler = New QuitButtonHandlerClass
set Window = XUScriptPlugin.LoadWindow( szSchema )
set bQuit = XUScriptPlugin.LoadControl( Window,"btnQuit")
XUScriptPlugin.AddButtonHandler Window, "btnQuit", handler
set StatusBar = XUScriptPlugin.LoadControl(Window,"StatusBar")
Window.Title = "EQ2 MegaBot Info"
'Show the window
XUScriptPlugin.ActivateWindow Window
End Sub
Public Sub SetStatusBar(txt)
StatusBar.Text = txt
End Sub
Private Sub Class_Terminate()
Dim i
XUScriptPlugin.RemoveButtonHandler Window, "btnQuit"
XUScriptPlugin.UnloadControl bQuit
XUScriptPlugin.UnloadControl StatusBar
XUScriptPlugin.DeActivateWindow Window
XUScriptPlugin.UnloadWindow Window
set handler=NOTHING
end Sub
End Class
' =============================================================
' =============================================================
Dim i
QuitNow=FALSE
Set objStatusWindow = New OutputStatusWindowClass
i=1
Do While NOT QuitNow
StatusBar("Loop: " & i)
XUScriptHost.Sleep 1000
i = i + 1
Loop
XUScriptHost.Sleep 2000
Set objStatusWindow = NOTHING
Thanks,
Rich