Any function like ISDEPLOYED for detection of Web-App mode
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hiroaki Nakanishi
il 11 Gen 2023
Commentato: Kojiro Saito
il 11 Gen 2023
English follows Japanese (Bad English, sorry):
今MATLABアプリを作成していて、Webアプリとして実行可能にしたいと思っているのですが、
uigetdirやinputdlgなど、Webアプリとして実行される場合にのみサポートされない関数があります。これらについて、Webアプリとして実行されているかどうかで場合分けをしたいのですがうまくいきません。
uigetdirやinputdlgなどと同等の機能を実現するために、別の方法は用意しました。
そしてWebアプリとして実行されている場合にのみその方法を使い、そうでない場合には通常の関数(uigetdirなど)を使用させたいのですが、「Webアプリとして実行されているか」を判定する関数が見つかりませんでした。try-catchも試しましたが、エラーをキャッチできません。
なにか良い方法、あるいは「Webアプリとして実行されているか」を判定する関数はありますでしょうか?
---
I'm creating an application to execute in Web-App mode and in trouble of detection of execution mode (in MATLAB or WebAppServer/Standalone.)
There are some functions like UIGETDIR or INPUTDLG that DO work in Standalone mode but DON'T in WebApp mode.
I've created alternative ways for those functions, and I wanna write codes which execute them when the app is executed in WebApp mode and execute original ones (UIGETFILE, etc...) otherwise. But I can't find any function which returns 1 only when the app is in WebApp mode.
(ISDEPLOYED returns 1 not only when the app is WebApp mode but also in Standalone mode. If my understanding is wrong, okease tell me.)
I also tried a TRY-CATCH statement below but it dis not work.
Is there any function like that or any way to realize the function?
Any help would be appreciated.
---
Sample Codes:
try
% uigetdir is not supported in WebApp mode, thus I expect that MException occurs here.
d = uigetdir(pwd, 'select folder');
catch
d = uigetdir_WebApp(pwd, 'select folder') % alternative function of uigetdir for WebApp mode
end
% -> try-catch is not working; Error "'uigetdir' is not supported in Web App" occurs.
0 Commenti
Risposta accettata
Kojiro Saito
il 11 Gen 2023
ctfrootという関数を使うと場合分けができます。
スタンドアロンアプリで実行すると、ctfrootは例えばWindowsだと
C:\Users\USERNAME\AppData\Local\Temp\USERNAME\mcrCache9.13\myApp0
のようにmcrcachedirコマンドでリターンされるAppDataのフォルダーになります。
Webアプリで実行すると、ctfrootはWindowsだと
C:\ProgramData\MathWorks\webapps\R2022b\USR\.appCache\mcrCache9.13\myApp0
のように、ProgramDataのフォルダーになります。
これを区別することでWebアプリかどうかの判定ができます。
2 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su MATLAB Web App Server in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!