Jump to content

i know this will be something simple but i can fix it


Recommended Posts

Hi ive been trying to fix this script but i cant find whats wrong with the code

what is wrong is when it makes the sum it sets the label as 0*0 all the time but it shold not be can any one help thanks

#include <GUIConstants.au3>

$ini = "Timestableswizz.ini"

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Time tables wizz", 223, 170, 193, 115)
GUISetFont(10, 400, 0, "MS Sans Serif")
GUISetBkColor(0x008000)
$Label1 = GUICtrlCreateLabel("THE SUM:", 8, 24, 68, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x008000)
$Label2 = GUICtrlCreateLabel("ALabel2", 96, 24, 54, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x008000)
$Label3 = GUICtrlCreateLabel("IS IT", 8, 64, 31, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x008000)
$Radio1 = GUICtrlCreateRadio("", 96, 64, 113, 17)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x008000)
$Radio2 = GUICtrlCreateRadio("", 96, 80, 113, 17)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x008000)
$Radio3 = GUICtrlCreateRadio("", 96, 96, 113, 17)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x008000)
$Radio4 = GUICtrlCreateRadio("", 96, 112, 113, 17)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x008000)
$Button1 = GUICtrlCreateButton("Next", 8, 96, 75, 25, BitOR($BS_CENTER,$BS_VCENTER,$BS_PUSHLIKE,$BS_FLAT,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label4 = GUICtrlCreateLabel("Your Socre", 8, 136, 71, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x008000)
$Label5 = GUICtrlCreateLabel("", 88, 136, 54, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x008000)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


Func _newsum()
    ;gets the mode
    $Mode = IniRead($ini,"SETINGS", "MODE", "EASY")
    ;easy
    If $Mode = "EASY" Then 
        $1 = 10
        $2 = 0
    EndIf
    ;medium
    If $Mode = "MEDIUM" Then
        $1 = 12
        $2 = 1
    EndIf
    ;hard
    If $Mode = "HARD" Then
        $1 = 20
        $2 = 1
    EndIf
    ;make the sum
    $number = Random( $1, $2, 1)
    GUICtrlSetData( $Label2, $number & "*" & $number)
EndFunc



While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            _newsum()

    EndSwitch
WEnd

some of my scripts check them out and give feedback so i can learn from them :)autoclicker a autoclickernote taker a script to take notes with

Link to comment
Share on other sites

#include <GUIConstants.au3>

$ini = "Timestableswizz.ini"

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Time tables wizz", 223, 170, 193, 115)
GUISetFont(10, 400, 0, "MS Sans Serif")
GUISetBkColor(0x008000)
$Label1 = GUICtrlCreateLabel("THE SUM:", 8, 24, 68, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x008000)
$Label2 = GUICtrlCreateLabel("ALabel2", 96, 24, 54, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x008000)
$Label3 = GUICtrlCreateLabel("IS IT", 8, 64, 31, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x008000)
$Radio1 = GUICtrlCreateRadio("", 96, 64, 113, 17)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x008000)
$Radio2 = GUICtrlCreateRadio("", 96, 80, 113, 17)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x008000)
$Radio3 = GUICtrlCreateRadio("", 96, 96, 113, 17)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x008000)
$Radio4 = GUICtrlCreateRadio("", 96, 112, 113, 17)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x008000)
$Button1 = GUICtrlCreateButton("Next", 8, 96, 75, 25, BitOR($BS_CENTER,$BS_VCENTER,$BS_PUSHLIKE,$BS_FLAT,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label4 = GUICtrlCreateLabel("Your Socre", 8, 136, 71, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x008000)
$Label5 = GUICtrlCreateLabel("", 88, 136, 54, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x008000)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            _newsum()

    EndSwitch
WEnd

Func _newsum()
   ;gets the mode
    $Mode = IniRead($ini,"SETINGS", "MODE", "EASY")
   ;easy
    If $Mode = "EASY" Then 
        $1 = 10
        $2 = 0
    EndIf
   ;medium
    If $Mode = "MEDIUM" Then
        $1 = 12
        $2 = 1
    EndIf
   ;hard
    If $Mode = "HARD" Then
        $1 = 20
        $2 = 1
    EndIf
   ;make the sum
    $number = Random($2, $1, 1)
    GUICtrlSetData( $Label2, $number & "*" & $number)
EndFunc

The syntax of Random is Random(min,max) and yours was like Random(max,min) :)

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...