help-octave
[Top][All Lists]
Advanced

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

Re: defining global values from C++ DLD-functions


From: Tim Piessens
Subject: Re: defining global values from C++ DLD-functions
Date: Mon, 3 Mar 2003 09:11:12 +0100 (MET)

On Sat, 1 Mar 2003, Paul Kienzle wrote:

> Tim Piessens wrote:
>
> >Hello,
> >
> >It seems that set_global_value() can be used to set a global value, but
> >I cannot find a function to define a global variable from a
> >dld-function. Does anyone have solution to do that ?
> >
> Did you try set_global_value()?  Looking at the
> code, it does global_sym_tab->lookup(name,true),
> which if I read the code for lookup correctly, means
> that a new symbol will be defined if it is not found.
>

This does not seem to be correct. I have tested this with the following
small example :

DEFUN_DLD(test, args, nargout, "Testing set_global_value() \n")
{
        set_global_value(args(0).string_value(),args(1));

        return args(1);
}

This gave the following in octave :

octave --norc
octave:1> a
error: `a' undefined near line 1 column 1
octave:1> test("a",3)
ans = 3
octave:2> a
error: `a' undefined near line 2 column 1
octave:2> a=2
a = 2
octave:3> who

*** dynamically linked functions:

test

*** local user variables:

a

octave:4> global a
warning: local variable value may have changed to match global
octave:5> a
a = 3
octave:6> test("a",4)
ans = 4
octave:7> a
a = 4
octave:8> who

*** dynamically linked functions:

test

*** globally visible user variables:

a


So if I interpret correctly, set_global_value() does set "a" define a
but does not declare it.

Tim




-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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