From help-octave-request at bevo dot che dot wisc dot edu Thu May 17 12:30:43 2001 Subject: function scope and load From: Adam Kornick To: help-octave at bevo dot che dot wisc dot edu Date: 17 May 2001 13:30:38 -0400 Folks, I'm trying to port some Matlab code that loads a file of structs and then returns some of the structs to the calling function. Loading the file works fine from the command prompt, but when I call the function to load the file it returns empty variables. Examples below, not sure what to do next. Thoughts? I'm using GNU Octave, version 2.1.33 (i386-redhat-linux-gnu). `The function does the following function [const,sat,shallow]=t_getconsts; if exist('t_constituents.mat'); load -force "t_constituents.mat" %has structs inside else % do some math to generate the file end; `The file can be loaded fine but the variables are lost when I leave `the scope. `Global scope from the prompt >> load -force t_constituents.mat >> whos *** local user variables: prot type rows cols name ==== ==== ==== ==== ==== rwd struct - - const rwd scalar 1 1 prefer_zero_one_indexing rwd struct - - sat rwd struct - - shallow `but the function won't return anything >> [const,sat,shallow]=t_getconsts const = [] sat = [] shallow = [] ------------------------------------------------------------- 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 -------------------------------------------------------------