Sign in to follow this  
Followers 0
BJJ

Math problem no idea :(

24 posts in this topic

Hello

I want make Simple calculator but dont have idea how make it on AutoIt :)

I wane make 4 inputbox

Age [ ]

Power [ ]

Run [ ]

Fight [ ]

User overcrowd poll

==========================================

Age

If value is between 0 and 10 $Result_Age = 1

9 and 13 $Result_Old = 2

etc..

[ If difrent than 0 to 70 then error ]

Power

If value is between 0 and 20 $Result_Power = 1

If value is between 21 and 40 $Result_Power = 2

etc..

[ If difrent than 0 to 500 then error ]

Run

If value is between 0 and 10 $Result_Run = 1

If value is between 11 and 30 $Result_Run = 2

etc...

[ If difrent than 0 to 500 then error

Fight

If value is 0 $Result_Fight = 0

If value is 1 $Result_Fight = 8

If value is 2 $Result_Fight = 10

If value is 3 $Result_Fight = 13

etc...

[ If difrent than 0 to 50 then error ]

$Final_Result = $Result_Age + $Result_Power + $Result_Run + $Result_Fight

Please Help

Share this post


Link to post
Share on other sites



Umm i'm lost but maybe this will help,

$Age = InputBox ('How old are you?','Please input your name here.')
If @Error Then Exit 
$Power = InputBox ('Whats your power?','Please input your power here.')
If @Error Then Exit 
$Run = InputBox ('Whats your run?','Please input your run here.')
If @Error Then Exit 
$Fight = InputBox ('Whats your fight?','Please input your fight here.')
If @Error Then Exit 
    
Global $Result_Age, $Result_Power, $Result_Run, $Result_Fight, $Result_Final
    
; Set $Result_Age
For $A = '0' To '10' 
If $Age = $A Then $Result_Age = '1'
Next
If $Age = '9' Or $Age = '13' Then 
$Result_Age = '2'
ElseIf $Age > '10' Then 
$Result_Age = '0';???????????????
EndIf 

;Set $Result_Power
For $A = '0' To '20' 
If $Power = $A Then $Result_Power = '1'
Next
For $A = '21' To '40'
If $Power = $A Then $Result_Power = '2'
Next
If $Power > '40' Then $Result_Power = '0';???????????????
    
;Set $Result_Run
For $A = '0' To '10'
If $Run = $A Then $Result_Run = '1'
Next
For $A = '11' To '30'
If $Run = $A Then $Result_Run = '2'
Next
If $Run > '30' Then $Result_Run = '0';???????????????
    
;Set $Result_Fight
If $Fight = '0' Then $Result_Fight = '0'
If $Fight = '1' Then $Result_Fight = '8'
If $Fight = '2' Then $Result_Fight = '10'
If $Fight = '3' Then $Return_Fight = '13'
If $Fight > '3' Then $Result_Fight = '0'
    
$Result_Final = $Result_Age + $Result_Power + $Result_Run + $Result_Fight

ConsoleWrite ('$Result_Final : ' & $Result_Final & @CRLF)

- John! :)


Latest Projects :- New & Improved TCP Chat

Share this post


Link to post
Share on other sites

Try this.

CODE
#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Form1", 303, 219, 193, 115)

$Input1 = GUICtrlCreateInput("1", 16, 28, 121, 21)

$Input2 = GUICtrlCreateInput("1", 164, 28, 121, 21)

$Input3 = GUICtrlCreateInput("1", 16, 68, 121, 21)

$Input4 = GUICtrlCreateInput("1", 164, 68, 121, 21)

$Label1 = GUICtrlCreateLabel("Age", 16, 8, 23, 17)

$Label2 = GUICtrlCreateLabel("Power", 164, 8, 34, 17)

$Label3 = GUICtrlCreateLabel("Run", 16, 48, 24, 17)

$Label4 = GUICtrlCreateLabel("Fight", 164, 48, 27, 17)

$Button1 = GUICtrlCreateButton("Calculate", 32, 136, 93, 21, 0)

$Label5 = GUICtrlCreateLabel("Total", 188, 160, 45, 28)

GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")

$Label6 = GUICtrlCreateLabel("Total=", 188, 140, 34, 17)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

case $Button1

$age = Guictrlread($Input1)

$Power = Guictrlread($Input2)

$Run = Guictrlread($Input3)

$Fight = Guictrlread($Input4)

If $age > "" and $Power > "" and $Run > "" and $Fight > "" Then

If $age > 0 and $age < 10 Then $Result_Age = 1

If $Power > 0 and $Power < 20 Then $Result_Power = 1

If $Run > 0 and $Run < 10 Then $Result_Run = 1

If $Fight = 1 Then $Result_Fight = 8

GUICtrlSetData($label5,$Result_Age + $Result_Power + $Result_Run + $Result_Fight)

EndIf

EndSwitch

WEnd


[topic="21048"]New to AutoIt? Check out AutoIt 1-2-3![/topic] Need to make a GUI? You NEED KODA FormDesigner!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

How does the age and fight results work?

CODE
GUICreate("Calculator", 200, 300)

GUICtrlCreateLabel("Enter age:", 10, 10)

$ageinput = GUICtrlCreateInput("", 10, 30)

GUICtrlCreateLabel("Enter power:", 10, 60)

$powerinput = GUICtrlCreateInput("", 10, 80)

GUICtrlCreateLabel("Enter run:", 10, 110)

$runinput = GUICtrlCreateInput("", 10, 130)

GUICtrlCreateLabel("Enter fight:", 10, 160)

$fightinput = GUICtrlCreateInput("", 10, 180)

$calculate = GUICtrlCreateButton("Calculate!", 10, 210, 150)

$total = GUICtrlCreateLabel("", 10, 250, 150, 20)

GUISetState()

$msg = ""

While $msg <> -3

$msg = GUIGetMsg()

If $msg = $calculate Then

$age = GUICtrlRead($ageinput)

$power = GUICtrlRead($powerinput)

$run = GUICtrlRead($runinput)

$fight = GUICtrlRead($fightinput)

If $age <> "" or $power <> "" or $run <> "" or $fight <> "" Then

;I don't understand the age.

If $power < 0 Or $power > 500 Then

MsgBox(48, "Error!", "Please enter a value between 0 and 500!")

Else

$result_power = Ceiling($power / 20)

EndIf

If $run < 0 Or $run > 500 Then

MsgBox(48, "Error!", "Please enter a value between 0 and 500!")

ElseIf $run >= 0 And $run <= 10 Then

$result_run = 1

Else

$result_run = Ceiling(($run-10) / 20) + 1

EndIf

;I don't understand fight.

GUICtrlSetData($total, "Total: " & $result_run);$result_power + $result_run)

Else

MsgBox(48, "Error!", "You left one of the values blank!")

EndIf

EndIf

WEnd

Bah. Forgot to change a few things. But we don't know how the results for the age and fight work!

Edited by Coolw

My ProgramsMy WIP'sSteam Server Restarter

Share this post


Link to post
Share on other sites

@John2006

Greate Work (Your code work correctly)

I little change code but I need GUI :)

But my new code dont work correctly allways show resoult = 3 :party:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>


$Form1 = GUICreate("Form1", 605, 538, 247, 204)
$xxx1 = GUICtrlCreateGroup("", 128, 64, 441, 441)
$Label1 = GUICtrlCreateLabel("Age", 160, 120, 36, 17)
$Age = GUICtrlCreateInput("  ", 216, 120, 49, 21)
$Label2 = GUICtrlCreateLabel("Strange", 160, 160, 36, 17)
$Power = GUICtrlCreateInput("  ", 216, 160, 49, 21)
$Label3 = GUICtrlCreateLabel("Power", 160, 200, 36, 17)
$Run = GUICtrlCreateInput("  ", 216, 200, 49, 21)
$Label4 = GUICtrlCreateLabel("Fight", 160, 240, 36, 17)
$Fight = GUICtrlCreateInput("  ", 216, 240, 49, 21)
$xxx2 = GUICtrlCreateGroup("", 144, 96, 137, 193)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$start = GUICtrlCreateButton("Show my KI", 192, 448, 321, 33, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)



Local $A = 9999
   
Global $Result_Age, $Result_Power, $Result_Run, $Result_Fight, $Result_Final
   
; Set $Result_Age
For $A = '0' To '8'
If $Age = $A Then $Result_Age = '1'
Next
For $A = '9' To '13'
If $Age = $A Then $Result_Age = '2'
Next
For $A = '14' To '17'
If $Age = $A Then $Result_Age = '3'
Next
For $A = '18' To '50'
If $Age = $A Then $Result_Age = '4'
Next
For $A = '51' To '1000000'
If $Age = $A Then $Result_Age = '3'
Next

;Set $Result_Power
For $A = '0' To '20'
If $Power = $A Then $Result_Power = '1'
Next
For $A = '21' To '40'
If $Power = $A Then $Result_Power = '2'
Next
For $A = '41' To '60'
If $Power = $A Then $Result_Power = '3'
Next
For $A = '61' To '80'
If $Power = $A Then $Result_Power = '4'
Next
For $A = '81' To '100'
If $Power = $A Then $Result_Power = '6'
Next
For $A = '101' To '1000000'
If $Power = $A Then $Result_Power = '8'
Next


;Set $Result_Run
For $A = '0' To '10'
If $Run = $A Then $Result_Run = '1'
Next
For $A = '11' To '30'
If $Run = $A Then $Result_Run = '2'
Next
For $A = '31' To '50'
If $Run = $A Then $Result_Run = '3'
Next
For $A = '51' To '1000000'
If $Run = $A Then $Result_Run = '4'
Next
   
;Set $Result_Fight
If $Fight = '0' Then $Result_Fight = '0'
If $Fight = '1' Then $Result_Fight = '8'
If $Fight = '2' Then $Result_Fight = '10'
If $Fight = '3' Then $Return_Fight = '13'
If $Fight = '4' Then $Return_Fight = '14'
If $Fight = '5' Then $Return_Fight = '17'
If $Fight = '6' Then $Return_Fight = '20'
If $Fight = '7' Then $Return_Fight = '22'
If $Fight = '8' Then $Return_Fight = '23'
If $Fight = '9' Then $Return_Fight = '24'
If $Fight = '10' Then $Return_Fight = '25'
If $Fight > '10' Then $Return_Fight = '27';na razie tyle
   
$Result_Final = $Result_Age + $Result_Power + $Result_Run + $Result_Fight

While 1 
    $aMsg = GUIGetMsg(1)
    
Select 
    case $aMsg[0] = $Start
        
ConsoleWrite ('$Result_Final : ' & $Result_Final & @CRLF)

endselect
wend

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Bam! Here it is I think I got it this time,

Source :

#Include <ButtonConstants.Au3>
#Include <EditConstants.Au3>
#Include <GUIConstantsEx.Au3>
#Include <StaticConstants.Au3>
#Include <WindowsConstants.Au3>
Opt ('GUIOnEventMode','1')

$GUI = GUICreate ('Example','170','129','-1','-1','-1','128')
GUISetOnEvent ($GUI_EVENT_CLOSE, '_Exit')
GUICtrlCreatelabel ('Age :','5','5','40','20')
_Set ('1')
$Age = GUICtrlCreateInput ('','48','5','100','20','1')
_Set ('2')
GUICtrlCreatelabel ('Power :','5','30','51','20')
_Set ('1')
$Power = GUICtrlCreateInput ('','62','30','100','20','1')
_Set ('2')
GUICtrlCreatelabel ('Run :','5','55','36','20')
_Set ('1')
$Run = GUICtrlCreateInput ('','48','55','100','20','1')
_Set ('2')
GUICtrlCreatelabel ('Fight :','5','80','44','20')
_Set ('1')
$Fight = GUICtrlCreateInput ('','56','80','100','20','1')
_Set ('2')
$Start = GUICtrlCreateButton ('Start','50','105','70','20')
GUICtrlSetOnEvent ($Start, '_Start')
_Set ('2')
GUISetState (@SW_SHOW, $GUI)

While '1'
Sleep ('150')
WEnd

Func _Set ($iCase)
Switch $iCase
     Case '1'
         GUICtrlSetBkColor ('-1','-2')
         GUICtrlSetFont ('-1','10','600','','Arial')
     Case '2'
         GUICtrlSetFont ('-1','10','600','','Arial')
EndSwitch 
EndFunc

Func _Start ()
MsgBox ('0','Notice','Result : ' & _Result (), '0')
EndFunc

Func _Result ()
Local $R_Age, $R_Power, $R_Run, $R_Fight
;=== Age ===
For $A = '0' To '8'
If GUICtrlRead ($Age) = $A Then $R_Age = '1'
Next
For $A = '9' To '13'
If GUICtrlRead ($Age) = $A Then $R_Age = '2'
Next
For $A = '14' To '17'
If GUICtrlRead ($Age) = $A Then $R_Age = '3'
Next
For $A = '18' To '50'
If GUICtrlRead ($Age) = $A Then $R_Age = '4'
Next
If GUICtrlRead ($Age) > '50' And GUICtrlRead ($Age) < '1000001' Then $R_Age = '3'
;=== Power ===
For $A = '0' To '20'
If GUICtrlRead ($Power) = $A Then $R_Power = '1'
Next
For $A = '21' To '40'
If GUICtrlRead ($Power) = $A Then $R_Power = '2'
Next
For $A = '41' To '60'
If GUICtrlRead ($Power) = $A Then $R_Power = '3'
Next
For $A = '61' To '80'
If GUICtrlRead ($Power) = $A Then $R_Power = '4'
Next
For $A = '81' To '100'
If GUICtrlRead ($Power) = $A Then $R_Power = '6'
Next
If GUICtrlRead ($Power) > '100' And GUICtrlRead ($Power) < '1000001' Then $R_Power = '8'
;=== Run ===
For $A = '0' To '10'
If GUICtrlRead ($Run) = $A Then $R_Run = '1'
Next
For $A = '11' To '30'
If GUICtrlRead ($Run) = $A Then $R_Run = '2'
Next
For $A = '31' To '50'
If GUICtrlRead ($Run) = $A Then $R_Run = '3'
Next
If GUICtrlRead ($Run) > '50' And GUICtrlRead ($Run) < '1000001' Then $R_Run = '4'
;=== Fight ===
If GUICtrlRead ($Fight) = '0' Then $R_Fight = '0'
If GUICtrlRead ($Fight) = '1' Then $R_Fight = '8'
If GUICtrlRead ($Fight) = '2' Then $R_Fight = '10'
If GUICtrlRead ($Fight) = '3' Then $R_Fight = '13'
If GUICtrlRead ($Fight) = '4' Then $R_Fight = '14'
If GUICtrlRead ($Fight) = '5' Then $R_Fight = '17'
If GUICtrlRead ($Fight) = '6' Then $R_Fight = '20'
If GUICtrlRead ($Fight) = '7' Then $R_Fight = '22'
If GUICtrlRead ($Fight) = '8' Then $R_Fight = '23'
If GUICtrlRead ($Fight) = '9' Then $R_Fight = '24'
If GUICtrlRead ($Fight) = '10' Then $R_Fight = '25'
If GUICtrlRead ($Fight) > '10' Then $R_Fight = '27'
Return $R_Age + $R_Power + $R_Run + $R_Fight
EndFunc

Func _Exit ()
Exit
EndFunc

Hope it helps! :party:

- John

Edit : Notes :

When using a 'GUI' always use "GUICtrlRead ($Var)" to read inputs etc..

Never do a "For...Next" loop going to 1,000,000 because it takes forever...

Also you might want to use "OnEventMode" because its better! :)

Edited by John2006

Latest Projects :- New & Improved TCP Chat

Share this post


Link to post
Share on other sites

Fantastic work John2006

tomorrow i try change this GUI

Big THANKS !!

Share this post


Link to post
Share on other sites

Hmm I dont know why but resoult's have error some time look

when put

age = 9

Power = 21

Run = 11

Fight = 0

then we have 6 point and this is true

age = 9

Power = 21

Run = 11

Fight = 1

then we have 14 point and this is true

BUT

age = 9

Power = 21

Run = 11

Fight = 2

then we have 33 point and this is somt fake ...

fight 2 = 10 point

Share this post


Link to post
Share on other sites

post your code

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Bam! Here it is I think I got it this time,

Source :

#Include <ButtonConstants.Au3>
#Include <EditConstants.Au3>
#Include <GUIConstantsEx.Au3>
#Include <StaticConstants.Au3>
#Include <WindowsConstants.Au3>
Opt ('GUIOnEventMode','1')

$GUI = GUICreate ('Example','170','129','-1','-1','-1','128')
GUISetOnEvent ($GUI_EVENT_CLOSE, '_Exit')
GUICtrlCreatelabel ('Age :','5','5','40','20')
_Set ('1')
$Age = GUICtrlCreateInput ('','48','5','100','20','1')
_Set ('2')
GUICtrlCreatelabel ('Power :','5','30','51','20')
_Set ('1')
$Power = GUICtrlCreateInput ('','62','30','100','20','1')
_Set ('2')
GUICtrlCreatelabel ('Run :','5','55','36','20')
_Set ('1')
$Run = GUICtrlCreateInput ('','48','55','100','20','1')
_Set ('2')
GUICtrlCreatelabel ('Fight :','5','80','44','20')
_Set ('1')
$Fight = GUICtrlCreateInput ('','56','80','100','20','1')
_Set ('2')
$Start = GUICtrlCreateButton ('Start','50','105','70','20')
GUICtrlSetOnEvent ($Start, '_Start')
_Set ('2')
GUISetState (@SW_SHOW, $GUI)

While '1'
Sleep ('150')
WEnd

Func _Set ($iCase)
Switch $iCase
     Case '1'
         GUICtrlSetBkColor ('-1','-2')
         GUICtrlSetFont ('-1','10','600','','Arial')
     Case '2'
         GUICtrlSetFont ('-1','10','600','','Arial')
EndSwitch 
EndFunc

Func _Start ()
MsgBox ('0','Notice','Result : ' & _Result (), '0')
EndFunc

Func _Result ()
Local $R_Age, $R_Power, $R_Run, $R_Fight
;=== Age ===
For $A = '0' To '8'
If GUICtrlRead ($Age) = $A Then $R_Age = '1'
Next
For $A = '9' To '13'
If GUICtrlRead ($Age) = $A Then $R_Age = '2'
Next
For $A = '14' To '17'
If GUICtrlRead ($Age) = $A Then $R_Age = '3'
Next
For $A = '18' To '50'
If GUICtrlRead ($Age) = $A Then $R_Age = '4'
Next
If GUICtrlRead ($Age) > '50' And GUICtrlRead ($Age) < '1000001' Then $R_Age = '3'
;=== Power ===
For $A = '0' To '20'
If GUICtrlRead ($Power) = $A Then $R_Power = '1'
Next
For $A = '21' To '40'
If GUICtrlRead ($Power) = $A Then $R_Power = '2'
Next
For $A = '41' To '60'
If GUICtrlRead ($Power) = $A Then $R_Power = '3'
Next
For $A = '61' To '80'
If GUICtrlRead ($Power) = $A Then $R_Power = '4'
Next
For $A = '81' To '100'
If GUICtrlRead ($Power) = $A Then $R_Power = '6'
Next
If GUICtrlRead ($Power) > '100' And GUICtrlRead ($Power) < '1000001' Then $R_Power = '8'
;=== Run ===
For $A = '0' To '10'
If GUICtrlRead ($Run) = $A Then $R_Run = '1'
Next
For $A = '11' To '30'
If GUICtrlRead ($Run) = $A Then $R_Run = '2'
Next
For $A = '31' To '50'
If GUICtrlRead ($Run) = $A Then $R_Run = '3'
Next
If GUICtrlRead ($Run) > '50' And GUICtrlRead ($Run) < '1000001' Then $R_Run = '4'
;=== Fight ===
If GUICtrlRead ($Fight) = '0' Then $R_Fight = '0'
If GUICtrlRead ($Fight) = '1' Then $R_Fight = '8'
If GUICtrlRead ($Fight) = '2' Then $R_Fight = '10'
If GUICtrlRead ($Fight) = '3' Then $R_Fight = '13'
If GUICtrlRead ($Fight) = '4' Then $R_Fight = '14'
If GUICtrlRead ($Fight) = '5' Then $R_Fight = '17'
If GUICtrlRead ($Fight) = '6' Then $R_Fight = '20'
If GUICtrlRead ($Fight) = '7' Then $R_Fight = '22'
If GUICtrlRead ($Fight) = '8' Then $R_Fight = '23'
If GUICtrlRead ($Fight) = '9' Then $R_Fight = '24'
If GUICtrlRead ($Fight) = '10' Then $R_Fight = '25'
If GUICtrlRead ($Fight) > '10' Then $R_Fight = '27'
Return $R_Age + $R_Power + $R_Run + $R_Fight
EndFunc

Func _Exit ()
Exit
EndFunc

Hope it helps! :party:

- John

Edit : Notes :

When using a 'GUI' always use "GUICtrlRead ($Var)" to read inputs etc..

Never do a "For...Next" loop going to 1,000,000 because it takes forever...

Also you might want to use "OnEventMode" because its better! :)

Why are you putting all number inside quotes (' ') ? This makes them a string by default.

Only use the quotes for Strings, never for numbers.

Also using For-Next loops is not the smartest way to test. Just use If--elseIf--EndIf or Select--Case-EndSelect logic for that.

Jos

Edited by Jos
1 person likes this

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Hello

I want make Simple calculator but dont have idea how make it on AutoIt :)

I wane make 4 inputbox

Age [ ]

Power [ ]

Run [ ]

Fight [ ]

User overcrowd poll

==========================================

Age

If value is between 0 and 10 $Result_Age = 1

9 and 13 $Result_Old = 2

etc..

[ If difrent than 0 to 70 then error ]

Power

If value is between 0 and 20 $Result_Power = 1

If value is between 21 and 40 $Result_Power = 2

etc..

[ If difrent than 0 to 500 then error ]

Run

If value is between 0 and 10 $Result_Run = 1

If value is between 11 and 30 $Result_Run = 2

etc...

[ If difrent than 0 to 500 then error

Fight

If value is 0 $Result_Fight = 0

If value is 1 $Result_Fight = 8

If value is 2 $Result_Fight = 10

If value is 3 $Result_Fight = 13

etc...

[ If difrent than 0 to 50 then error ]

$Final_Result = $Result_Age + $Result_Power + $Result_Run + $Result_Fight

Please Help

this doesnt make sense:

If value is between 0 and 10 $Result_Age = 1

9 and 13 $Result_Old = 2

etc..

and what do u mean with etc? that the comparison should continue until 500 or whatever?

btw I modified jhon's code:

CODE

#Include <ButtonConstants.Au3>

#Include <EditConstants.Au3>

#Include <GUIConstantsEx.Au3>

#Include <StaticConstants.Au3>

#Include <WindowsConstants.Au3>

Opt ('GUIOnEventMode','1')

$GUI = GUICreate ('Example','170','129','-1','-1','-1','128')

GUISetOnEvent ($GUI_EVENT_CLOSE, '_Exit')

GUICtrlCreatelabel ('Age :','5','5','40','20')

_Set ('1')

$Age = GUICtrlCreateInput ('','48','5','100','20','1')

_Set ('2')

GUICtrlCreatelabel ('Power :','5','30','51','20')

_Set ('1')

$Power = GUICtrlCreateInput ('','62','30','100','20','1')

_Set ('2')

GUICtrlCreatelabel ('Run :','5','55','36','20')

_Set ('1')

$Run = GUICtrlCreateInput ('','48','55','100','20','1')

_Set ('2')

GUICtrlCreatelabel ('Fight :','5','80','44','20')

_Set ('1')

$Fight = GUICtrlCreateInput ('','56','80','100','20','1')

_Set ('2')

$Start = GUICtrlCreateButton ('Start','50','105','70','20')

GUICtrlSetOnEvent ($Start, '_Start')

_Set ('2')

GUISetState (@SW_SHOW, $GUI)

While '1'

Sleep ('150')

WEnd

Func _Set ($iCase)

Switch $iCase

Case '1'

GUICtrlSetBkColor ('-1','-2')

GUICtrlSetFont ('-1','10','600','','Arial')

Case '2'

GUICtrlSetFont ('-1','10','600','','Arial')

EndSwitch

EndFunc

Func _Start ()

MsgBox ('0','Notice','Result : ' & _Result (), '0')

EndFunc

Func _Result ()

Local $R_Age, $R_Power, $R_Run, $R_Fight

Local $A

;=== Age ===

$A = Number(GUICtrlRead($Age))

;~ MsgBox(0, '', $a)

For $i = 0 To 40

If $A >= 10*$i + 1 And $A <= 10*$i + 10 Then

$R_Age = $i + 1

EndIf

Next

$A = GUICtrlRead($Power)

;=== Power ===

For $i = 0 To 24

If $A >= 20*$i + 1 And $A <= 20*$i + 20 Then

$R_Power = $i + 1

EndIf

Next

MsgBox(0, '', $R_Power)

$A = GUICtrlRead($Run)

;=== Run ===

For $i = 0 To 40

If $A >= 10*$i +1 And $A <= 10*$i + 10 Then

$R_Run = $i + 1

EndIf

Next

$A = GUICtrlRead($Fight)

;=== Fight ===

If Not $a = 0 Then

$R_Fight = 8 + $i

EndIf

Return $R_Age + $R_Power + $R_Run + $R_Fight

EndFunc

Func _Exit ()

Exit

EndFunc

Edited by oMBRa

Share this post


Link to post
Share on other sites

Ok there you have full guidelines

Age

0-8 = 1

9-13 = 2

14-17 = 3

18-50 = 4

51-70 = 3

Power

0-20 = 1

21-40 = 2

41-60 = 3

61-80 = 4

80-100 = 6

101- max = 8

Run

0-10 = 1

11-30 = 2

31-50 = 3

51- max = 4

Fight

0 = 0

1 = 8

2 = 10

3 = 13

4 = 14

5 = 17

6 = 20

7 = 22

8 = 23

9 = 24

10 = 25

11= 26

12 = 27

Share this post


Link to post
Share on other sites

Ok there you have full guidelines

Yea... and ?

Did you make the changes I proposed yet and do some proper debugging to figure out why things go wrong or are you expecting us to do that?

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

try this:

CODE

#include <ButtonConstants.Au3>

#include <EditConstants.Au3>

#include <GUIConstantsEx.Au3>

#include <StaticConstants.Au3>

#include <WindowsConstants.Au3>

Opt('GUIOnEventMode', '1')

$GUI = GUICreate('Example', '170', '129', '-1', '-1', '-1', '128')

GUISetOnEvent($GUI_EVENT_CLOSE, '_Exit')

GUICtrlCreateLabel('Age :', '5', '5', '40', '20')

_Set('1')

$Age = GUICtrlCreateInput('', '48', '5', '100', '20', '1')

_Set('2')

GUICtrlCreateLabel('Power :', '5', '30', '51', '20')

_Set('1')

$Power = GUICtrlCreateInput('', '62', '30', '100', '20', '1')

_Set('2')

GUICtrlCreateLabel('Run :', '5', '55', '36', '20')

_Set('1')

$Run = GUICtrlCreateInput('', '48', '55', '100', '20', '1')

_Set('2')

GUICtrlCreateLabel('Fight :', '5', '80', '44', '20')

_Set('1')

$Fight = GUICtrlCreateInput('', '56', '80', '100', '20', '1')

_Set('2')

$Start = GUICtrlCreateButton('Start', '50', '105', '70', '20')

GUICtrlSetOnEvent($Start, '_Start')

_Set('2')

GUISetState(@SW_SHOW, $GUI)

While '1'

Sleep('150')

WEnd

Func _Set($iCase)

Switch $iCase

Case '1'

GUICtrlSetBkColor('-1', '-2')

GUICtrlSetFont('-1', '10', '600', '', 'Arial')

Case '2'

GUICtrlSetFont('-1', '10', '600', '', 'Arial')

EndSwitch

EndFunc ;==>_Set

Func _Start()

MsgBox('0', 'Notice', 'Result : ' & _Result(), '0')

EndFunc ;==>_Start

Func _Result()

Local $R_Age, $R_Power, $R_Run, $R_Fight, $A

Local $nAge[5][3] = [[0, 8, 1], [9, 13, 2], [14, 17, 3], [51, 70, 4]]

Local $nPower[5][3] = [[0, 20, 1], [21, 40, 2], [41, 60, 3], [61, 80, 4], [80, 100, 6]]

Local $nRun[3][3] = [[0, 10, 1], [11, 30, 2], [31, 50, 3]]

Local $nFight[13] = [0, 8, 10, 13, 14, 17, 20, 22, 23, 24, 25, 26, 27]

;=== Age ===

$A = GUICtrlRead($Age)

;~ MsgBox(0, '', $a)

For $i = 0 To 5

If $A >= $nAge[$i][0] And $A <= $nAge[$i][1] Then

$R_Age = $nAge[$i][2]

ExitLoop

EndIf

Next

$A = GUICtrlRead($Power)

;=== Power ===

For $i = 0 To 5

If $A >= $nPower[$i][0] And $A <= $nPower[$i][1] Then

$R_Power = $nPower[$i][2]

ExitLoop

EndIf

Next

If $R_Power = 0 Then $R_Age = 8

$A = GUICtrlRead($Run)

;=== Run ===

For $i = 0 To 3

If $A >= $nRun[$i][0] And $A <= $nRun[$i][1] Then

$R_Run = $nRun[$i][2]

ExitLoop

EndIf

Next

If $R_Run = 0 Then $R_Run = 4

$A = GUICtrlRead($Fight)

;=== Fight ===

If $A > 12 Then

$R_Fight = 0

Else

$R_Fight = $nFight[$a]

EndIf

Return $R_Age + $R_Power + $R_Run + $R_Fight

EndFunc ;==>_Result

Func _Exit()

Exit

EndFunc ;==>_Exit

Share this post


Link to post
Share on other sites
oMBRa Your code dont calculate corectly

Share this post


Link to post
Share on other sites

can u post some examples? ( and post what it should be like too)

Share this post


Link to post
Share on other sites

#Include <ButtonConstants.Au3>
#Include <EditConstants.Au3>
#Include <GUIConstantsEx.Au3>
#Include <StaticConstants.Au3>
#Include <WindowsConstants.Au3>
Opt ('GUIOnEventMode','1')

$GUI = GUICreate ('Example','170','129','-1','-1','-1','128')
GUISetOnEvent ($GUI_EVENT_CLOSE, '_Exit')
GUICtrlCreatelabel ('Age :','5','5','40','20')
_Set ('1')
$Age = GUICtrlCreateInput ('','48','5','100','20','1')
_Set ('2')
GUICtrlCreatelabel ('Power :','5','30','51','20')
_Set ('1')
$Power = GUICtrlCreateInput ('','62','30','100','20','1')
_Set ('2')
GUICtrlCreatelabel ('Run :','5','55','36','20')
_Set ('1')
$Run = GUICtrlCreateInput ('','48','55','100','20','1')
_Set ('2')
GUICtrlCreatelabel ('Fight :','5','80','44','20')
_Set ('1')
$Fight = GUICtrlCreateInput ('','56','80','100','20','1')
_Set ('2')
$Start = GUICtrlCreateButton ('Start','50','105','70','20')
GUICtrlSetOnEvent ($Start, '_Start')
_Set ('2')
GUISetState (@SW_SHOW, $GUI)

While '1'
Sleep ('150')
WEnd

Func _Set ($iCase)
Switch $iCase
     Case '1'
         GUICtrlSetBkColor ('-1','-2')
         GUICtrlSetFont ('-1','10','600','','Arial')
     Case '2'
         GUICtrlSetFont ('-1','10','600','','Arial')
EndSwitch
EndFunc

Func _Start ()
MsgBox ('0','Scouter','Your KI  =  ' & _Result (), '0')
EndFunc

Func _Result ()
Local $R_Age, $R_Power, $R_Run, $R_Fight
;=== Age ===
For $A = '0' To '8'
If GUICtrlRead ($Age) = $A Then $R_Age = '1'
Next
For $A = '9' To '13'
If GUICtrlRead ($Age) = $A Then $R_Age = '2'
Next
For $A = '14' To '17'
If GUICtrlRead ($Age) = $A Then $R_Age = '3'
Next
For $A = '18' To '50'
If GUICtrlRead ($Age) = $A Then $R_Age = '4'
Next
If GUICtrlRead ($Age) > '50' And GUICtrlRead ($Age) < '1000001' Then $R_Age = '3'
;=== Power ===
For $A = '0' To '20'
If GUICtrlRead ($Power) = $A Then $R_Power = '1'
Next
For $A = '21' To '40'
If GUICtrlRead ($Power) = $A Then $R_Power = '2'
Next
For $A = '41' To '60'
If GUICtrlRead ($Power) = $A Then $R_Power = '3'
Next
For $A = '61' To '80'
If GUICtrlRead ($Power) = $A Then $R_Power = '4'
Next
For $A = '81' To '100'
If GUICtrlRead ($Power) = $A Then $R_Power = '6'
Next
If GUICtrlRead ($Power) > '100' And GUICtrlRead ($Power) < '1000001' Then $R_Power = '8'
;=== Run ===
For $A = '0' To '10'
If GUICtrlRead ($Run) = $A Then $R_Run = '1'
Next
For $A = '11' To '30'
If GUICtrlRead ($Run) = $A Then $R_Run = '2'
Next
For $A = '31' To '50'
If GUICtrlRead ($Run) = $A Then $R_Run = '3'
Next
If GUICtrlRead ($Run) > '50' And GUICtrlRead ($Run) < '1000001' Then $R_Run = '4'
;=== Fight ===
If GUICtrlRead ($Fight) = '0' Then $R_Fight = '0'
If GUICtrlRead ($Fight) = '1' Then $R_Fight = '8'
If GUICtrlRead ($Fight) = '2' Then $R_Fight = '10'
If GUICtrlRead ($Fight) = '3' Then $R_Fight = '13'
If GUICtrlRead ($Fight) = '4' Then $R_Fight = '14'
If GUICtrlRead ($Fight) = '5' Then $R_Fight = '17'
If GUICtrlRead ($Fight) = '6' Then $R_Fight = '20'
If GUICtrlRead ($Fight) = '7' Then $R_Fight = '22'
If GUICtrlRead ($Fight) = '8' Then $R_Fight = '23'
If GUICtrlRead ($Fight) = '9' Then $R_Fight = '24'
If GUICtrlRead ($Fight) = '10' Then $R_Fight = '25'
If GUICtrlRead ($Fight) > '10' Then $R_Fight = '27'
Return $R_Age + $R_Power + $R_Run + $R_Fight
EndFunc

Func _Exit ()
Exit
EndFunc

That is good but this part dont work

;=== Fight ===
If GUICtrlRead ($Fight) = '0' Then $R_Fight = '0'
If GUICtrlRead ($Fight) = '1' Then $R_Fight = '8'
If GUICtrlRead ($Fight) = '2' Then $R_Fight = '10'
If GUICtrlRead ($Fight) = '3' Then $R_Fight = '13'
If GUICtrlRead ($Fight) = '4' Then $R_Fight = '14'
If GUICtrlRead ($Fight) = '5' Then $R_Fight = '17'
If GUICtrlRead ($Fight) = '6' Then $R_Fight = '20'
If GUICtrlRead ($Fight) = '7' Then $R_Fight = '22'
If GUICtrlRead ($Fight) = '8' Then $R_Fight = '23'
If GUICtrlRead ($Fight) = '9' Then $R_Fight = '24'
If GUICtrlRead ($Fight) = '10' Then $R_Fight = '25'
If GUICtrlRead ($Fight) > '10' Then $R_Fight = '27'

This program Calculate a "Power"

User put answer for questions Age, strange(power) , Run (RUNNING) , Fight (skill in matrial arts)

and see total score if he have 20 yrs take 4 ponit he training 6 yrs so take 20 points ...

This Code calculate corectly onlt Age + Power + Run but Fight dont work and i can't repair this part of code

Share this post


Link to post
Share on other sites

But this isnt my code...

Share this post


Link to post
Share on other sites

becaouse your code dont work corect

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