Hi. My codes have important information and if some data change, it is hard to find which data has changed. How can i lock editor window in order to such issue does not happens. Tnx

 Akzeptierte Antwort

Yongjian Feng
Yongjian Feng am 5 Jul. 2021

0 Stimmen

  1. Change your file to be readonly, then you won't accidentally modify your file.
  2. Always keep a copy of the working file.

10 Kommentare

armin m
armin m am 5 Jul. 2021
How change my file to read only?
Yongjian Feng
Yongjian Feng am 5 Jul. 2021
An easy way is to go to your operating system and do it from there. What operating system are you using please? Windows, MacOS, or Linux?
armin m
armin m am 5 Jul. 2021
Windows
armin m
armin m am 5 Jul. 2021
You mean properties>read only? It acctually change your code. If you change your code and accidentaly click on overwrite button which appear in run mode when you change read only file code.if better way exists ot would be better. Tnx
Yongjian Feng
Yongjian Feng am 5 Jul. 2021
Bearbeitet: Yongjian Feng am 5 Jul. 2021
Ok, when you open the *.m file in the matlab editor, the file path of this file will be shown in the address field as the red arrow points at. (Note I am using the online version. Your should be something like c:\Users.....)
Once you figure out the file path, use your file explorer to go to the folder of that *.m file.
Right click on the file, and select Properties, and then check ReadOnly
armin m
armin m am 5 Jul. 2021
If a read only file run and some information changes accidentally,the program shows alert which include overwrite button.by clicking on this button,the code will changes. Is there any better way to to solve the mentioned problem?
Yongjian Feng
Yongjian Feng am 5 Jul. 2021
In general, if you have important code, think about using configuration control tool like perforce or git.Git is free. Check in your code to git, and it can manage the versions for you.
armin m
armin m am 6 Jul. 2021
So what is git?
Yongjian Feng
Yongjian Feng am 6 Jul. 2021
Check this: https://github.com/
armin m
armin m am 6 Jul. 2021
Tnx

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Image Analyst
Image Analyst am 5 Jul. 2021

0 Stimmen

@armin m, I believe you're mistaken when you say "properties>read only? It acctually change your code. If you change your code and accidentaly click on overwrite button which appear in run mode when you change read only file code."
I did exactly that. Made a file read only via the properties in file Explorer. That (changing property to readonly) did not change the code because when I opened it up in MATLAB's editor it was the same. However, I made a change to it and tried to save it and it said:
There is an "overwrite" button like you said and if you click it, it will save your changes and uncheck the readonly property, like you told it to. It gave you a warning but if you said to ignore the warning and do what you told it to do (overwrite), evidently it will trust you know what you're doing and do what you told it to do. Like it or not, that seems to be the way it operates.
So (1) don't change it, and (2) if you did change it, don't overwrite it. And (3) if you did overwrite it, get the original copy from your archive or backup.

1 Kommentar

armin m
armin m am 5 Jul. 2021
Tnx. I meant exactly what you said but i explained badly. I looked for better way cause of what i said. thank you.

Melden Sie sich an, um zu kommentieren.

Kategorien

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by