Name:
#macro
Syntax:

#MACRO label(param1, param2...)

(code goes here)

#ENDMACRO

 

 

Description:

Allows a multi-line substitution macro to be defined.

Wherever the defined macro label name is found within the program source that name will be replaced by the contents of the macro (with parameters substituted with the values specified). Please see macros within part 2 of the PICAXE manual for more details.

As a macro is processed as a 'text substitution' before compilation it cannot contain any other directive.

Applies To:
All
See Also:
Related Create:
    Share:
    Print:

    Macro Expansion

    A simple macro to display a number on line one of an LCD

    Code Example:
    ; Original source code -
    
    symbol lcdpin = B.7
    
    #macro lcdout( delay, number )
    	serout lcdpin, n2400, ( 254, 128, #number, "    " )
    	pause delay
    #endmacro
    
    main:
    	lcdout( 100, w0 )
    	w0 = w0 + 1
    	pause 1000
    	goto main
    
    ; Equivalent to -
    
    symbol lcdpin = B.7
    
    main:
    	serout lcdpin, n2400, ( 254, 128, #w0, "    " )
    	pause 100
    	w0 = w0 + 1
    	pause 1000
    	goto main
    Copy Code Submit an Example

    Submit Your Own Code!

    You must be logged in to submit code examples. Login now.

    Comments

    • Login to leave a comment.