Jump to content

a few retarded problems


Recommended Posts

i am stumped.... :D

there are a few problems with my proggy.

1) it ALWAYS, no matter what, shows that the answer is incorrect.

2) it doesn't actually stop when needed

3) it doesn't register the random letter that it should have picked, OR, doesn't read it properly again. not sure.

#cs     TO DO on next open
--------------------------
1) Design GKanTrain()
2) Create a function to compare user input against $gIniPath,kanatraining,yourans
3) Implement a score option
#ce

#include "Include\ButtonConstants.au3"
#include "Include\GuiConstants.au3"
#include "Include\GuiConstantsEx.au3"
#include "Include\EditConstants.au3"
#include "FUNCMain.au3"


Global $gIniPath="Data\opt.ini"

Func GMainMenu()
    GUICreate("JBT: Main menu",350,250)
    Opt("GuiCoordMode", 0)
    $mmB1=GUICtrlCreateButton("Pracitce Kana",35,35,100,20)

    GUISetState()
    While 1 = 1
        $mmM=GUIGetMsg()
        Select
            Case $mmM=$mmB1
                IniWrite($gIniPath,"options","guisel","1")
                ExitLoop
            Case $mmM=$GUI_EVENT_CLOSE
                Exit
        EndSelect
    WEnd
    GUIDelete()
EndFunc

Func GKanOpt()
    $gkoIR1=IniRead($gIniPath,"options","gkoinput","10")
    GUICreate("JBT: Kana training - Options",300,200)
    Opt("GuiCoordMode",0)
    $gkoR1=GUICtrlCreateRadio("Hiragana only",35,35,100,20)
    $gkoR2=GUICtrlCreateRadio("Katakana only",0,25,100,20)
    $gkoR3=GUICtrlCreateRadio("Both",0,25,100,20)
    $gkoIN1=GUICtrlCreateInput($gkoIR1,100,50,100,20,$ES_NUMBER)
    $gkoB1=GUICtrlCreateButton("Begin",0,25,100,20)
    GUISetState()
    GUICtrlSetState($gkoR3,$GUI_CHECKED)
    Dim $gkoAcc[1][2]=[["{ENTER}",$gkoB1]]
    GUISetAccelerators($gkoAcc)

    While 1=1
        $gkoM=GUIGetMsg()
        Select
            Case $gkoM=$gkoB1
                $gkoR1R=GUICtrlRead($gkoR1)
                $gkoR2R=GUICtrlRead($gkoR2)
                $gkoR3R=GUICtrlRead($gkoR3)
                Select
                    Case $gkoR1R=$GUI_CHECKED
                        IniWrite($gIniPath,"kanaopt","kantype","1")
                    Case $gkoR2R=$GUI_CHECKED
                        IniWrite($gIniPath,"kanaopt","kantype","2")
                    Case $gkoR3R=$GUI_CHECKED
                        IniWrite($gIniPath,"kanaopt","kantype","3")
                EndSelect
                $gkoINW1=GUICtrlRead($gkoIN1)
                IniWrite($gIniPath,"options","tloop",$gkoINW1)
                GUIDelete()
                GKanTrain()
            Case $gkoM=$GUI_EVENT_CLOSE
                GUIDelete()
                GMainMenu()
        EndSelect
    WEnd
EndFunc

Func GKanTrain()
    FSelKana()
    $gktIR1=IniRead($gIniPath,"kanaopt","filename","NULL")
    GUICreate("JBT:Kana training",300,250)
    GUICtrlCreatePic($gktIR1,75,25,150,150)
    GUICtrlCreateLabel("Please input the correct letter",-50,150,200,20)
    $gktIN1=GUICtrlCreateInput("",0,25,100,20,$ES_LOWERCASE)
    $gktB1=GUICtrlCreateButton("Enter",25,25,50,20)
    GUISetState()
    Dim $gktAcc[1][2]=[["{ENTER}",$gktB1]]
    GUISetAccelerators($gktAcc)

    While 1=1
        $gktM=GUIGetMsg()
        Select
            Case $gktM=$gktB1
                $gktIN1R=GUICtrlRead($gktIN1)
                $gktIR2=IniRead($gIniPath,"kanaopt","result","NULL")
                IniWrite($gIniPath,"kanaopt","yourans",$gktIN1R)
                FChkAns()
                GUIDelete()
                GKanChkAns()
            Case $gktM=$GUI_EVENT_CLOSE
                GUIDelete()
                GMainMenu()
        EndSelect
    WEnd
EndFunc

Func GKanChkAns()
    $gkcaIR1=IniRead($gIniPath,"options","result","NULL")
    GUICreate("JBT: Kana training",350,250)
    Opt("GuiCoordMode",0)
    If $gkcaIR1=1 Then
        GUICtrlCreatePic("Data\Graphics\MGO1.bmp",25,25,250,100)
        GUICtrlCreateLabel("Correct answer!",0,150,250,20)
    Else
        $gkcaIR2=IniRead($gIniPath,"options","corans","NULL")
        GUICtrlCreatePic("Data\Graphics\MGO2.bmp",25,25,250,100)
        GUICtrlCreateLabel("Incorrect answer!",0,25,250,20)
        GUICtrlCreateLabel("The correct answer is "&$gkcaIR2,0,25,250,20)
    EndIf
    $gkcaB1=GUICtrlCreateButton("Next char",50,55,100,20)
    GUISetState()
    Dim $gkcaAcc[1][2]=[["{ENTER}",$gkcaB1]]
    GUISetAccelerators($gkcaAcc)

    While 1=1
        $gkcaM=GUIGetMsg()
        Select
            Case $gkcaM=$gkcaB1
                $gkcaIR3=IniRead($gIniPath,"options","endtrain","NULL")
                FLoopTill()
                If $gkcaIR3=0 Then
                    GUIDelete()
                    GKanTrain()
                Else
                    GUIDelete()
                    ;score
                EndIf
            Case $gkcaM=$GUI_EVENT_CLOSE
                GUIDelete()
                GMainMenu()
        EndSelect
    WEnd
EndFunc

Global $gIniPath="Data\opt.ini"
Global $gKanaPath="Data\kana.ini"

Func FSelKana()
    $fskRankanIR=Random(1,46,1)
    $fskSwitch=IniRead($gIniPath,"kanaopt","kantype","NULL")
    If $fskSwitch=1 Then
        IniWrite($gIniPath,"kanaopt","type","H")
    ElseIf $fskSwitch=2 Then
        IniWrite($gIniPath,"kanaopt","type","K")
    ElseIf $fskSwitch=3 Then
        $fskRanType=Random(1,2,1)
        Select
            Case $fskRanType=1
                IniWrite($gIniPath,"kanaopt","type","H")
            Case $fskRanType=2
                IniWrite($gIniPath,"kanaopt","type","K")
        EndSelect
    EndIf
    $kanasel=IniRead($gKanaPath,"kana",$fskRankanIR,"0")
    $kanatypesel=IniRead($gIniPath,"kanaopt","type","0")
    IniWrite($gIniPath,"kanaopt","filename","Data\Graphics\"&$kanatypesel&$fskRankanIR&".bmp")
    IniWrite($gIniPath,"kanaopt","corans",$kanasel)
EndFunc

Func FChkAns()
    $fcaIR1=IniRead($gIniPath,"kanaopt","corans","NULL")
    $fcaIR2=IniRead($gIniPath,"kanaopt","yourans","NULL")
    $fcaSC=StringCompare($fcaIR1,$fcaIR2,0)
    $fcaScore=IniRead($gIniPath,"kanaopt","score","NULL")
    If $fcaSC=0 Then
        $fcaScore=$fcaScore+1
        IniWrite($gIniPath,"kanaopt","score",$fcaScore)
        IniWrite($gIniPath,"kanaopt","result","1")
    Else
        IniWrite($gIniPath,"kanaopt","result","0")
    EndIf
EndFunc

Func FLoopTill()
    $fltIR1=IniRead($gIniPath,"options","tloop","0")
    $fltIR2=IniRead($gIniPath,"options","curloop","0")
    If $fltIR1=$fltIR2 Then
        IniWrite($gIniPath,"options","endtrain","1")
    Else
        $fltIR2=$fltIR2+1
        IniWrite($gIniPath,"options","endtrain","0")
        IniWrite($gIniPath,"options","curloop",$fltIR2)
    EndIf
EndFunc

the main file simply calls GMainMenu() atm. it's not important.

Edited by GodForsakenSoul
Link to comment
Share on other sites

If even you can write in another post an explanation of what your first post is all about I will be quite impressed.

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

right. sorry. sleep deprivation is a magical thing.

1)i'm trying to make it show a "CORRECT!!!" or "WRONG!!!" gui depending on whether or not you input the correct value in the input box.

GChkAns() is the gui, it gets its info from opt.ini and FChkAns(), which sets the right or wrong flag to either 1 (right) or wrong (0).

FChkAns() compares the string you enter from GKanTrain() which is also being saved in an ini.

for some ungodly reason, the right/wrong flag is always wrong, despite the fact i clearly wrote good enough conditions for it to change.

2) FLoopTill() basically counts how many loops you made.

it has a set number of loops through the whole proccess set (default: 10), it starts counting from 1.

i do believe you can decipher FLoopTill() easily enough.

yet, it doesn't friggin work!

3) the program selects a random letter and a matching picture. it has no problem generating the picture, but the letter is always NULL.

i stole FSelKana() DIRECTLY from an older version where it worked 100% perfectly. i'm very much confused as to why it doesn't work NOW.

suggestions as to why the hell this decides to not work NOW are welcome. help is welcome also.

Link to comment
Share on other sites

  • Developers

right. sorry. sleep deprivation is a magical thing.

I am wondering how many times I have seen you say this and being stumped.

What about getting some sleep and coming back when your brain is back online?

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

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