App Designer add function confused by variable names
    6 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Michael Van de Graaff
      
 el 7 de Mzo. de 2021
  
    
    
    
    
    Comentada: Michael Van de Graaff
      
 el 3 de Dic. de 2021
            I've determined the problem and work around for my particular case, and wish to post it here for posterity. 
The problem i encountered is this: when adding a new helper fuction in App Designer, the automatic code generation would occasionally place the new function inside of a previous function. This is visually and syntacally terrible, and i'm pretty sure it bricks most code too. 
The source of the buggy behavior seems to be with variables whose names end with the word 'end' . I did NOT name any variable 'end', but 'variable_end' is sufficient to cause the problem.
I was able to create a minimal example. 
methods (Access = private)
        function results = not_buggy_names(app)
            variable_named_with_endd = 1;
            results = variable_named_with_endd;
        end
    end
If we have the already existing function not_buggy_names and now press the add function button we correctly get the following behavior
    methods (Access = private)
        function results = not_buggy_names(app)
            variable_named_with_endd = 1;
            results = variable_named_with_endd;
        end
        function results = func2(app)
            % this is correctly placed
        end
    end
However, if instead we have the folowing initial function buggy_names, which contains the string 'end' 
methods (Access = private)
        function results = buggy_names(app)
            variable_named_with_end = 1;
            results = variable_named_with_end; % this line is the problem, putting comment here doesn't help
            additional_code_doesnt_help = 1;
        end
    end
and now add a new function yields
    methods (Access = private)
        function results = buggy_names(app)
            variable_named_with_end = 1;
            results = variable_named_with_end;% this line is the problem, putting comment here doesn't help
            additional_code_doesnt_help = 1;
        function results = func2(app)
            % The new function got placed within the previous function, but at the end
        end
        end
    end
The variable with 'end' in the name does seem to need to be at the very end of the line. 
For example, this code works fine:
methods (Access = private)
        function results = fix_buggy_names(app)
            variable_named_with_end = 1;
            results = variable_named_with_end + 0; % now the line doesn't end with the sting 'end'
        end
    end
which produces
methods (Access = private)
        function results = fix_buggy_names(app)
            variable_named_with_end = 1;
            results = variable_named_with_end + 0; % now the line doesn't end with the sting 'end'
        end
        function results = func2(app)
        end
    end
2 comentarios
Respuesta aceptada
  Chidvi Modala
    
 el 10 de Mzo. de 2021
        I have brought this issue to the concerned people and it might be fixed in any future release.
2 comentarios
Más respuestas (0)
Ver también
Categorías
				Más información sobre Legend en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


