{{fbdoc item="title" value="__FB_ARG_COUNT__"}}----
Intrinsic define (macro) performed by the compiler.

{{fbdoc item="syntax"}}##
	""__FB_ARG_COUNT__( args... )""
##
{{fbdoc item="param"}}
	##//args...//##
		argument list

{{fbdoc item="desc"}}
	Counts the number of arguments in the argument list (##//args...//##) and returns the corresponding value.
	A value is always returned, with 0 corresponding to an empty argument list.
	
	Because the argument separator is the comma (,), the returned value for a non-empty argument list is the number of main commas (non-nested) plus 1.

{{fbdoc item="ex"}}
	{{fbdoc item="filename" value="examples/manual/defines/fbargcount.bas"}}%%(freebasic)
#macro m( args... )
	Print __FB_ARG_COUNT__( args )
#endmacro

m()
m(a)
m(b,c)
m(,d)
m(,e,)
m(,,,)

Sleep

/' Output:
 0
 1
 2
 2
 3
 4
'/
	%%
	{{fbdoc item="filename" value="examples/manual/defines/fbargcount2.bas"}}%%(freebasic)
' macro with a variadic parameter which can contain several sub-parameters:
'   To distinguish between the different arguments passed by a variadic_parameter,
'   you can first convert the variadic_parameter to a string using the Operator # (Preprocessor Stringize),
'   then differentiate in this string (#variadic_parameter) each passed argument by locating the separators (usually a comma)
'   in a [For...Next] loop based on the number of arguments (__FB_ARG_COUNT__) passed to the macro.

#macro average(result, arg...)
	Scope
		Dim As String s = #arg
		If s <> "" Then
			result = 0
			For I As Integer = 1 To __FB_ARG_COUNT__( arg ) - 1
				Dim As Integer k = InStr(1, s, ",")
				result += Val(Left(s, k - 1))
				s = Mid(s, k + 1)
			Next I
			result += Val(s)
			result /= __FB_ARG_COUNT__( arg )
		End If
	End Scope
#endmacro

Dim As Double result
average(result, 1, 2, 3, 4, 5, 6)
Print result

Sleep

/' Output :
 3.5
'/
	%%
{{fbdoc item="diff"}}
	- New to ""FreeBASIC""

{{fbdoc item="see"}}
	- ##[[KeyPgDdfbargleftof|__FB_ARG_LEFTOF__]]##
	- ##[[KeyPgDdfbargrightof|__FB_ARG_RIGHTOF__]]##
	- ##[[KeyPgDdfbargextract|__FB_ARG_EXTRACT__]]##

{{fbdoc item="back" value="CatPgDddefines|Intrinsic Defines"}}