Software: Apache. PHP/8.1.30 uname -a: Linux server1.tuhinhossain.com 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root) Safe-mode: OFF (not secure) /usr/share/doc/groff-base/html/ drwxr-xr-x |
Viewing file: Select action/file-type: [ prev | next | top ] 14. MacrosYou can define macros in pic, with up to 32 arguments (up to 16 on EBCDIC platforms). This is useful for diagrams with repetitive parts. In conjunction with the scope rules for block composites, it effectively gives you the ability to write functions. The syntax is define name { replacement text } This defines name as a macro to be replaced by the replacement text (not including the braces). The macro may be called as name(arg1, arg2, ... argn) The arguments (if any) are substituted for tokens $1, $2 ... $n appearing in the replacement text. As an example of macro use, consider this: .PS
#
Count on end ] to reset these box
fill (!$1) with .s at center of Outer; #
Plot a block of six jumpers. jwidth
= last [].Outer.wid; box with .nw at 6th last [].nw wid 6*jwidth ht jheight; #
Use {} to avoid changing position from last box draw. #
Sample macro invocations. It yields the following: Figure 14-1: Sample use of a macro This macro example illustrates how you can combine [], brace grouping, and variable assignment to write true functions. One detail the example above does not illustrate is the fact that macro argument parsing is not token-oriented. If you call jumper( 1 ), the value of $1 is " 1 ". You could even call jumper(big string) to give $1 the value "big string". If you want to pass in a coordinate pair, you can avoid getting tripped up by the comma by wrapping the pair in parentheses. Macros persist through pictures. To undefine a macro, say undef name; for example, undef
jumper would undefine the two macros in the jumper block example. [ prev | next | top ] |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0051 ]-- |