editor functionality: check that variable name isn't already a MATLAB function name or keyword?
Afficher commentaires plus anciens
Is it possible that the editor checks automatically in the background, while I am typing, that a by me used variable or handle, etc. name isn´t already exisitent somewhere in MATLAB or a MATLAB toolbox as a function name, keyword or any other import and thus better to reserve than overwrite word? At the moment I am working without toolboxes, but I would like to be prepared as good as possible for the future, and if the editor would not check only against installed functions, but would have a list with generally from The Mathworks available functions, it could be helpful if ALL those existent words become accordingly colored. Furthermore, do the function names from my own code become automatically incorporated in the 'reserved / occupied' name list of the editor (R2013b) for color coding, if my m-files are on a reachable path?
1 commentaire
Marco
le 27 Fév 2014
Réponse acceptée
Plus de réponses (1)
Star Strider
le 27 Fév 2014
Modifié(e) : Star Strider
le 27 Fév 2014
0 votes
One way (the method I use) is to type the name into the EDITOR window, put the mouse cursor on the word. Then either:
- right click on it to bring up a pop-up menu, then left click on Help on selection F1
- press the fn+f1 keys
Both of these bring up the documentation on the word you want information about. If it comes up ‘empty’ — there’s no documentation available on it — then it’s not a MATLAB function or reserved word.
I use this most often to bring up documentation on functions I want information about, but it also works to be sure new variable or function names aren’t already claimed. (It also brings up information on functions I write, a reason to document them with comments just below the function line.)
The iskeyword function also works, but you have to type and run this in the Command Window. (I don’t use this much because it clutters the Command Window.)
3 commentaires
Sean de Wolski
le 27 Fév 2014
iskeyword only checks for these:
iskeyword
ans =
'break'
'case'
'catch'
'classdef'
'continue'
'else'
'elseif'
'end'
'for'
'function'
'global'
'if'
'otherwise'
'parfor'
'persistent'
'return'
'spmd'
'switch'
'try'
'while'
Which should be blue (or your color of choice) and completely unusable outside of what it was designed for.
Star Strider
le 27 Fév 2014
Good point. Another reason I don’t use it much.
Marco
le 27 Fév 2014
Catégories
En savoir plus sur Startup and Shutdown dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!