Not
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
Anmärkning
Intressegrupper för communityn har nu flyttat från Yammer till Microsoft Viva Engage. Om du vill gå med i en Viva Engage-community och delta i de senaste diskussionerna fyller du i formuläret Begär åtkomst till Finance and Operations Viva Engage Community och väljer den community som du vill ansluta till.
I den här artikeln beskrivs funktionerna för reflektionskörning.
classIdGet
Hämtar den numeriska identifieraren (klass-ID) för klassen som objektet som initieras tillhör.
int classIdGet(class object)
Parameterar
| Parameter | Description |
|---|---|
| objekt | Objektet som klass-ID:t ska hämtas för. |
Returvärde
Klass-ID för det angivna objektet.
Example
static void classIdGetExample(Args _args)
{
int i;
WorkTimeCheck w;
i = classIdGet(w);
print "Class ID for object is " + int2Str(i);
}
dimOf
Hämtar antalet indexelement som utrymmet har allokerats för i en X++-matris.
int dimOf(anytype object)
Parameterar
| Parameter | Description |
|---|---|
| objekt | Matrisen för att fastställa dimensionens storlek. |
Returvärde
Om värdet för objektparametern är en matris, antalet element i matrisen. annars 0 (noll).
Anmärkningar
Funktionen dimOf är avsedd för X++-matriser som deklareras som följande primitiva X++-typer:
- booleskt
- date
- int
- int64
- verklig / äkta
- utcDateTime
Ett exempel är int iAmounts[6];. Matriser med uppräkningsvärden och utökade datatyper stöds också om de i slutändan baseras på någon av de föregående primitiva datatyperna (till exempel int). Funktionen dimOf accepterar inte matriser av alla primitiva X++-typer. Här är de matristyper som dimOf-funktionen inte accepterar:
- Str
- behållare
- anytype
- Matriser med klassobjekt
- Instanser av klassen 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
Hämtar en sträng som representerar namnet på det fält som anges av ett tabell-ID-nummer och ett fält-ID-nummer.
str fieldId2Name(int tableid, int fieldid)
Parameterar
| Parameter | Description |
|---|---|
| tableid | Tabellens ID-nummer. Not: Använd funktionen tableName2Id för att ange ID för en tabell. |
| fieldid | Fältets ID-nummer. |
Returvärde
Namnet på fältet.
Anmärkningar
Om du vill returnera en utskrivbar version av fältnamnet använder du funktionen fieldId2PName .
Example
I följande exempel anges fn till namnet på fältet i tabellen Kund (CustGroup) som har ett fält-ID på 7.
static void fieldId2NameExample(Args _arg)
{
str fn;
fn = fieldId2Name(tableName2Id("Customer"),7);
}
fieldId2PName
Hämtar det utskrivbara namnet på fältet som anges av ett tabell-ID-nummer och ett fält-ID-nummer.
str fieldId2PName(int tableid, int fieldid)
Parameterar
| Parameter | Description |
|---|---|
| tableid | Tabellens ID-nummer. Not: Använd funktionen tableName2Id för att ange ID för en tabell. |
| fieldid | Fältets ID-nummer. Not: Använd funktionen fieldName2Id för att ange ID för ett fält. |
Returvärde
Namnet på fältet.
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
Hämtar fält-ID för tabellfältet som anges av ett tabell-ID-nummer och ett fält-ID-nummer.
int fieldName2Id(int tableid, str fieldname)
Parameterar
| Parameter | Description |
|---|---|
| tableid | Tabellens ID-nummer. Not: Använd funktionen tableName2Id för att ange ID för en tabell. |
| fieldname | Namnet på fältet. |
Returvärde
ID för fältet som anges av parametrarna tableid och fieldname .
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
Hämtar namnet på ett index.
str indexId2Name(int tableid, int indexid)
Parameterar
| Parameter | Description |
|---|---|
| tableid | ID för tabellen som indexet tillhör. |
| indexid | Indexets ID. |
Returvärde
Namnet på indexet.
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
Hämtar ID:t för ett index.
int indexName2Id(int tableid, str indexname)
Parameterar
| Parameter | Description |
|---|---|
| tableid | ID för tabellen som indexet tillhör. |
| indexname | Namnet på indexet. |
Returvärde
Indexets ID.
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
Hämtar en sträng som innehåller namnet på en tabell.
str tableId2Name(int _tableid)
Parameterar
| Parameter | Description |
|---|---|
| _tableid | Tabellens ID. |
Returvärde
Tabellens namn.
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
Hämtar en sträng som innehåller det utskrivbara namnet (etiketten) för en tabell.
str tableId2PName(int _fieldid)
Parameterar
| Parameter | Description |
|---|---|
| _fieldid | Tabellens ID. |
Returvärde
Tabellens etikett.
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
Hämtar ID:t för en tabell.
int tableName2Id(str _name)
Parameterar
| Parameter | Description |
|---|---|
| _Namn | Tabellens namn. |
Returvärde
Tabellens ID.
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
Hämtar typen av ett element.
enum typeOf(anytype _object)
Parameterar
| Parameter | Description |
|---|---|
| _objekt | Elementet som ska returnera typen för. |
Returvärde
Ett typsystemuppräkningsvärde.
Example
I följande exempel testas om det första elementet i en container, c, är en annan container som innehåller ett heltal.
if(typeof(conpeek(c, 1)) != Types::Container ||
conlen(conpeek(c, 1)) != 1 ||
typeof(conpeek(conpeek(c, 1), 1)) != Types::Integer)
{
// More code.
}