The symclear function clears the macro symbol table of any
stored macro variables and macro functions. The function is used
to avoid contamination between one call to msource and the
next. It is called automatically when the "clear" parameter of
msource is set to TRUE. If the "clear" parameter is
set to FALSE, you can clear the symbol table manually with
the symclear function.
symclear(variables = TRUE, functions = TRUE)The number of objects cleared, invisibly. The function also outputs a message saying how many objects were cleared.
Other symtable:
print.symtable(),
symget(),
symput(),
symtable()
library(macro)
# Get path to demo macro program
src <- system.file("extdata/Demo4.R", package = "macro")
# Display source code
# - This is the macro input code
cd <- readLines(src)
cat(paste(cd, "\n"))
# #% Create some macro variables
# #%let x <- 1
# #%let y <- 2
# #%let z <- &x + &y
#
# #% Create a macro function
# #%macro test(vl = Hello!)
# print("&vl")
# #%mend
# Execute source code
msource(src, echo = FALSE)
# View symbol table
symtable()
# # Macro Symbol Table: 3 macro variables
# Name Value
# 1 &x 1
# 2 &y 2
# 3 &z 1 + 2
# # Macro Function List: 1 macro functions
# Name Parameter Default
# 1 test vl Hello!
# Clear symbol table
symclear()
# Clearing macro symbol table...
# 4 items cleared.
# View symbol table again
symtable()
# # Macro Symbol Table: (empty)
# # Macro Function List: (empty)