Sign in to follow this  
Followers 0
dakishman

Pls help me on a passing loop...

6 posts in this topic

OK, my code works fine until i get to the second user interface.

#include <GUIConstants.au3>
#include <Array.au3>
;=================================================Var Definitions=========================================================================================
==========
$Word = 01101101
$Step = 0
$var = 0
$Langth = 0
$Frequancy = 0
$msg2 = 0
$Songnames = 0
$StartStopButton = 0
;=================================================Splash Screen==============================================================================================
=======


;=================================================Create Main Window==============================================================================================
==
$mainwindow = GUICreate("D/A Converter", 200, 140)
GUICtrlCreateLabel("What would you like to do?", 30, 10)

;=================================================Gui Controls In Main Window=======================================================================================
;-------------------------------------------------Ratio Button Group------------------------------------------------------------------------------------------------
GUICtrlCreateGroup ("Choose One", 10, 30, 180, 90)
$ReadFromFile = GUICtrlCreateRadio ( "Read Tones from File",15,50)
$SingleNote = GUICtrlCreateRadio ( "Create a Single Tone",15,70)
GUICtrlCreateGroup ("",-99,-99,1,1) ;close group?? Mabye beacuse it starts another that is a Dummy Group? so the other one finishes?

;-------------------------------------------------Buttons----------------------------------------------------------------------------------------------------------

$okbutton = GUICtrlCreateButton("OK", 70, 100, 60)

;-------------------------------------------------Dummy Window------------------------------------------------------------------------------------------------------
$dummywindow = GUICreate("Dummy window for testing ", 200, 100)

;-------------------------------------------------Switch to main window and display---------------------------------------------------------------------------------
GUISwitch($mainwindow)
GUISetState(@SW_SHOW)

;=================================================Gui Scan================================================================================================
==========
While 1
  $msg = GUIGetMsg(1)

  Select
      
    Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $mainwindow 
      ExitLoop
;================================================Load Digital File Option===========================================================================================      
    Case $msg[0] = $okbutton And BitAND(GUICtrlRead($ReadFromFile), $GUI_CHECKED) = $GUI_CHECKED
      $FilePath = FileOpenDialog("Choose your digital file...", @DesktopDir & "\", "Brandon Kish's Digital Files (*.BKDF)", 1)
      $Songnames = FileRead($FilePath)
      $Songnames = StringSplit($Songnames,";",1)
      GUISwitch($mainwindow)
      GUISetState(@SW_HIDE)
      $Step = 1
        ExitLoop
;================================================Create a single note===============================================================================================
    Case $msg[0] = $okbutton And BitAND(GUICtrlRead($SingleNote), $GUI_CHECKED) = $GUI_CHECKED
      
    Case $msg[0] = $okbutton
      MsgBox(0, "Error", "Please select an option...", 3)
    
  EndSelect
WEnd
;================================================End GUI Scan================================================================================================
=======

If $Step = 1 Then
;================================================Create File Control Window=========================================================================================
            
            $FileWindow = GUICreate("Digital File Converter (" & $Songnames[1] & ")", 400, 350) 
            GUISwitch($FileWindow)
            GUISetState(@SW_SHOW)
            GUICtrlCreateLabel("Brandon Kish's Digital Decoder",10,10)
            GUICtrlCreateLabel("File Progression",10,40)
            $progressbar = GUICtrlCreateProgress (10,61,380,20)
            GUICtrlCreateGroup ("Digital Line Being Decoded:", 10, 90, 380, 35)
            GUICtrlCreateLabel($Word,25,105)
            GUICtrlCreateGroup ("",-99,-99,1,1) ;close group?? Mabye beacuse it starts another that is a Dummy Group? so the other one finishes?
            GUICtrlCreateGroup ("Word Decoded Information", 10,135, 380, 35)
            GUICtrlCreateLabel("Langth:",25,150)
            GUICtrlCreateLabel($Langth,70,150)
            GUICtrlCreateLabel("Frequancy:",180,150)
            GUICtrlCreateLabel($Frequancy,250,150)
            GUICtrlCreateGroup ("",-99,-99,1,1) ;close group?? Mabye beacuse it starts another that is a Dummy Group? so the other one finishes?
        ;-----------------------------------Song List---------------------------------------------
            _ArrayDisplay ($Songnames,"name")
            $SongLength = $Songnames[0] - 1
;=================================================Gui Scan================================================================================================
==========
GUISwitch($FileWindow)
While 4                                                                                                            ;[Note 1]
  $msg = GUIGetMsg(1)

  Select
      
    Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $FileWindow 
      ExitLoop
;================================================Load Digital File Option===========================================================================================      
    Case $msg[0] = $StartStopButton
    GUICtrlSetData($StartStopButton,"Stop")
      $Step = 3
        ExitLoop
;================================================Create a single note===============================================================================================
    Case $msg[0] = $okbutton And BitAND(GUICtrlRead($SingleNote), $GUI_CHECKED) = $GUI_CHECKED
      
    Case $msg[0] = $okbutton
      MsgBox(0, "Error", "Please select an option...", 3)
    
  EndSelect
WEnd
EndIf
$Songinc = 1
If $Step = 3 Then                                                                                                                    ;[Note 2]
    $Songinc = $Songinc + 1
    $Array = StringSplit(StringStripWS($Songnames[$Songinc],3), '')
                _ArrayDisplay ($Array,"$Array")
    $Frequancy = $Array[0] * 2 ^ 0 + $Frequancy                                                                     ;Converts the 1 bit from the $Array into a Decimal form of the binary
$Frequancy = $Array[1] * 2 ^ 1 + $Frequancy                                                                     ;Converts the 2 bit from the $Array into a Decimal form of the binary
$Frequancy = $Array[2] * 2 ^ 2 + $Frequancy                                                                     ;Converts the 3 bit from the $Array into a Decimal form of the binary
$Frequancy = $Array[3] * 2 ^ 3 + $Frequancy                                                                     ;Converts the 4 bit from the $Array into a Decimal form of the binary
$Frequancy = $Array[4] * 2 ^ 4 + $Frequancy                                                                     ;Converts the 5 bit from the $Array into a Decimal form of the binary
$Frequancy = $Array[5] * 2 ^ 5 + $Frequancy                                                                     ;Converts the 6 bit from the $Array into a Decimal form of the binary
$Frequancy = $Array[6] * 2 ^ 6 + $Frequancy                                                                     ;Converts the 7 bit from the $Array into a Decimal form of the binary
$Frequancy = $Array[7] * 2 ^ 7 + $Frequancy                                                                     ;Converts the 8 bit from the $Array into a Decimal form of the binary
$Frequancy = $Frequancy * 10
Else
    Sleep(10000)
    EndIf

Ok the problem...

Once u select the Open from file ratio, then go to ok. things are fine. Then u go to open a file. Things are fine. Then the next user interface opens up and ALL HELL breaks loose. It doesn't respond to loops (While 1)

[see Note 1 In the Code above]

it just passes right through it like it isn't even there, It then continues to the next If

[see Note 2 In the Code above]

command and passes right through doing the code even though the condition is not true. I don't get it!

P.S. I know there is no startandstop button in the GUI, i had a exit one also. I accedently removed them in all the tinkering i did.

PLEASE HELP!!!


I love AutoIT! It doesn't talk back, it doesn't complain that ur on the computer, it loves to be ran over and over and over... but IT STILL DOESN'T DO THE DISHES... Gatta keep da pimp hand strong...

Share this post


Link to post
Share on other sites



I'm trying to understand but find it very dificult to test without a test-BKDF file.

Can you add one ?

Share this post


Link to post
Share on other sites

OK, my code works fine until i get to the second user interface.

...
Case $msg[0] = $StartStopButton
...

...

P.S. I know there is no startandstop button in the GUI, i had a exit one also. I accedently removed them in all the tinkering i did.

If the $StartStopButton variable is declared but uninitialized because you aren't creating the button then $StartStopButton = 0. In a message loop when nothing is happening $msg = 0. Therefore the case quoted above is true and it exits the loop.

:shocked:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

If the $StartStopButton variable is declared but uninitialized because you aren't creating the button then $StartStopButton = 0. In a message loop when nothing is happening $msg = 0. Therefore the case quoted above is true and it exits the loop.

:shocked:

OMG how can I be so stupid.. I get it. Now that u mention it, it did stop working the same time that button was removed.


I love AutoIT! It doesn't talk back, it doesn't complain that ur on the computer, it loves to be ran over and over and over... but IT STILL DOESN'T DO THE DISHES... Gatta keep da pimp hand strong...

Share this post


Link to post
Share on other sites

Ok, mbaye not. I just reolized that I did define the variable at the top. "$StartStopButton = 0". I tried the program again using "Dim" to declare my variable, just to make sure. It still does the same thing. Am I missing somthing?


I love AutoIT! It doesn't talk back, it doesn't complain that ur on the computer, it loves to be ran over and over and over... but IT STILL DOESN'T DO THE DISHES... Gatta keep da pimp hand strong...

Share this post


Link to post
Share on other sites

Ok, mbaye not. I just reolized that I did define the variable at the top. "$StartStopButton = 0". I tried the program again using "Dim" to declare my variable, just to make sure. It still does the same thing. Am I missing somthing?

The point was that a control ID from creating a button will never be 0. Your GUI message loop receives $msg = 0 over and over while nothing is happening. If you compare an invalid $StartStopButton control ID of 0 to the $msg for nothing happening, they match. Either create the button and get a valid control ID, or initialize it to something non-zero, like -1:

$StartStopButton = -1oÝ÷ Ø8¦¢²èq©ZjX¬¢yr­ê®·ü¨»§¶ÚyÉZ­é¨­ëajz'zö«¦åzíëébê+²ü¬r^¢Ø^¯¬{*.v÷öÙÞyØ­jëh×6; This works
$a = 1
$b = 0

; This works
Dim $a = 1, $b= 0

; This does not work
$a = 1, $b= 0

:shocked:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
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
Sign in to follow this  
Followers 0