Jump to content

CASE glitch


Recommended Posts

im almost possitive this is where the case should be... yet it does the case staement without the button even being pressed.. any help guys?

here is my code (long, not as ong as it used to be :mellow:)

look for the [HERE]>>> thing thats where im having troubles

#cs ----------------------------------------------------------------------------

AutoIt Version: 3.2.12.0
Author:   BOB

Script Function: GUI information organizer
    Template AutoIt script.

#ce ----------------------------------------------------------------------------
;This is made by BOB
;(bob00037 on the autoitforums)
; This script Is An Information Organizer For The Not Very Widely Known MMORPG Endless Online;
#include <GuiConstantsEx.au3>
#Include <GuiListView.au3>
#include <ButtonConstants.au3>
#include <GuiConstants.au3>
#include <Editconstants.au3>

#NoTrayIcon
DirCreate("C:\GUILDINFO")
If FileExists("C:\guildinfo\Guild.ini") Then
    
Else
    MsgBox(64,"no", "Does NOT exists")
    IniWrite("C:\GUILDINFO\Guild.ini", "Help", "#", "*****this is a help guide on the controlls of GI******                                                                                                                                                                                      #[For Each editbox hitting ENTER will call a function]                                            #[top right [X]=exit\OR\ ALT+f4=exit]                                                                         #[CANNOT edit the list box BUT just add a member then Delete it when you need to edit it, then add again]                                                                                        #[DO NOT change the directory outputs (i have not designed it to be user friendly)]")
    IniWrite("C:\guildinfo\Guild.ini", "Personal", "#Text", "0")
    IniWrite("C:\guildinfo\Guild.ini", "CurrentMembers", "#Current", "0")
    IniWrite("C:\guildinfo\Guild.ini", "Personal", "#Rules", "0")
    IniWrite("C:\guildinfo\Guild.ini", "ACCOUNT", "#1", "0")
    MsgBox(64,"NOW", "it exists")
    
    
EndIf
#region; GLOBAL VARS
#Region; GI GUI
Global $GUI;GUI

Global $Pdt, $PSv, $Ldbtn, $Pdtdr, $INIp, $OpnDrb, $OpnDrI, $hlp, $INIh, $Rules, $Lrules, $SRules

Global $Delcm, $AdRcm, $Adrcm2, $Addcm, $listview, $Listview2, $INIcm, $Cmdt, $Cmld, $listedit, $CmSv, $Cmsv2, $CmLd, $CmLd2, $Cmcount, $Cmmemup, $CmMemCount, $Cmupdate, $noitemsm

Global $USERname, $USERL
#EndRegion

#Region;ACC GUI
Global $ACC
Global $USER, $UPASS, $USERp, $USERn, $USERp2, $USERn2, $REGacc, $REGpass, $cancelacc, $USERRead
#EndRegion

#Region; REG GUI
Global $REG; GUI
Global $REGnamereg, $REGpassreg, $REGREG
#EndRegion
#EndRegion

$ACC = GUICreate("LOGIN\REGISTER",200,100)
$USER = GUICtrlCreateInput("USERNAME",0,0,200,20)
$UPASS = GuictrlcreateInput("PASSWORD",0,20,200,20,$ES_PASSWORD)
$Login = GUICtrlCreateButton("LOGIN", 0,40,200,20)
$REGbtn = GUICtrlCreateButton("REGISTER",0,60,200,20)
$Cancelacc = GUICtrlCreateButton("CANCEL",0,80,200,20)
GUICtrlSetData($USERRead, iniReadSection("guild.ini", "[ACCOUNT]"))
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
           Exit
        Case $cancelacc
            AutoItSetOption ( "GUICloseOnESC" )
            Send("{ESC}")
        Case $REGbtn;REGISTERATION gui
            GUIDelete($ACC)
            GUICreate($REG,200,60)
            $REGnamereg = GUICtrlCreateInput("account name",0,0,200,20)
            $REGpassreg = GUICtrlCreateInput("password",0,20,200,20,$ES_PASSWORD)
            $REGREG = GUICtrlCreateButton("REGISTER",0,40,200,20)
            GUISetState(@SW_SHOW)
[HERE]>>>>>>>Case $REGREG
                IniWrite("guild.ini","ACCOUNT","ACC",GUICtrlRead($REGnamereg))
                IniWrite("Guild.ini","ACCOUNT","Pass",GUICtrlRead($REGpassreg))
                MsgBox(0,"","Please run GI again")
        Case $Login
            $inipass = Iniread("guild.ini","ACCOUNT","ACC","")
            If $inipass = guictrlread($UPASS) Then
            MsgBox(0,"","ACCEPTED")
            else
            MsgBox(0,"","DECLINED")
    EndIf
    #region; GUI
$GUI = GuiCreate("GI    (Guild Information)   VERSION 0.00005", 400, 400)
GuiSetIcon(@SystemDir & "\mspaint.exe", 0)
GUIDelete($ACC)
#EndRegion

    #Region; PIC
GuiCtrlCreatePic("guild.bmp",0,0, 399,79)
#EndRegion

    #Region; Personal TAB
GuiCtrlCreateTab(0, 80)
GuiCtrlCreateTabItem("Personal")


_vars()
Func _vars()

    $PSv = GuiCtrlCreateButton("SAVE", 0, 360, 400, 20); The "save" button on the personal tab
    $OpnDrB = GuiCtrlCreateButton("OPEN DIR", 300, 315, 100, 20);  The "OPEN" button on the personal tab
    $Ldbtn = GUICtrlCreateButton("LOAD", 300, 335,100,20); The "load" button on the personal tab
    $hlp = GUICtrlCreateButton("HELP", 200, 380, 200,20); HELP button for the help file
    $Pdtdr = GUICtrlCreateInput("C:\guildinfo\guild.ini", 0, 335, 300, 20); The DIRECTORY input for LOAD on the personal tab
    $Pdt = GUICtrlCreateEdit(" ", 0, 130, 400, 175, $ES_MULTILINE);The BIG input on the personal tab
    $OpnDrI = GUICtrlCreateInput("C:\guildinfo", 0, 315, 300, 20); The DIRECTORY input for OPEN DIR on the personal tab
    $INIp = IniRead("Guild.ini", "personal", "#text", ""); The [personal] .ini text readback call
    $INIh = IniRead("Guild.ini", "Help", "#", ""); The [help] .ini text readback call
    $Lrules = GUICtrlCreateButton("LOAD RULES",5,105,195,20)
    $Srules = GUICtrlCreateButton("SAVE RULES",202,105,195,20)
    $Rules = Iniread("guild.ini", "Personal", "#Rules","")
    
EndFunc

; DATE
#Region
GuiCtrlCreateDate("", 0, 380, 200, 20)
#EndRegion
#EndRegion


    #Region;Guild TAB
GuiCtrlCreateTab(0, 80)
GuiCtrlCreateTabItem("Guild")

#Region; DATE
GuiCtrlCreateDate("", 0, 380, 200, 20)
#EndRegion


#Region
_vars2()
Func _vars2()
    GUICtrlSetState(-1, $GUI_DROPACCEPTED); to allow drag and dropping
    $CmMemCount = GUICtrlCreateEdit("0", 0, 130, 224, 20)
    $Adrcm = GuiCtrlCreateInput("Name|0|0|0|0", 0, 110, 224, 20)
    $Delcm = GuiCtrlCreateButton("Delete", 306, 110, 80, 20)
    $Addcm = GuiCtrlCreateButton("Add ", 226, 110, 80, 20)
    $listview = GuiCtrlCreateListView("Member|Rank|Warnings|Test Taken|Gone", 0, 150, 399, 200, BitOR($LVS_EDITLABELS, $LVS_EX_GRIDLINES))
    $Listview2 = GUICtrlRead($listview)
    $Adrcm2 = GUICtrlRead( $Adrcm )
    $CmSv = GUICtrlCreateButton("SAVE", 0, 360, 197, 18)
    $Cmld = GUICtrlCreateButton("LOAD", 198, 360, 200, 18)
    $Cmupdate = GUICtrlCreateButton("UPDATE", 226,130,160,20)
    $CMmemup = IniRead("guild.ini", "CurrentMembers", "Itemcount", "default")

EndFunc
#EndRegion
#EndRegion

    #Region; USER TAB
    GUICtrlCreateTab(0, 80)
    GUICtrlCreateTabItem("USER")
    GUISetState(@SW_SHOW)
    GUICtrlCreateLabel("Welcome,",150,85,250,20)
    GUICtrlCreateLabel(IniRead("guild.ini","ACCOUNT","ACC",""), 200,85,250,20)
    AutoItSetOption ("GUICloseOnESC" )
    #EndRegion
        Case $PSv; PERSONAL
            Iniwrite("guild.ini", "personal", "#text", GUICtrlRead($Pdt))
        Case $Ldbtn
        GUICtrlSetData ( $Pdt, $INIp )
        Case $OpnDrB
            MsgBox( 0, "OPEN?", "UDF Directory" )
        Case $hlp
            MsgBox(0,"Help?", "UDF file",GUICtrlRead($Pdtdr))
            GUICtrlSetData ( $Pdt, $INIh )
        Case $LRules
            GUICtrlSetData($Pdt, $Rules)
        CASE $Srules
            iniwrite("guild.ini","personal","#rules", GUICtrlRead($Pdt))
        Case $Addcm; GUILD
            GUICtrlCreateListViewItem( GUICtrlRead( $Adrcm ), $listview)
        Case $Delcm
            _GUICtrlListView_DeleteItemsSelected($Listview)
        Case $CmSv
             if FileExists("guild.ini") then IniDelete("guild.ini","CurrentMembers")
            IniWrite("guild.ini","CurrentMembers","ItemCount",_GUICtrlListView_GetItemCount($listview))
            For $n = 0 To _GUICtrlListView_GetItemCount($listview) - 1
                $Itemtext = _GUICtrlListView_GetItemText($listview, $n)
                For $p = 1 To 5;for each column
                    $Itemtext &= '|' & _GUICtrlListView_GetItemText($listview, $n,$p)
                Next
                IniWrite("Guild.ini","CurrentMembers",$n,$Itemtext)
            Next
        Case $CmLd
        For $i = 0 to 300
            GUICtrlCreateListViewItem((INIread("guild.ini", "CurrentMembers", $i, "")), $Listview )
        Next
    EndSwitch
WEnd
Edited by bob00037
Link to comment
Share on other sites

Well, first off, at the bottom of your script is your WEnd. So, everytime it loops, it is recreating EVERYTHING (functions and all). Second off, your Switch statment is ended with an EndIF instead of EndSwitch.

From there you got some more clean up to do.

#1=yes i know #2= if you look closely et the Very end of the script is the ENDswitch... the endif statement just didnt get indented.. my bad

First, Define var $ACCOUNT

Second, Insert item, $ACCOUNT = GUICtrlCreateButton("ACCOUNT",0,100,200,20)

Then, Resize '$ACC' GUICreate()

Then, Case $REGREG => Case $ACCOUNT

Good luck to you :-)

and i will try this ty guys for answering me :mellow:

.... and BTW when i delete the $REGREG case everything works fine.. except the funcs i need to happen in the $REGREG case dont :\..... but otherwise everything else is fine

[EDIT]

uhh yeah it doesnt work

Edited by bob00037
Link to comment
Share on other sites

#1=yes i know #2= if you look closely et the Very end of the script is the ENDswitch... the endif statement just didnt get indented.. my bad

and i will try this ty guys for answering me :mellow:

.... and BTW when i delete the $REGREG case everything works fine.. except the funcs i need to happen in the $REGREG case dont :\..... but otherwise everything else is fine

[EDIT]

uhh yeah it doesnt work

When you declare

$Global $REGnamereg, $REGpassreg, $REGREG

then $REGREG will be "" untill the button is created, so if there is no event and $nMsg = 0 then that case will be called.

So in your case have this

Case $REGREG
                If $REGREG <> 0 then
                    IniWrite("guild.ini","ACCOUNT","ACC",GUICtrlRead($REGnamereg))
                    IniWrite("Guild.ini","ACCOUNT","Pass",GUICtrlRead($REGpassreg))
                    MsgBox(0,"","Please run GI again")
                EndIf

Also, you will make your own life a lot easier if you organize you script a bit more. Get all the functions out of the switch loop for example and use Ctrl T if you use SciTE to tidy it.

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

hmmm ill try to do that.. but the reason i have everything in the switch is because when i hit LOGIN i want it to show the next gui(main script) and when i hit REGISTER i wawnt it to bring up a smaller registration gui.... ill try that bit of code you put up ill reply in a few hours since im at school atm :mellow:

Link to comment
Share on other sites

ok thanks man lol that woked now i got it exactly the way i want.... why did i have to put the case $REGREG <>0 ??? what does this signify? so i can learn in the futre

EDIT

damnit... now whenever i put in guidelete($ACC) right after the $REGREG case... everything is fine untill i hit save on one of the tabs then it always calls the case statements from $REGREG.. why? and how do i delete the gui without having the save case messed up... and BTW does the <>0 check if the button action is false or true? thats what the help fle said.... lol yet another problem

Edited by bob00037
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...