IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Interfaces Graphiques Discussion :

Undefined variable varargin


Sujet :

Interfaces Graphiques

  1. #1
    Membre actif
    Inscrit en
    Avril 2012
    Messages
    79
    Détails du profil
    Informations forums :
    Inscription : Avril 2012
    Messages : 79
    Par défaut Undefined variable varargin
    Bonsoir
    J'ai essayé d'appeler un GUI à partir d'un autre GUI mais j'ai obtenu cette erreur
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
     
    ??? Undefined variable varargin.
     
    Error in ==> afficher at 35
    if nargin && ischar(varargin{1})
     
    Error in ==> interface>pushbutton1_Callback at 100
    afficher(i);
     
    Error in ==> gui_mainfcn at 96
            feval(varargin{:});
     
    Error in ==> interface at 42
        gui_mainfcn(gui_State, varargin{:});
     
    Error in ==> @(hObject,eventdata)interface('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
     
     
    ??? Error while evaluating uicontrol Callback
    dans le premier GUI
    dans le deuxième GUI
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    function varargout = afficher(i)
    merci

  2. #2
    Expert confirmé
    Avatar de duf42
    Homme Profil pro
    Formateur en informatique
    Inscrit en
    Novembre 2007
    Messages
    3 111
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France

    Informations professionnelles :
    Activité : Formateur en informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2007
    Messages : 3 111
    Par défaut
    Bonjour,

    Pourrais-tu montrer les premières lignes de la fonction afficher (genre les 50 premières)?

    Duf

  3. #3
    Membre actif
    Inscrit en
    Avril 2012
    Messages
    79
    Détails du profil
    Informations forums :
    Inscription : Avril 2012
    Messages : 79
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
     
    function varargout = afficher(i)
    %AFFICHER M-file for afficher.fig
    %      AFFICHER, by itself, creates a new AFFICHER or raises the existing
    %      singleton*.
    %
    %      H = AFFICHER returns the handle to a new AFFICHER or the handle to
    %      the existing singleton*.
    %
    %      AFFICHER('Property','Value',...) creates a new AFFICHER using the
    %      given property value pairs. Unrecognized properties are passed via
    %      varargin to afficher_OpeningFcn.  This calling syntax produces a
    %      warning when there is an existing singleton*.
    %
    %      AFFICHER('CALLBACK') and AFFICHER('CALLBACK',hObject,...) call the
    %      local function named CALLBACK in AFFICHER.M with the given input
    %      arguments.
    %
    %      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
    %      instance to run (singleton)".
    %
    % See also: GUIDE, GUIDATA, GUIHANDLES
     
    % Edit the above text to modify the response to help afficher
     
    % Last Modified by GUIDE v2.5 14-Nov-2012 21:58:16
     
    % Begin initialization code - DO NOT EDIT
    gui_Singleton = 1;
    gui_State = struct('gui_Name',       mfilename, ...
                       'gui_Singleton',  gui_Singleton, ...
                       'gui_OpeningFcn', @afficher_OpeningFcn, ...
                       'gui_OutputFcn',  @afficher_OutputFcn, ...
                       'gui_LayoutFcn',  [], ...
                       'gui_Callback',   []);
    if nargin && ischar(varargin{1})
       gui_State.gui_Callback = str2func(varargin{1});
    end
     
    if nargout
        [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
    else
        gui_mainfcn(gui_State, varargin{:});
    end
    % End initialization code - DO NOT EDIT
     
     
    % --- Executes just before afficher is made visible.
    function afficher_OpeningFcn(hObject, eventdata, handles, varargin)
    % This function has no output args, see OutputFcn.
    % hObject    handle to figure
    % eventdata  reserved - to be defined in a future version of MATLAB
    % handles    structure with handles and user data (see GUIDATA)
    % varargin   unrecognized PropertyName/PropertyValue pairs from the
    %            command line (see VARARGIN)
     
    % Choose default command line output for afficher
    handles.output = hObject;
     
    % Update handles structure
    guidata(hObject, handles);

  4. #4
    Invité
    Invité(e)
    Par défaut
    Bonsoir,

    Tu dois laisser varargin dans la première ligne :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    function varargout = afficher(varargin)
    C'est dans la fonction afficher_OpeningFcn que tu récupères le paramètre i que tu passes. Je t'invite à lire ce message.

  5. #5
    Membre actif
    Inscrit en
    Avril 2012
    Messages
    79
    Détails du profil
    Informations forums :
    Inscription : Avril 2012
    Messages : 79
    Par défaut
    J'ai utilisé ces lignes mais ça n'a pas marché
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    function pushbutton1_Callback(hObject, eventdata, handles)
    afficher(i)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    function varargout = afficher(varargin)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    function afficher_OpeningFcn(hObject, eventdata, handles, varargin)
    handles.output = hObject;
    i = varargin{1};
    % Update handles structure
    guidata(hObject, handles);
     
    function varargout = afficher_OutputFcn(hObject, eventdata, handles)
    varargout{1} = handles.output;
    a=i
    j'ai obtenu ce résultat
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    a =
     
            0 + 1.0000i

  6. #6
    Invité
    Invité(e)
    Par défaut
    Il faut que tu stockes ta variable i dans la structure handles, c'est elle qui te permet de faire passer tes variables "locales" entre les différentes fonctions de ton interface.
    Je t'invite à lire ce tutoriel, et notamment le §2.3

  7. #7
    Membre actif
    Inscrit en
    Avril 2012
    Messages
    79
    Détails du profil
    Informations forums :
    Inscription : Avril 2012
    Messages : 79
    Par défaut
    Je suis désolée mais j'ai pas compris où et comment je peux utiliser handles

Discussions similaires

  1. Undefined variable: Idclic
    Par kratos59 dans le forum Langage
    Réponses: 7
    Dernier message: 11/05/2006, 16h50
  2. Notice: Undefined variable
    Par oranoutan dans le forum Langage
    Réponses: 19
    Dernier message: 21/12/2005, 22h28
  3. undefined variable
    Par ept35 dans le forum Langage
    Réponses: 3
    Dernier message: 30/11/2005, 15h48
  4. Notice: Undefined variable
    Par kayn dans le forum Langage
    Réponses: 2
    Dernier message: 03/10/2005, 20h44
  5. Réponses: 3
    Dernier message: 22/09/2005, 11h24

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo