232showtime Posted April 3, 2017 Posted April 3, 2017 (edited) Hello, I got little problem with this UDF found in wiki, Just copy paste from wiki and got an error, got really confused this time. #include <MsgBoxConstants.au3> testme() Func testme($param1, $param2 = "nothing", $param3 = 5) MsgBox($MB_OK, "", "Parameter one is required. The value of Parameter 1 is " & $param1 & @CRLF & _ "Parameter 2 is optional. The value of Parameter 2 is " & $param2 & @CRLF & _ "Parameter 3 is optional. The value of Parameter 3 is " & $param3) EndFunc ;==>testme ;"C:\Users\user\Desktop\Script\UserDefinedFunction.au3"(4,55) : error: testme() called by a previous line with 0 arg(s). Min = 1. ;First previous line calling this Func is 3. ;Func testme($param1, $param2 = "nothing", $param3 = 5) Edited April 3, 2017 by 232showtime I dont understand the error and why its not workin... 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.
TheDcoder Posted April 3, 2017 Posted April 3, 2017 (edited) Isn't the first parameter required? #include <MsgBoxConstants.au3> testme("required") Func testme($param1, $param2 = "nothing", $param3 = 5) MsgBox($MB_OK, "", "Parameter one is required. The value of Parameter 1 is " & $param1 & @CRLF & _ "Parameter 2 is optional. The value of Parameter 2 is " & $param2 & @CRLF & _ "Parameter 3 is optional. The value of Parameter 3 is " & $param3) EndFunc ;==>testme Edited April 3, 2017 by TheDcoder Added code snippet 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
232showtime Posted April 3, 2017 Author Posted April 3, 2017 oh shoot, I already tried $param1 = 1 i received an error earlier, I did it again and it works, I wonder why??? thats why i got confused... 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.
TheDcoder Posted April 3, 2017 Posted April 3, 2017 Just now, 232showtime said: I did it again and it works, I wonder why??? thats why i got confused... Happens 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
Subz Posted April 3, 2017 Posted April 3, 2017 Quote I already tried $param1 = 1 i received an error earlier What do you mean you tried $param1 = 1?
232showtime Posted April 3, 2017 Author Posted April 3, 2017 (edited) I declared $param1 = 1 and got an error, I copy paste again the code and declared $param1 = 1 and it worked, thats why I got confused. Func testme($param1=1, $param2="Nothing", $param3=3) MsgBox($MB_OK, "", "Parameter one is required. The value of Parameter 1 is " & $param1 & @CRLF & _ "Parameter 2 is optional. The value of Parameter 2 is " & $param2 & @CRLF & _ "Parameter 3 is optional. The value of Parameter 3 is " & $param3 ) EndFunc Edited April 3, 2017 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.
Subz Posted April 3, 2017 Posted April 3, 2017 That would mean $param1 is no longer required, it's optional, if you look at Dcoders post# 2 above, the $param1 variable is required, which means you must give $param1 a value e.g. testme("Here is Param1"). Hope that made sense.
232showtime Posted April 3, 2017 Author Posted April 3, 2017 yep thanks @TheDcoder @Subz ... 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.
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