Заметка
Доступ к этой странице требует авторизации. Вы можете попробовать войти в систему или изменить каталог.
Доступ к этой странице требует авторизации. Вы можете попробовать сменить директорию.
Замечание
Группы интересов сообщества теперь переехали из Yammer в Microsoft Viva Engage. Чтобы присоединиться к сообществу Viva Engage и принять участие в последних обсуждениях, заполните форму " Запрос доступа к финансам и операциям Viva Engage Community " и выберите сообщество, к которому вы хотите присоединиться.
В этой статье описываются функции времени выполнения отражения.
classIdGet
Извлекает числовый идентификатор (идентификатор класса) класса, к которому принадлежит объект, к которому принадлежит инициализированный объект.
int classIdGet(class object)
Параметры
| Параметр | Description |
|---|---|
| объект | Объект, для получения идентификатора класса. |
Возвращаемое значение
Идентификатор класса указанного объекта.
Example
static void classIdGetExample(Args _args)
{
int i;
WorkTimeCheck w;
i = classIdGet(w);
print "Class ID for object is " + int2Str(i);
}
dimOf
Извлекает количество элементов индекса, для которых было выделено пространство в массиве X++.
int dimOf(anytype object)
Параметры
| Параметр | Description |
|---|---|
| объект | Массив, определяющий размер измерения. |
Возвращаемое значение
Если значение параметра объекта является массивом, число элементов в массиве; в противном случае — 0 (ноль).
Замечания
Функция dimOf предназначена для массивов X++, объявленных в качестве следующих типов примитивных типов X++:
- булевый
- date
- инт
- int64
- real
- UTCDateTime
Примером является int iAmounts[6];. Массивы значений перечисления и расширенные типы данных также поддерживаются, если они в конечном итоге основаны на одном из предыдущих примитивных типов данных (например, int). Функция dimOf не принимает массивы всех типов примитивных типов X++. Ниже приведены типы массивов, которые функция dimOf не принимает:
- str
- контейнер
- anytype
- Массивы объектов класса
- Экземпляры класса Array
Example
static void JobDimOfArrays(Args _args)
{
int iAmounts[20], iCounts[];
ABCModel enumAbcModel[22]; // Enum
ABCModelType exdtAbcModelType[24]; // Extended data type
anytype anyThings[26];
str sNames[28];
Array myArrayObj; // Class
info("Start of job.");
info("--(Next, normal int array, dimOf() accepts it.)");
info(int2Str(dimOf(iAmounts)));
info("--(Next, normal enum array, dimOf() accepts it.)");
info(int2Str(dimOf(enumAbcModel)));
info("--(Next, normal extended data type array (based on enum), dimOf() accepts it.)");
info(int2Str(dimOf(exdtAbcModelType)));
info("--(Next, dynamic int array, dimension not yet set.)");
info(int2Str(dimOf(iCounts)));
info("--(Next, dynamic int array, after dimension established.)");
iCounts[13] = 13;
info(int2Str(dimOf(iCounts)));
info(" == == == == == (Next, array types that dimOf() does not support.)");
info("--(Next, normal anytype array, dimOf() always returns 0.)");
info(int2Str(dimOf(anyThings)));
info("--(Next, an instance of class X++ Array, dimOf() always returns 0.)");
myArrayObj = new Array(Types::Integer);
myArrayObj.value(1,501);
info(int2Str(dimOf(myArrayObj)));
info("--(Next, the lastIndex method provides size information about Array instances.)");
info(int2Str(myArrayObj.lastIndex()));
info("--(Next, normal str array, dimOf() does not accept it, job is halted.)");
info(int2Str(dimOf(sNames)));
info("End of job.");
}
/************ Actual Infolog output
Message (11:10:06 am)
Start of job.
--(Next, normal int array, dimOf() accepts it.)
20
--(Next, normal enum array, dimOf() accepts it.)
22
--(Next, normal extended data type array (based on enum), dimOf() accepts it.)
24
--(Next, dynamic int array, dimension not yet set.)
0
--(Next, dynamic int array, after dimension established.)
16
== == == == == (Next, array types that dimOf() does not support.)
--(Next, normal anytype array, dimOf() always returns 0.)
0
--(Next, an instance of class X++ Array, dimOf() always returns 0.)
0
--(Next, the lastIndex method provides size information about Array instances.)
1
--(Next, normal str array, dimOf() does not accept it, job is halted.)
Error executing code: Illegal operation on this type of array. (C)JobsJobDimOfArrays - line 41
************/
/*********** Pop-up error dialog box
"Internal error number 25 in script."
This error is caused by the code line...
info(int2Str(dimOf(iCounts)));
...before iCounts was assigned at any index.
***********/
fieldId2Name
Извлекает строку, представляющую имя поля, указанного номером идентификатора таблицы и номером идентификатора поля.
str fieldId2Name(int tableid, int fieldid)
Параметры
| Параметр | Description |
|---|---|
| tableid | Идентификатор таблицы. Заметка: Используйте функцию tableName2Id , чтобы указать идентификатор таблицы. |
| fieldid | Идентификатор поля. |
Возвращаемое значение
Имя поля.
Замечания
Чтобы вернуть печатную версию имени поля, используйте функцию fieldId2PName .
Example
В следующем примере имя поля в таблице Customer (CustGroup) имеет идентификатор поля 7.
static void fieldId2NameExample(Args _arg)
{
str fn;
fn = fieldId2Name(tableName2Id("Customer"),7);
}
fieldId2PName
Извлекает отображаемое имя поля, указанного номером идентификатора таблицы и номером идентификатора поля.
str fieldId2PName(int tableid, int fieldid)
Параметры
| Параметр | Description |
|---|---|
| tableid | Идентификатор таблицы. Заметка: Используйте функцию tableName2Id , чтобы указать идентификатор таблицы. |
| fieldid | Идентификатор поля. Заметка: Используйте функцию fieldName2Id , чтобы указать идентификатор поля. |
Возвращаемое значение
Имя поля.
Example
static void fieldId2PNameExample(Args _arg)
{
str name;
tableid _tableId;
fieldid _fieldid;
_tableId = tableName2Id("Address");
_fieldId = fieldName2Id(_tableId, "Name");
name = fieldId2PName(_tableId, _fieldid);
print name;
}
fieldName2Id
Извлекает идентификатор поля поля, указанного номером идентификатора таблицы и номером идентификатора поля.
int fieldName2Id(int tableid, str fieldname)
Параметры
| Параметр | Description |
|---|---|
| tableid | Идентификатор таблицы. Заметка: Используйте функцию tableName2Id , чтобы указать идентификатор таблицы. |
| имя поля | Имя поля. |
Возвращаемое значение
Идентификатор поля, указанного параметрами табличного и имени поля .
Example
static void fieldName2IdExample(Args _arg)
{
int id;
id = fieldName2Id(tableName2Id("Address"), "Name");
// Returns 6. Name is the 6th field in the Address table.
print id;
}
indexId2Name
Извлекает имя индекса.
str indexId2Name(int tableid, int indexid)
Параметры
| Параметр | Description |
|---|---|
| tableid | Идентификатор таблицы, к которой принадлежит индекс. |
| indexid | Идентификатор индекса. |
Возвращаемое значение
Имя индекса.
Example
static void indexId2NameExample(Args _arg)
{
str s;
tableid id;
indexid idx;
id = tableName2Id("Address");
idx = indexName2Id(id, "AddrIdx");
s = indexId2Name(id, idx);
print "The result of calling indexId2Name is " + s;
}
indexName2Id
Извлекает идентификатор индекса.
int indexName2Id(int tableid, str indexname)
Параметры
| Параметр | Description |
|---|---|
| tableid | Идентификатор таблицы, к которой принадлежит индекс. |
| имя индекса | Имя индекса. |
Возвращаемое значение
Идентификатор индекса.
Example
static void indexName2IdExample(Args _arg)
{
indexid idx;
tableid id;
id = tableName2Id("Address");
idx = indexName2Id(id, "AddrIdx");
print "Index ID for index name AddrIdx of table Address is " + int2Str(idx);
}
tableId2Name
Извлекает строку, содержащую имя таблицы.
str tableId2Name(int _tableid)
Параметры
| Параметр | Description |
|---|---|
| _tableid | Идентификатор таблицы. |
Возвращаемое значение
Название таблицы.
Example
static void tableId2NameExample(Args _arg)
{
str s;
tableid id;
// Get the ID for table name Address.
id = tableName2Id("Address");
print "ID for table name Address is " + int2Str(id);
// Get the name from the table ID.
s = tableId2Name(id);
print "Name for table ID " + int2Str(id) + " is " + s;
// Get the printable name from the table ID.
s = tableId2PName(id);
print "Printable name for table ID " + int2Str(id) + " is " + s;
}
tableId2PName
Извлекает строку, содержащую печатное имя (метку) таблицы.
str tableId2PName(int _fieldid)
Параметры
| Параметр | Description |
|---|---|
| _fieldid | Идентификатор таблицы. |
Возвращаемое значение
Метка таблицы.
Example
static void tableId2NameExample(Args _arg)
{
str s;
tableid id;
// Get the ID for table name Address.
id = tableName2Id("Address");
print "ID for table name Address is " + int2Str(id);
// Get the name from the table ID.
s = tableId2Name(id);
print "Name for table ID " + int2Str(id) + " is " + s;
// Get the printable name from the table ID.
s = tableId2PName(id);
print "Printable name for table ID " + int2Str(id) + " is " + s;
}
tableName2Id
Извлекает идентификатор таблицы.
int tableName2Id(str _name)
Параметры
| Параметр | Description |
|---|---|
| _имя | Название таблицы. |
Возвращаемое значение
Идентификатор таблицы.
Example
static void tableName2IdExample(Args _arg)
{
str s;
tableid id;
// Get the ID for the Address table name.
id = tableName2Id("Address");
print "ID for the Address table name is " + int2Str(id);
// Get the name from the table ID.
s = tableId2Name(id);
print "Name for table ID " + int2Str(id) + " is " + s;
// Get the printable name from the table ID.
s = tableId2PName(id);
print "Printable name for table ID " + int2Str(id) + " is " + s;
}
typeOf
Извлекает тип элемента.
enum typeOf(anytype _object)
Параметры
| Параметр | Description |
|---|---|
| _объект | Элемент, возвращаемый типом. |
Возвращаемое значение
Значение системного перечисления типов .
Example
В следующем примере проверяется, является ли первый элемент в контейнере c другим контейнером, который содержит одно целое число.
if(typeof(conpeek(c, 1)) != Types::Container ||
conlen(conpeek(c, 1)) != 1 ||
typeof(conpeek(conpeek(c, 1), 1)) != Types::Integer)
{
// More code.
}