روش های کاربردی اصلی

روش های کاربردی اصلی

روش های کاربردی اصلی
کلاس برنامه اصلی AppModel متدهای زیر را دارد:
 
نام
نحو
شرح
declaration
DataSource declaration(String name)
شی اعلان ( Scalar ، Array 1D ، Array 2D ، ChoiceList ، یا UnitSet ) را با نام مشخص شده برمی گرداند.
form
FormList form()
لیست فرم ها را برمی گرداند.
form
Form form(String name)
فرم را با نام مشخص شده برمی گرداند.
hasProperty
boolean hasProperty(String name)
اگر یک ویژگی قابل تغییر با نام مشخص شده وجود داشته باشد، true را برمی گرداند.
mainWindow
MainWindow mainWindow()
شی MainWindow را برمی گرداند .
کلاس AppModel دارای ویژگی های زیر است:
ویژگی
ارزش
پیش فرض
شرح
asktosave
true | false
false
اگر درست است، از کاربر بپرسید که آیا تغییرات باید قبل از بسته شدن برنامه ذخیره شوند.
startmode
edit | run
edit
وقتی روی فایل MPH، از جمله نمادهای دسکتاپ ویندوز، دوبار کلیک می‌کنید، مشخص می‌کند که آیا برنامه برای ویرایش یا اجرا باز می‌شود.
کد مثال
app.set(“asktosave”، true);
کد زیر یک رشته متنی را به عنوان پنجره برنامه اضافه می کند.
String oldTitle = app.mainWindow().getString(“title”);
app.mainWindow().set(“title”, oldTitle + “moified”);
مثال‌های زیر نشان می‌دهند که چگونه فهرست اعلان‌ها را در یک برنامه پرس و جو کنید.
// Get the declaration list
Declaration list = app.declaration();
// Get the names of all DataSource objects in the list.
String[] names = list.names();
// Get the number of DataSource objects in the list.
int size = list.size();
// Get the DataSource with the name “svar”.
DataSource src = list.get(“svar”);
// Get the index within the list of the DataSource with the name “svar”.
int index = list.index(“svar”);
// Get the DataSource at a certain index within the list.
DataSource src = list.get(index);
// Get the DataSource objects defined in a given form.
Declaration formDeclarations = app.form(“form1”).declaration();
// Iterate over DataSource objects within the list.
for(DataSource dt : list) {
// Get the type of the DataSource.
String type = dt.getType();
}