constant namespace (module?)
mas
Is there a way to limit the namespaces for constants similar to modules do for Functions? The following doesn't work: -- Procedure "testc.ipf" #pragma TextEncoding = "UTF-8" #pragma rtGlobals=3 #pragma moduleName=xxx Static Constant ktest = 42 -- Procedure #pragma TextEncoding = "UTF-8" #pragma rtGlobals=3 Function doit() Variable x x = xxx#ktest print "x is", x End The callers of my functions needs access to several constants (the same and/or different constants for each function). These functions include both Igor procedures/functions and XOP/functions. I'm worried about namespace collisions on the constant names. PS: What about Structures too? This seems less of a problem to me since I can use a very long name for the structure as the structure name will appear less often (and the STRUCT variable is local).
You can make constants static (local to a file).
Accessing the constant from outside that file using moduleName#constantName isn't supported (yet), but you can use a static function that returns the constant and call that static function using the module name.
#pragma TextEncoding = "UTF-8"
#pragma rtGlobals=3
#pragma moduleName=xxx
Static Constant ktest = 42
Static Function Get_ktest()
return ktest
End
-- Procedure
#pragma TextEncoding = "UTF-8"
#pragma rtGlobals=3
Function doit()
Variable x
x = xxx#Get_ktest()
print "x is", x
End
September 7, 2021 at 05:53 pm - Permalink
Is there a timeline for being able to access static constants from another proc file using the moduleName#constantName syntax?
July 13, 2022 at 01:10 pm - Permalink
It is an Igor 10 feature.
July 13, 2022 at 03:50 pm - Permalink
Thanks!
July 15, 2022 at 05:13 am - Permalink