Jump to content

Problem with multi " Func "


Recommended Posts

I want see two results so i used two func but i see only each result :)

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

Opt ('GUIOnEventMode','1')

$Form1 = GUICreate("Form1", 305, 256, 192, 118)
$Label1 = GUICtrlCreateLabel("Ile lat palisz", 16, 16, 140, 25)
$Label2 = GUICtrlCreateLabel("Ile paczek na dobe", 16, 56, 140, 25)
$Label3 = GUICtrlCreateLabel("Cena paczki w zl", 16, 96, 140, 25)
$lata = GUICtrlCreateInput(" ", 168, 16, 65, 21)
$paczki = GUICtrlCreateInput(" ", 168, 56, 65, 21)
$cena = GUICtrlCreateInput(" ", 168, 96, 65, 21)
$Start = GUICtrlCreateButton("Button1", 80, 216, 145, 33, 0)

$lblwynik1 = GUICtrlCreateLabel("Na papierosy wydales : ", 16, 156, 140, 25)
$lblwynik = GUICtrlCreateLabel(" ", 140, 156, 140, 25)

$lblwynik3 = GUICtrlCreateLabel("Wypaliles : ", 16, 186, 140, 25)
$lblwynik2 = GUICtrlCreateLabel(" ", 140, 186, 140, 25)


GUISetOnEvent ($GUI_EVENT_CLOSE, '_Exit')

GUICtrlSetOnEvent ($Start, '_Start' )
GUICtrlSetOnEvent ($Start, '_Start2' )

GUISetState(@SW_SHOW, $Form1)

While '1'
Sleep ('150')
WEnd




Func _Start ()
GUICtrlSetData($lblwynik,_Result() & ' zl ')
EndFunc


Func _Result ()
    
$a_lata = GUICtrlRead($lata)
$a_paczki = GUICtrlRead($paczki)
$a_cena = GUICtrlRead($cena)

$rok = 365

$dni_palenia = ($a_lata * $rok)

$ilosc_paczek = ($dni_palenia * $a_paczki)

$wynik  = ($ilosc_paczek * $a_cena)


Return $wynik
EndFunc



Func _Start2 ()
GUICtrlSetData($lblwynik2,_Result2() & ' sztuk ')
EndFunc


Func _Result2 ()
    
$a_lata = GUICtrlRead($lata)
$a_paczki = GUICtrlRead($paczki)


$rok = 365
$fajki = 20

$dni_palenia = ($a_lata * $rok)

$ilosc_paczek = ($dni_palenia * $a_paczki)

$wynik2  = ($ilosc_paczek * $fajki)


Return $wynik2
EndFunc

How can I put more result in one Func ?

Link to comment
Share on other sites

difficult to understand as not English so i dont know what your doing really but did you want

Func _Start()
    GUICtrlSetData($lblwynik, _Result() & ' zl ')
    GUICtrlSetData($lblwynik2, _Result2() & ' zl ')
EndFunc  ;==>_Start

in the _start() func ?

also you have

GUICtrlSetOnEvent ($Start, '_Start' )

GUICtrlSetOnEvent ($Start, '_Start2' )

but you can only set the $start button to 1 func

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Link to comment
Share on other sites

So i cant make two difrent result when push one buton ??

I want to start two functions in one button or one function but two results

Tomorrow i change my code to English

Edited by Quzziy
Link to comment
Share on other sites

well yea you can, did you try the added line i showed you ?

your line...

GUICtrlSetData($lblwynik, _Result() & ' zl '); so this one does the first func and displays the results in $lblwynik

add my line...

GUICtrlSetData($lblwynik2, _Result2() & ' zl '); and this does the second func and displays these results in $lblwynik2

o and dont forget to take out this line GUICtrlSetOnEvent ($Start, '_Start2' )

so you have got your two results .

is this not what your after?

Edited by JackDinn

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Link to comment
Share on other sites

change these 2 lines to round() them up/down :)

$wynik =Round(($ilosc_paczek * $a_cena))

$wynik2 = Round(($ilosc_paczek * $fajki))

Edited by JackDinn

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

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