static void Macros(Args _args)
{
str sTest;
int iTest = 8;
;
setPrefix("1.Macro define and undefine");
#define.MyMacro // MyMacro is now defined.
#if.MyMacro
sTest = "Yes, MyMacro is defined.";
info(sTest);
#endif
#undef.MyMacro
#ifnot.MyMacro
sTest = "No, MyMacro is not defined.";
info(sTest);
#endif
setPrefix("2.ReDefining Macro");
#define.MyMacro(32)
// This next #define, which has no value for the macro name,
// would not disrupt the value 32 set by the previous #define.
//#define.MyMacro
// This next #define, which has a different value than 32,
// would overwrite the value 32 set by the previous #define.
#define.MyMacro(444)
iTest = #MyMacro;
info(int2str(iTest));
setPrefix("3.if test On macros");
#define.MyIntMacro(66)
// #if tests.
#if.MyIntMacro()
info("A: " + int2str(#MyIntMacro));
#endif
#if.MyIntMacro(66)
info("B: " + int2str(#MyIntMacro));
#endif
// #ifNOT tests.
#ifNOT.MyIntMacro(7777)
info("C: " + int2str(#MyIntMacro));
#endif
#ifNOT.No_Such_Macro_Name(66)
info("D: " + int2str(#MyIntMacro));
#endif
setPrefix("4.debugging macros");
// Uncomment either one of these defines, or neither.
//#define.DebugMacro(light) // This line for: light debugging.
#define.DebugMacro(heavy) // This line for: heavy debugging.
#if.DebugMacro
info("Starting the job.");
#endif
#if.DebugMacro(heavy)
info("UTC == "+ DateTimeUtil ::toStr(DateTimeUtil::utcNow()));
#endif
// Do something useful here.
setPrefix("5.Macros are Case insensitive");
// Macros are Case insensitive
#LOcalMAcro.YOurLM
info("From YOurLM localmacro.");
#ENdMAcro
#yoURLM // Mismatched casing of the macro name symbol.
//----------- #define --------
#deFine.MyMaCRO("TheVaLUE")
// Mismatched casings, in macro name, and in parentheses.
#iF.mYmacro("ThEvaLUE")
info("The # if test for value is case-insensitive for the value.");
#eNdif
setPrefix("6.Macro Incrementing and decrementing");
#define.CounterMacroA(1)
#defInc.CounterMacroA //incrementing
info("Macro after incrementing " + int2str(#CounterMacroA));
#defDec.CounterMacroA //decrementing
info("Macro after decrementing " + int2str(#CounterMacroA));
setPrefix("7.Negative and Big Macros");
#define.Macro(-121)
info("My negative macro is" + int2str(#Macro));
#defInc.Macro
info("My negative macro after incrementing is" + int2str(#Macro));
#define.Macro1(2147483647)
info("My Big macro is" + int2str(#Macro1));
#defInc.Macro1
info("My big macro after incrementing is" + int2str(#Macro1));
setPrefix("8.Passing values to macro");
#define.MyMacro("One == [%1] , Two == [%2]")
// Make parameter substitutions:
info("AA: " + #MyMacro(Apple));
info("BB: " + #MyMacro(Apple,Banana));
info("CC: " + #MyMacro(Apple, Banana, cranberry));
info("DD: " + #MyMacro(,Apple,Banana));
info("EE: " + #MyMacro());
info("FF: " + #MyMacro);
setPrefix("9.Local and global macros");
#localmacro.LMacReportLog
// print("%1 --LM, print.");
info("%1 --LM, Infolog.");
#endmacro
#LMacReportLog(g11: Hello World )
#if.LMacReportLog
info("The # IF LMacReportLog is true");
#endif
#undef.LMacReportLog
#LMacReportLog(g22: Greetings World)
#localmacro.LMacReportLog
#endmacro // No lines for value before this end.
#LMacReportLog(g33: Bye Bye) // Not present in the output.
//pause;
setPrefix("10.Overriding the macros local vs Global");
//Overridding the macros(Local and then global)
#localmacro.LGMa
info("LGMa: Loc 11");
#endmacro
#globalmacro.LGMa
info("LGMa: Glob 12");
#endmacro
#LGMa
//--------- LGMb , G then L ---------
#globalmacro.LGMb
info("LGMb: Glob 24");
#endmacro
#localmacro.LGMb
info("LGMb: Loc 25");
#endmacro
#LGMb
}
No comments:
Post a Comment