help-octave
[Top][All Lists]
Advanced

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

Re: Having trouble with global array variables


From: Olumide
Subject: Re: Having trouble with global array variables
Date: Mon, 07 Jul 2008 01:29:19 +0100
User-agent: Thunderbird 2.0.0.14 (Windows/20080421)

Ben Abbott wrote:
The line "global position" should occur in the original script as well as in each function that uses it.

To be safe, be sure to insert the line "global position" ahead of any line that uses the variable "position".

I haven't tried to run your script, but I did insert the lines where they belong ... hopefully, I got it all right.

Unfortunately not. I've written the following short demo/test case to illustrate the problem:

##############################################

data = [ 0,0,0; 256,0,0; 0,256,0; 256,256,0; 128,128,5 ];

function foo()
  global data;
  data
endfunction

foo(); # outputs data = [](0x0)

data   # outputs full matrix

##############################################

As you can see the global matrix 'data' is not visible within foo() even if global data added to foo ...

:(






reply via email to

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