Skip to content

FB_ARG_LISTEXPAND


Intrinsic define (macro) performed by the compiler.

Syntax

` FB_ARG_LISTEXPAND( macroname, macroargcount, args... )

`

Parameters

macroname

name of the macro used for extension calls

macroargcount

number of parameters for the 'macroname' macro

expand the parameter list 'args...' according to the 'macroargcount' value:

  • 'macroargcount > 0' : pass 'macroargcount' parameters each time

  • 'macroargcount = 0' : pass all parameters

  • 'macroargcount < 0' : for each parameter passed, the previous 'macroargcount' parameters are automatically removed on the next pass

args...

argument list

Description

Expands to one or more 'macroname( .... )' depending on the value of macroargcount and number of arguments in the args... list.

Returns empty string on invalid index, rather than compile error.

Examples

start GeSHi

vb
#macro m( arg... )
    #print "   "##arg
#endmacro

#print "macroargcount>0 (=1):"
__FB_ARG_LISTEXPAND__( m, 1, Hello1, Hello2, Hello3, Hello4)
#print " "
#print "macroargcount=0 (=0):"
__FB_ARG_LISTEXPAND__( m, 0, Hello1, Hello2, Hello3, Hello4)
#print " "
#print "macroargcount<0 (=-1):"
__FB_ARG_LISTEXPAND__( m, -1, Hello1, Hello2, Hello3, Hello4)

/' Compiler output:
macroargcount>0 (=1):
   Hello1
   Hello2
   Hello3
   Hello4
 
macroargcount=0 (=0):
   Hello1, Hello2, Hello3, Hello4
 
macroargcount<0 (=-1):
   Hello1, Hello2, Hello3, Hello4
   Hello2, Hello3, Hello4
   Hello3, Hello4
   Hello4
'/

end GeSHi

Version

  • Since fbc 1.20.0

Differences from QB

  • New to FreeBASIC

See also

  • __FB_ARG_RIGHTOF__
  • __FB_ARG_LEFTOF__
  • __FB_ARG_COUNT__
  • __FB_ARG_EXTRACT__

Back to DocToc

Translated from FreeBASIC official docs. Contact us for removal if infringed.
FreeBASIC is an open-source project, not affiliated with Microsoft