Any function like ISDEPLOYED for detection of Web-App mode

2 views (last 30 days)
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.

Accepted Answer

Kojiro Saito
Kojiro Saito on 11 Jan 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 Comments
Kojiro Saito
Kojiro Saito on 11 Jan 2023
回答の採用ありがとうございました。解決して良かったです。

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB Web App Server in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!