Making a change in appdesigner when deployed permanent

Hello. I have an app that controls several external devices using the comms port and serial communication. I use the same app on about 5 different computers and the comms ports are always different.
For each of my external devices, I use a drop down to select the comms ports (i.e. Com2) but set the default value. But when I run the app on a different instrument, I need to go to all the drop downs and select the relevant comms port.
(My app is compiled by the way and the target computers have the runtime compile installed)
My questions are:
1: Can I get the default value (of the dropsown box) to change and be permanent after I first change it.
2: If not, can I use a file to read in at startup, so this inititalisation text file can be changed for each computer (..how do you read a file from the actual deployed directory)
Thanks
Jason

 채택된 답변

Timo Dietz
Timo Dietz 2020년 12월 3일

0 개 추천

You have to use "load" / "save" functions to store and reload your settings.
The app does not support permanent changes of the compiled code.

댓글 수: 6

So do you mean load & save as a text file?
Timo Dietz
Timo Dietz 2020년 12월 3일
편집: Timo Dietz 2020년 12월 3일
You can directly store variables in an m file (e.g. as a struct). Have a look at the documentation of "load" and "save". It's quite convenient.
E.g. in case your variable is s1:
save('newstruct.mat', '-struct', 's1');
Don't forget the ' since you have to deliver the name of the variable as string.
Oh thats perfect - but how do I get the actual folder where the .EXE is running from?
Try mfilename('fullpath') .
You can then separate with fileparts if needed.
Actually, mfilename doesn't work for deployed apps (i.e. an EXE created)
It returns this, but my actual exe is in C:\Matlab\EXE\
'C:\Users\Scan\AppData\Local\Temp\Scan\mcrCache9.9\....
Good point. I'm not sure whether I'm allowed to put external links here but you can search the internet for this.
I found one idea which sends the 'path' command to the system and just checks the latest entry - which should be the app execution path. Sorry for not being more pecise.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

릴리스

R2020b

질문:

2020년 12월 3일

댓글:

2020년 12월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by