5-Minute-Snack: Default local folders in TMS Miletus (e.g. user directory)
TMS Miletus is a framework that allows you to create desktop applications based on TMS WEB Core. You can hit two birds with one stone by delivering a Web application and a desktop application (soon for multiple platforms) at the same time!
This sounds easier than it actually is because Web applications do not have access to your local file system or any other hardware. Web browsers will not allow access to any of those resources. TMS Miletus provides components, procedures, and functions to bridge this gap.
One example, are special folders. When storing user-specific information on the disk, you cannot simply dump it in the current working directory. In Delphi, you can use TPath.GetHomePath, for example. How would you do this in TMS WEB Core with TMS Miletus as IOUtils.pas is unavailable?
The framework provides the procedure GetMiletusPath. In its first parameter, you specify the directory you wish to retrieve using constants defined in the framework. The following values are possible:
The second parameter is a var parameter of type string which will contain the directory after calling the procedure.
Here is an example to retrieve the user’s data directory:
procedure TForm1.MiletusFormCreate(Sender: TObject); var LPath: String; begin GetMiletusPath( NP_USERDATA, LPath ); WebEdit1.Text := LPath; end;
This will retrieve the user data directory and store it in the var parameter LPath.
When running this application with a TWebEdit control on the form, it will look like this:
For a general overview of TMS Miletus, have a look at this short video which focuses on the dilemma when you have to provide an application for desktop as well as the Web.