Character: ALT+ (NumPad) 01, used as the leading/ending char in ArgCheckDefault and Default.
Code:
+#a::
TEST_Function("", "FOO")
TEST_FUNCTION("FOO", "", "BAR", "")
TEST_FUNCTION()
return
ArgCheckDefault( byRef blankParam, var1="ArgCheckDefault", var2="ArgCheckDefault", var3="ArgCheckDefault", var4="ArgCheckDefault", var5="ArgCheckDefault" )
{
blankParam := 0, defaultCount := 0, numParams := 0
Loop, 5
{
numParams++
tmpV := var%A_Index%
if( tmpV == "" && ++blankParam )
continue
if( tmpV == "DEFAULT" && ++defaultCount )
continue
if( tmpV == "ArgCheckDefault" && --numParams )
break
}
return ( numParams - defaultCount )
}
TEST_Function(aVar="DEFAULT", bVar="DEFAULT", cVar="DEFAULT", dVar="DEFAULT")
{
A_ParamCount := ArgCheckDefault( blankParam, aVar, bVar, cVar, dVar )
MsgBox,,, % "User Provided: " A_ParamCount " args to " A_ThisFunc ", of which " blankParam " were blank (`"`")",3
aVar := ( aVar == "" || aVar == "DEFAULT" ) ? "SomeValue" : aVar
; etc.
return
}
Of course, personally I wouldn't use that, nor have I come across an instance where I need to know how many args were actually passed to a function.
I do something like this:
Code:
TC_CD( src="", trg="", newTab="", srcTrg="", keepSelect="", wID="", wControl="", allowMin="" )
{ ;;
;; Defaults: SameTab, LeftRight
;;
Global @TC@_AllowMin ; Global default for Allow cmds to be sent to TC while Minimized.
Global @TC@_CDSelect ; Global TC_CD() default: Keep "CD" Selected Files.
Global @TC@_CDNewTab ; Global TC_CD() default: Open "CD" in a new Tab.
Global @TC@_CDSrcTrg ; Global TC_CD() default: Use Active Panel as "Source", instead of
;; ; Absolute Left/Right positioning.
;;
;; NOTE: All Global _defaults_ can be overridden by simply
;; providing the variable in the Function parameters.
;;
onErrorExit( !src && !trg, A_ThisFunc, "No Path Parameters." )
QueryID( wID, "ahk_class TTOTAL_CMD" )
allowMin := ( allowMin == "" ? ( @TC@_AllowMin ? 1 : 0 ) : allowMin )
keepSelect := ( keepSelect == "" ? ( @TC@_CDSelect ? 1 : 0 ) : keepSelect )
newTab := ( newTab == "" ? ( @TC@_CDNewTab ? 1 : 0 ) : newTab )
srcTrg := ( srcTrg == "" ? ( @TC@_CDSrcTrg ? 1 : 0 ) : srcTrg )