octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #34145] need for ifdef test


From: anonymous
Subject: [Octave-bug-tracker] [bug #34145] need for ifdef test
Date: Sat, 27 Aug 2011 00:03:02 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.2.20) Gecko/20110822 Gentoo

URL:
  <http://savannah.gnu.org/bugs/?34145>

                 Summary: need for ifdef test
                 Project: GNU Octave
            Submitted by: None
            Submitted on: Sat 27 Aug 2011 12:03:01 AM UTC
                Category: None
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Feature Request
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 3.4.0
        Operating System: Any

    _______________________________________________________

Details:

It seems there is not direct way to test whether a variable has been defined
or not. 

Since both NA and NaN are actually assigned values it does not seem there is a
basic test for unassigned variables. 

A work around is a try... catch structure around an attempt to reference the
variable  but it's a bit messy . 

isdef(varname)  could be cleaner unless I'm missing a trick. 


try
 i=i;
catch 
 i=1;
end_catch_try


if ! isdef(i) i=1;

OR 

isdef(i,1);  # to provide a default value.




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?34145>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]