Jump to content

Checking for an equation in an input box


Recommended Posts

It's actually better to have a reproducer. Then I don't have to sort through all the code to find the issue. As well, I find that the majority of the time I start making a reproducer, I discover the problem myself.

Anyways, I think you'll find the solution to your problem pretty easy:

Func RealTime()
    $ToMakeRead = GuiCtrlRead($ToMake)
    $MathRead = GuiCtrlRead($NumberEntry)
    ;For $i = 1 to $MathRead
    $ToMakeRead -= $MathRead
    GuiCtrlSetData($ToMake, $ToMakeRead)
    ;Next
    ;nGuiCtrlSetData($ToMake, Execute(GuiCtrlRead($ToMake)) - Execute(GuiCtrlRead($NumberEntry)))
    ;Local $OldStr
        ;If $ToMakeRead <> $OldStr Then
                ;GuiCtrlSetData($ToMake,    $ToMakeRead - Execute($MathRead))
        ;EndIf
        ;$OldStr = $MathRead
EndFunc
IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
Link to comment
Share on other sites

That puts a number in your label, in the code you gave me, I assure you. Not much else I can do until you help me help you...

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
Link to comment
Share on other sites

Are you trying to dynamically change the label text as the user types in the input box?

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
Link to comment
Share on other sites

I know of no way to do that. Search MSDN for messages from an input control, and see if there is a message sent when you edit the input.

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
Link to comment
Share on other sites

On second thought, you could use AdlibEnable, or possibly poll the input in your GUI loop. Example:

#include <GUIConstants.au3>

AdlibEnable("Update")

Opt("GUIOnEventMode", 1)
HotKeySet("{Esc}","Quit")

$testGUI = GUICreate("Dynamic Label Updater", 400, 400)
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")

$input = GUICtrlCreateInput("", 10, 10, 100, 25)
$label = GUICtrlCreateLabel("", 50, 100, 100, 25)

GUISetState(@SW_SHOW, $testGUI)

While 1
    Sleep(10)
WEnd

Func Update()
    $text = GUICtrlRead($input)
    GUICtrlSetData($label, $text)
EndFunc

Func Quit() 
    Exit 0
EndFunc

Let's have a look at yours...

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
Link to comment
Share on other sites

Try:

Func RealTime()
    $ToMakeRead = GUICtrlRead($ToMake)
    ConsoleWrite("$ToMakeRead: " & $ToMakeRead & @CR)
    $MathRead = GUICtrlRead($NumberEntry)
    ConsoleWrite("$MathRead: " & $MathRead & @CR)
    If $MathRead <> $CTRLRead And StringLen($MathRead) > 1 Then
        ;MsgBox(0, "", "Different")
        $ToMakeRead -= Execute($MathRead)
        ConsoleWrite("$ToMakeRead: " & $ToMakeRead & @CR)
        GUICtrlSetData($ToMake, $ToMakeRead)
    EndIf
EndFunc   ;==>RealTimeoÝ÷ Ùh^­ì¨ºµ¡W¥¢ky§l)¶¬jëh×6While 1
    Global $CTRLRead = GUICtrlRead($NumberEntry)
    _CheckInput()
    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE, $Exit
            Exit
        Case $Start, $StartGame
            $Random = Random(0, UBound($N2M) - 1, 1)
            $Result = $N2M[$Random]
            GUICtrlSetData($ToMake, $Result, "")
        Case $Check
            Math()
        Case $NumberEntry
            Math()
            ;Realtime()
        Case $About
            MsgBox(4096, "About", "St*r Numbers Game" & @CRLF & @TAB & "Copyright James Brooks 2007!" & @CRLF & @CRLF _
                     & "Concept by: James Brooks" & @CRLF & "Graphics by: James Brooks" & @CRLF & "Designed by: James Brooks" & _
                    @CRLF & "Version: " & $version)
        Case $Update
            Updater()
        Case $HelpMe
            MsgBox(0, "St*r Numbers Game", "Try and make the number shown in blue by using only the numbers shown in the star" & _
                    "You can use +-*/ to make the number!")
        Case $Website
            ShellExecute("http://starnumbergame.googlepages.com/home")
    EndSwitch
    RealTime()
WEnd
IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
Link to comment
Share on other sites

Actually, better add this instead:

Func Start()
    $Random = Random(0, UBound($N2M) - 1, 1)
    Global $Result = $N2M[$Random]
    GUICtrlSetData($ToMake, $Result, "")
EndFunc   ;==>Start

Func RealTime()
    $MathRead = GUICtrlRead($NumberEntry)
    If $MathRead <> $CTRLRead And StringLen($MathRead) > 1 Then
        $value = $Result - Execute($MathRead)
        GUICtrlSetData($ToMake, $value)
    EndIf
EndFunc   ;==>RealTime

Edit: typos

Edited by mikehunt114
IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
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...