Is it possible to update the text inside other scripts/functions using a separate script?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Steven Manz
el 28 de Mzo. de 2022
Comentada: Steven Manz
el 28 de Mzo. de 2022
In development of a new tool, I will want to update the version and date in each script when a new version is ready to be used. Right now there are multiple scripts that will need the update, and to save time, I would like to create a script that calls to each individual function to change the date and version.
Let's say I have a function with a header:
function test = dummy()
%% Header
% Name : dummy
% Rev : 3.0.0
% Date : 2022/03/28
% Author : Steven Manz
% Desc :
%
% REVISION HISTORY
% 1.0.0 : Initial release
% 3.0.0 : Reformatted entire tool for production use
%
% INPUTS
% -------------------------------------------------------------------------
end
...
Is it possible to write a script that will search for Rev and change the revision as well as the history, then change the date to the current date?
Using another function to change the text inside a separate function is something I have never tried before and cannot seem to find any information for anywhere else. Is this possible in MATLAB?
4 comentarios
Rik
el 28 de Mzo. de 2022
.m files are stored as plain text. Since a few releases they are UTF-8 encoded by default, but if you don't use special characters in your char arrays/strings that doesn't matter. So all tools that work on txt files will work on m files.
Respuesta aceptada
Más respuestas (1)
Steven Lord
el 28 de Mzo. de 2022
While you can store the revision history for a file in the file itself, if you're going to build a lot of tools for others to use I strongly recommend using a source control system or SCM. You can control certain types of SCMs from within MATLAB; the documentation section to which I linked discusses Git and SVN. One benefit an SCM gives you is that if you make a change and then need to undo that change, reverting it is usually pretty easy. If you've modified the main or sole copy of the file you need to try to remember what modifications you made to implement that change and that can be difficult especially if that change was large, was complicated, or it's been a while since you made it.
Ver también
Categorías
Más información sobre Environment and Settings 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!