Jump to content

So lost and confused -Solved-


 Share

Recommended Posts

Can anyone tell me why neither of there do not work at all (in detail please)??

 

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 285, 192, 114)
$Button1 = GUICtrlCreateButton("Randomize Button", 192, 184, 185, 73)
$Input1 = GUICtrlCreateInput("0", 24, 40, 121, 21)
$Input2 = GUICtrlCreateInput("0", 24, 72, 121, 21)
$Combo1 = GUICtrlCreateCombo("", 24, 112, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData($Combo1, "1|2|3|4|5")
$Input3 = GUICtrlCreateInput("0", 400, 40, 121, 21)
$Input4 = GUICtrlCreateInput("0", 400, 72, 121, 21)
$Combo2 = GUICtrlCreateCombo("", 400, 112, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData($Combo2, "A|B|C|D|E")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global $Max = 0
Global $Max1 = 0

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo1
            Global $Choice = GUICtrlRead($Combo1)
            Switch $Combo1
                Case "1"
                    GUICtrlSetData($Max, 10)
                Case "2"
                    GUICtrlSetData($Max, 20)
                Case "3"
                    GUICtrlSetData($Max, 30)
                Case "4"
                    GUICtrlSetData($Max, 40)
                Case "5"
                    GUICtrlSetData($Max, 50)
            EndSwitch
        Case $Combo2
            Global $Max1 = GUICtrlRead($Combo2)
            Switch $Max1
                Case "A" Or "B" Or "C"
                    GUICtrlSetData($Max1, 60)
                Case Else
                    GUICtrlSetData($Max1, 100)
            EndSwitch
        Case $Button1
            Randomize()
    EndSwitch
WEnd

Func Randomize()
    $Input1 = Random(0, $Max, 1)
    $Input2 = Random(0, $Max, 1)
    $Input3 = Random(0, $Max1, 1)
    $Input4 = Random(0, $Max1, 1)
EndFunc   ;==>Randomize

 

Edited by xxaviarxx
Link to comment
Share on other sites

  • Developers

Can anyone tell me why neither of there do not work at all (in detail please)??

What exactly doesn't work as this isn't really clear to me? ;)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Well based on your choice from either combo list the randomizing button should pick a number between 0 and the value set by the combo list. It works flawlessly in my head but in the script the Max and Max1 values never change themselves from 0 or at least the input boxes do not register the change.

Edited by xxaviarxx
Link to comment
Share on other sites

  • Developers

Started to do some debugging and one thing that is wrong is that you are test the handle "Switch $Combo1"in stead of  "Switch $Choice".

Here is how you can do debugging in SciTE (Full version) with Al+D:

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 285, 192, 114)
$Button1 = GUICtrlCreateButton("Randomize Button", 192, 184, 185, 73)
$Input1 = GUICtrlCreateInput("0", 24, 40, 121, 21)
$Input2 = GUICtrlCreateInput("0", 24, 72, 121, 21)
$Combo1 = GUICtrlCreateCombo("", 24, 112, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData($Combo1, "1|2|3|4|5")
$Input3 = GUICtrlCreateInput("0", 400, 40, 121, 21)
$Input4 = GUICtrlCreateInput("0", 400, 72, 121, 21)
$Combo2 = GUICtrlCreateCombo("", 400, 112, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData($Combo2, "A|B|C|D|E")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

Global $Max = 0
Global $Max1 = 0

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo1
            Global $Choice = GUICtrlRead($Combo1)
            ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Choice = ' & $Choice & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
            Switch $Choice
                Case "1"
                    $Max=10
                Case "2"
                    $Max=20
                    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Max = ' & $Max & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
                Case "3"
                    $Max=30
                Case "4"
                    GUICtrlSetData($Max, 40)
                Case "5"
                    GUICtrlSetData($Max, 50)
            EndSwitch
        Case $Combo2
            Global $Max1 = GUICtrlRead($Combo2)
            Switch $Max1
                Case "A" Or "B" Or "C"
                    GUICtrlSetData($Max1, 60)
                Case Else
                    GUICtrlSetData($Max1, 100)
            EndSwitch
        Case $Button1
            Randomize()
    EndSwitch
WEnd

Func Randomize()
    $Input1 = Random(0, $Max, 1)
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Input1 = ' & $Input1 & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
    $Input2 = Random(0, $Max, 1)
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Input2 = ' & $Input2 & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
    $Input3 = Random(0, $Max1, 1)
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Input3 = ' & $Input3 & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
    $Input4 = Random(0, $Max1, 1)
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Input4 = ' & $Input4 & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
EndFunc   ;==>Randomize

Just to get you going. ;)

Jos
 

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

As I thought it was something really simple that I completely overlooked for the most part. Had to change the inputs which I completely forgot to do #1 and the $Choice one i never noticed while trying many different things.

Also seems as though you cannot use this ::

Case $Combo2
            Global $Choice1 = GUICtrlRead($Combo2)
            Switch $Choice1
                Case "A" Or "B" Or "C"
                    GUICtrlSetData($Max1, 60) ; $Max1 = 60 same problem
                Case Else
                    GUICtrlSetData($Max1, 100) ; $Max1 = 100 same problem
            EndSwitch

Instead you have to use this ::

Case $Combo2
            Global $Choice1 = GUICtrlRead($Combo2)
            Switch $Choice1
                Case "A", "B", "C"
                    $Max1 = 60
                Case Else
                    $Max1 = 100
            EndSwitch

I was under the impression from the help files that the comma and Or meant the exact same thing, when in fact Or will not work in a case like this but the comma does, kind of weird wording in the help files on this matter.

 

Thank you for your help this had me stumped for a couple hours.

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