EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  <20052006  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  <20052006  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: Andrew Johnson <[email protected]>
To: Emmanuel Mayssat <[email protected]>
Cc: [email protected]
Date: Fri, 28 Jan 2005 17:03:55 -0600
Emmanuel Mayssat wrote:

I was thinking about using a registar function as follow: default("${BR}",9600) that would check the value or $BR and if not set, then put 9600. (and so far nobody mentioned that solution!! )

Actually that was one of my earlier suggestions.


but what I really want to do is an if then else in iocsh

You're welcome to try to add an if-then-else command to your own version of iocsh, since EPICS is Open Source. However we're not likely to accept any patches that implement this into the official release because we don't want the iocsh to become Yet Another Programming Language. Eric Norum has in the past linked the tcl language up to EPICS so you can write startup scripts in tcl if you want to do intelligent processing in them, although his code was never published.


My point was that setting a default in the way you're suggesting could very easily cause you problems, whether you add an if-then-else construct to iocsh or write a defaultEnv(variable, value) command. Imagine two dbload files with this pseudocode:

a.dbl:
  if unset(X) then X=1
  dbLoadRecords a.db, X=${X}

b.dbl:
  if unset(X) then X=2
  dbLoadRecords b.db, X=${X}

If we execute these in this order with X unset:
  < a.dbl
  < b.dbl
the dbLoadRecords commands will expand out to this:
  dbLoadRecords a.db, X=1
  dbLoadRecords b.db, X=1
whereas if we execute them in the reverse order:
  < b.dbl
  < a.dbl
they will expand out to this:
  dbLoadRecords b.db, X=2
  dbLoadRecords a.db, X=2

I'm just warning you to be prepared for this to happen.

- Andrew
--
Dear God, I didn't think orange went with purple until I saw
the sunset you made last night.  That was really cool. - Caro

References:
if-then-else in iocsh Emmanuel Mayssat
Re: if-then-else in iocsh Andrew Johnson
Re: if-then-else in iocsh Maren Purves
Re: if-then-else in iocsh Emmanuel Mayssat
Re: if-then-else in iocsh Andrew Johnson
Re: if-then-else in iocsh Emmanuel Mayssat

Navigate by Date:
Prev: Re: if-then-else in iocsh Emmanuel Mayssat
Next: Re: if-then-else in iocsh Emmanuel Mayssat
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  <20052006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: if-then-else in iocsh Emmanuel Mayssat
Next: mbbo strings linked to mbbo commands Emmanuel Mayssat
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  <20052006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 02 Sep 2010 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·