Remarque
L’accès à cette page nécessite une autorisation. Vous pouvez essayer de vous connecter ou de modifier des répertoires.
L’accès à cette page nécessite une autorisation. Vous pouvez essayer de modifier des répertoires.
Cet article décrit les fonctions du runtime de réflexion.
classIdGet
Récupère l’identificateur numérique (ID de classe) de la classe à laquelle appartient l’objet initialisé.
int classIdGet(class object)
Parameters
| Parameter | Description |
|---|---|
| object | Objet pour lequel obtenir l’ID de classe. |
Return value
ID de classe de l’objet spécifié.
Example
static void classIdGetExample(Args _args)
{
int i;
WorkTimeCheck w;
i = classIdGet(w);
print "Class ID for object is " + int2Str(i);
}
dimOf
Récupère le nombre d’éléments d’index alloués dans un tableau X++.
int dimOf(anytype object)
Parameters
| Parameter | Description |
|---|---|
| object | Tableau pour déterminer la taille de dimension de. |
Return value
Si la valeur du paramètre d’objet est un tableau, le nombre d’éléments du tableau ; sinon, 0 (zéro).
Remarks
La fonction dimOf est destinée aux tableaux X++ déclarés comme types primitifs X++ suivants :
- boolean
- date
- int
- int64
- real
- utcDateTime
Un exemple est int iAmounts[6] ;. Les tableaux de valeurs d’énumération et de types de données étendus sont également pris en charge s’ils sont finalement basés sur l’un des types de données primitifs précédents (par exemple , int). La fonction dimOf n’accepte pas les tableaux de tous les types primitifs X++. Voici les types de tableaux que la fonction dimOf n’accepte pas :
- str
- container
- anytype
- Tableaux d’objets de classe
- Instances de la classe 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
Récupère une chaîne qui représente le nom du champ que vous spécifiez à l’aide d’un numéro d’ID de table et d’un numéro d’ID de champ.
str fieldId2Name(int tableid, int fieldid)
Parameters
| Parameter | Description |
|---|---|
| tableid | Numéro d’ID de la table. Note: Utilisez la fonction tableName2Id pour spécifier l’ID d’une table. |
| fieldid | Numéro d’ID du champ. |
Return value
Nom du champ.
Remarks
Pour renvoyer une version imprimable du nom de champ, utilisez la fonction fieldId2PName .
Example
L’exemple suivant définit fn sur le nom du champ dans la table Customer (CustGroup) qui a un ID de champ de 7.
static void fieldId2NameExample(Args _arg)
{
str fn;
fn = fieldId2Name(tableName2Id("Customer"),7);
}
fieldId2PName
Récupère le nom imprimable du champ que vous spécifiez à l’aide d’un numéro d’ID de table et d’un numéro d’ID de champ.
str fieldId2PName(int tableid, int fieldid)
Parameters
| Parameter | Description |
|---|---|
| tableid | Numéro d’ID de la table. Note: Utilisez la fonction tableName2Id pour spécifier l’ID d’une table. |
| fieldid | Numéro d’ID du champ. Note: Utilisez la fonction fieldName2Id pour spécifier l’ID d’un champ. |
Return value
Nom du champ.
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
Récupère l’ID de champ du champ de table que vous spécifiez à l’aide d’un numéro d’ID de table et d’un numéro d’ID de champ.
int fieldName2Id(int tableid, str fieldname)
Parameters
| Parameter | Description |
|---|---|
| tableid | Numéro d’ID de la table. Note: Utilisez la fonction tableName2Id pour spécifier l’ID d’une table. |
| fieldname | Nom du champ. |
Return value
ID du champ spécifié par les paramètres tableid et nom_champ .
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
Récupère le nom d’un index.
str indexId2Name(int tableid, int indexid)
Parameters
| Parameter | Description |
|---|---|
| tableid | ID de la table à laquelle appartient l’index. |
| indexid | ID de l’index. |
Return value
Nom de l’index.
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
Récupère l’ID d’un index.
int indexName2Id(int tableid, str indexname)
Parameters
| Parameter | Description |
|---|---|
| tableid | ID de la table à laquelle appartient l’index. |
| indexname | Nom de l’index. |
Return value
ID de l’index.
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
Récupère une chaîne qui contient le nom d’une table.
str tableId2Name(int _tableid)
Parameters
| Parameter | Description |
|---|---|
| _tableid | ID unique de la table. |
Return value
Nom de la table.
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
Récupère une chaîne qui contient le nom imprimable (l’étiquette) d’une table.
str tableId2PName(int _fieldid)
Parameters
| Parameter | Description |
|---|---|
| _fieldid | ID unique de la table. |
Return value
Étiquette de la table.
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
Récupère l’ID d’une table.
int tableName2Id(str _name)
Parameters
| Parameter | Description |
|---|---|
| _name | Nom de la table. |
Return value
ID unique de la table.
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
Récupère le type d’un élément.
enum typeOf(anytype _object)
Parameters
| Parameter | Description |
|---|---|
| _object | Élément pour lequel retourner le type. |
Return value
Valeur d’énumération système Types .
Example
L’exemple suivant teste si le premier élément d’un conteneur, c, est un autre conteneur qui contient un entier unique.
if(typeof(conpeek(c, 1)) != Types::Container ||
conlen(conpeek(c, 1)) != 1 ||
typeof(conpeek(conpeek(c, 1), 1)) != Types::Integer)
{
// More code.
}