Tripoz Posted June 21, 2015 Share Posted June 21, 2015 (edited) Hi,i have some code like: While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $Button1 test1() test2() test3() OP() EndSwitch WEndfunc test1();;;;if statement with many conditionEndFuncFunc test2();;;;if statement with many conditionEndFuncFunc test3();;;;if statement with many conditionEndFuncFUnc OP();;;how to read the result of Func test1() ????$aaa = call(Test1)if test1() = "XXXXX" and test2() = "YYYYY" AND test3() = "zzzzz" thenconsolewrite("success!")elseconsolewrite("unsuccess!")EndFunc is there any way to Read the result of each Func like i write in Func OP()?thx for anyhelp.. Edited June 21, 2015 by Tripoz Link to comment Share on other sites More sharing options...
kaisies Posted June 21, 2015 Share Posted June 21, 2015 Look into return Link to comment Share on other sites More sharing options...
Tripoz Posted June 21, 2015 Author Share Posted June 21, 2015 Look into returnim too nubie...still confusehow can i get the result from Func test1() and write it in other Function (func OP() in my case ???thx for any help Link to comment Share on other sites More sharing options...
water Posted June 21, 2015 Share Posted June 21, 2015 You really need to start learning how AutoIt works. The help file and the wiki with many tutorials are good starting points.func test1() ;;;;if statement with many condition Return "xxxx" EndFuncBTW:No need to use call here$aaa = call(Test1)simply use$aaa = Test1() 232showtime 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Tripoz Posted June 21, 2015 Author Share Posted June 21, 2015 @water thx btw..but i dont know where to start so i just writing the code for my project n i had stucked..i change my code to be like this??its right?While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $Button1 OP() EndSwitch WEnd func test1() if $kemana1 > $Kemana2 Then SLEEP(1000) ConsoleWrite("Dibawah") return "Dibawah" Else SLEEP(1000) ConsoleWrite("Diatas") return "Diatas" EndIf EndFunc Func OP() $aaa = test1() if $aaa = "Dibawah" then consolewrite("success!") elseif $aaa = "Diatas" then consolewrite("unsuccess!") EndIf EndFunc Link to comment Share on other sites More sharing options...
Developers Jos Posted June 21, 2015 Developers Share Posted June 21, 2015 Not sure why you ask the question ... have you tried and did it work?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 More sharing options...
TheDcoder Posted June 21, 2015 Share Posted June 21, 2015 Please watch Morthwart's great AutoIt tutorials! TD P.S I learned AutoIt using these videos 232showtime 1 EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
water Posted June 21, 2015 Share Posted June 21, 2015 Looks good so far.But I think your script gets more complex than needed. As test1() only contains a simple If/Then/Else I suggest to simplify to:While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 OP() EndSwitch WEnd Func OP() If $Kemana1 > $Kemana2 Then ConsoleWrite("Dibawah - success" ) Else ConsoleWrite("Diatas - no success") EndIf EndFunc My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
232showtime Posted June 21, 2015 Share Posted June 21, 2015 (edited) good day @water,im confused also with this return, question is whats the difference between a return with Msgbox and MsgBox only... Script with Return+msgboxmax(3, 2) Func max($x, $y) If $x > $y Then Return MsgBox(64, "", $x) Else Return MsgBox(64, "", $y) EndIf EndFunc ;==>max Script with MsgBox onlymax(3, 2) Func max($x, $y) If $x > $y Then MsgBox(64, "", $x) Else MsgBox(64, "", $y) EndIf EndFunc ;==>maxT_Twhats the use of Return? Edited June 21, 2015 by 232showtime ill get to that... i still need to learn and understand a lot of codes Correct answer, learn to walk before you take on that marathon. Link to comment Share on other sites More sharing options...
water Posted June 21, 2015 Share Posted June 21, 2015 Return MsgBox(64, "", $x)simply saves some lines of code.Return leaves the function after having displayed the MsgBox.Example:Func Test($sValue) If $sValue <> "A" Then Return MsgBox(64, "Error", "Invalid value for $sValue!") ; More ; Statements EndFunc 232showtime 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted June 21, 2015 Share Posted June 21, 2015 Another aspect:As the return value of MsgBox is the ID of the button pressed function Test returns this ID to the calling function.Most of the time this information is ignored by the script. 232showtime 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
232showtime Posted June 21, 2015 Share Posted June 21, 2015 Return MsgBox(64, "", $x)simply saves some lines of code.Return leaves the function after having displayed the MsgBox.Example:Func Test($sValue) If $sValue <> "A" Then Return MsgBox(64, "Error", "Invalid value for $sValue!") ; More ; Statements EndFunc this explains well, now i know how to use Return. thanks ill get to that... i still need to learn and understand a lot of codes Correct answer, learn to walk before you take on that marathon. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now