I'm using Octave GNU for GUI Excel data. I want to ask you guys how can I call defined argument in another function. Here is my code.
%%First Function = pushbutton_Callback
function pushbutton_Callback(hObject, eventdata, handles)
fileName = uigetfile('*.xlsx')%%excel data import
handles.fileName=fileName;
guidata(hObject, handles)
endfunction
%%Second Function = popupmenuX_Callback
function popupmenuX_Callback(hObject, eventdata, handles)
fileName = fileName @pushbutton_Callback;
printf ("in popupmenuX_Callback, calling pushbutton_Callback\n");
%%To nested function to prevent (because in Octave nested function is not accepted), I used subfunction as alternative%%
handles.fileName=fileName; %% This argument fileName I want to bring from first function
[numbers, colNames]=xlsread(fileName); %%read columns of excel data in first function
set(hObject,'string',colNames);
endfunction
If I put my functions like this, always come these errors.
>> fileName = V8.xlsx
error: superclass calls can only occur in methods or constructors
error: called from
popupmenuX_Callback at line 61 column 10
So what I want to do is, I want to bring defined Argument "fileName" in first function (pushbutton_Callback) to second function (popupX_callback). But it can not be defined in second function. I've heard that nested function in octave can be resolved with "foo", "foobar" or "ex_top", "ex_a" function. But I can't not resolve the problem with "ex_"function. Then should I have to use "foo", "foobar" function to call arguments into other function?
Best regards!
===========================================================================
I edited my questions with my full codes. (Full codes below) So what I want to do is, just like this video. But in Matlab like in video, it can be made with GUIDE or Application designer but in Octave there are no functions like that. So as a octave Beginner, it is hard for me to solve the problem.
%%Versuch
%% Diagramm zeichen
%%============================================================================
close all
clear h
graphics_toolkit qt
pkg load io
%%Uicontrols
%%Graph
h.ax = axes ("position", [0.3 0.25 0.6 0.5]);
%%Title
h.plot_title_label = uicontrol ("style", "text",
"units", "normalized",
"string", "Versuchsergebnis",
"horizontalalignment", "left",
"position", [0.03 0.9 0.25 0.08]);
%% Design for excel data import
h.print_pushbutton = uicontrol ("style", "pushbutton",
"units", "normalized",
"string", "Excel Datei mitbringen",
"callback", @pushbutton_Callback,
"position", [0.03 0.8 0.3 0.09]);
%% Drawing axis
h.popupmenuX = uicontrol("Style","popupmenu",
"units", "normalized",
"string","X Axis",...
"callback", @popupmenuX_Callback,
"Position",[0.7 0.04 0.2 0.05]);
h.popupmenuY = uicontrol("Style","popupmenu",
"units", "normalized",
"string","Y Axis",
"callback",@popupmenuY_Callback,
"Position",[0.03 0.5 0.2 0.05]);
%%=============================================================================
%% Functions
%%=============================================================================
%% 1. Excel Data import
function pushbutton_Callback(hObject, eventdata, handles)
fileName = uigetfile('*.xlsx')%%excel data import
handles.fileName = fileName;
guidata(hObject, handles)
endfunction
%% 2. X Axis Information from excel data import
function popupmenuX_Callback(hObject, eventdata, handles)
fileName = pushbutton_Callback(hObject, eventdata, handles)
%%This code fileName causes error, that 'handles' is not defined.%%
handles.fileName = fileName; %% This argument fileName I want to bring from first function
[numbers, colNames] = xlsread(fileName); %%read columns of excel data in first function
set(hObject,'string',colNames);
endfunction
%% 3. Y Axis Information from excel data import
function popupmenuY_Callback(hObject, eventdata, handles)
filename = pushbutton_Callback(hObject, eventdata, handles)
handles.fileName = fileName;
[numbers, colNames] = xlsread(fileName);
set(hObject,'string',colNames);
endfunction
%%%% Plot the graph
a = xlsread (fileName);
xColNum = get(popupmenuX_Callback,'value');
yColNum = get(popupmenuY_Callback,'value');
fileName = handles.fileName;
x = a(:,xColNum);
y = a(:,yColNum);
h.ax = plot(x,y);