imgsimonebiliato Well-Known Member Licensed User Longtime User Jan 30, 2017 #1 Hello, is it possibile to create a sub like this: Code: Copy Public Sub Query (aSql As String, aLog As Boolean = False) End Sub and call: Code: Copy Query("SELECT * FROM ART") where the parameter "aLog" is false by default, and only if I want to set true, I need to call it: Code: Copy Query("SELECT * FROM ART", True)
Hello, is it possibile to create a sub like this: Code: Copy Public Sub Query (aSql As String, aLog As Boolean = False) End Sub and call: Code: Copy Query("SELECT * FROM ART") where the parameter "aLog" is false by default, and only if I want to set true, I need to call it: Code: Copy Query("SELECT * FROM ART", True)
eurojam Well-Known Member Licensed User Longtime User Jan 30, 2017 #3 you can pass an array oject, something like Code: Copy Query(Array As Object("SELECT * FROM ART", TRUE)) Upvote 0
you can pass an array oject, something like Code: Copy Query(Array As Object("SELECT * FROM ART", TRUE))
Erel B4X founder Staff member Licensed User Longtime User Jan 31, 2017 #4 Note that you don't need to write As Object: Code: Copy Query(Array("SELECT * FROM ART", True)) Another (better) option is to pass a Map: Code: Copy Query (CreateMap("query": "SELECT ...")) Sub Query(Params As Map) Dim q As String = Params.Get("query") Dim aLog As Boolean = Params.GetDefault("aLog", True) End Sub Upvote 0
Note that you don't need to write As Object: Code: Copy Query(Array("SELECT * FROM ART", True)) Another (better) option is to pass a Map: Code: Copy Query (CreateMap("query": "SELECT ...")) Sub Query(Params As Map) Dim q As String = Params.Get("query") Dim aLog As Boolean = Params.GetDefault("aLog", True) End Sub
imgsimonebiliato Well-Known Member Licensed User Longtime User Feb 1, 2017 #5 I don't like these solutions, because they complicate and lengthen the code. I need the 'OptionalParameter' to avoid writing useless code. Are there any other solutions? Upvote 0
I don't like these solutions, because they complicate and lengthen the code. I need the 'OptionalParameter' to avoid writing useless code. Are there any other solutions?
Erel B4X founder Staff member Licensed User Longtime User Feb 1, 2017 #6 imgsimonebiliato said: I don't like these solutions, because they complicate and lengthen the code Click to expand... Ok. As written above optional parameters are not supported. Upvote 0
imgsimonebiliato said: I don't like these solutions, because they complicate and lengthen the code Click to expand... Ok. As written above optional parameters are not supported.