From 301aa446f4fc3b185cc067433206dd7fc9f96874 Mon Sep 17 00:00:00 2001 From: Billingsly Wetherfordshire Date: Thu, 1 May 2014 11:13:57 -0700 Subject: [PATCH] Updated Tips and tricks (markdown) --- Tips-and-tricks.md | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Tips-and-tricks.md b/Tips-and-tricks.md index cd05adf..6514e46 100644 --- a/Tips-and-tricks.md +++ b/Tips-and-tricks.md @@ -7,14 +7,26 @@ You can use the slanted quote string syntax if you need to use a reserved word a ## Tricks with conditional compilation ```nimrod -const someFeature = True - -when someFeature: +when defined(useSomeFeature): const someSubFeature = true + type ID_Type = int32 + var defaultUserName = "Frank" else: - const someSubFeature = false + type ID_Type = int16 + var defaultUserName = "Molly" + +# `when` does not open a new scope, so `ID_Type` and `defaultUserName` +# are available here. + +when isMainModule: + #this code is ran only when this module is the main compilation module + echo "This module was compiled on ", CompileDate, " at ", CompileTime ``` +#### Defining `useSomeFeature` +* Do it when you compile: `$ nimrod c -d:useSomeFeature myApp` +* Put it in the local `nimrod.cfg` file `define:useSomeFeature` + ## How do I echo in a ``{.noSideEffects.}`` proc? You can use ``debugEcho`` for this. \ No newline at end of file