1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 <2005> 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 | Index | 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 <2005> 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 |
<== Date ==> | <== Thread ==> |
---|
Subject: | Re: if-then-else in iocsh |
From: | Maren Purves <[email protected]> |
To: | Emmanuel Mayssat <[email protected]> |
Cc: | [email protected] |
Date: | Fri, 28 Jan 2005 10:43:30 -1000 |
Emmanuel Mayssat wrote:
I use "dbLoad" files such as this one:
<snip>
Now, I would like to include in my dbl files a command that says: If this variable is not set, then set it to this value.
This technique appears to be somewhat fragile (meaning you must be careful if you decide to use it). It's probably fine if you have a small number of .dbl files and can keep track of all the variables that each one needs, but what happens if you should re-use a variable name (with different default values) in two different dbl files? The first dbl file would set the value it wants as the default, but the second file would always see the earlier file's default setting (because the variable was never unset), even if the user really wanted to use the second dbl file's default. Swapping the order in which you execute the two dbl files would change what is loaded into the database!
I would suggest that you require that the parent script must set *all* parameters that a dbl file relies on itself, or load a single default settings file early on like Eric suggested.
If you don't intend to change it once the iocInit is done, why not get it in at the "make" stage, and substitute the variables there, allowing you to check in the built script what you're actually going to end up with in the ioc?