備註
社區興趣小組現在已從 Yammer 轉移到 Microsoft Viva Engage。 若要加入 Viva Engage 社群並參與最新的討論,請填寫 [ 要求存取財務和營運 Viva Engage 社群 表單 」 ,並選擇您要加入的社群。
本文列出編譯階段函式,並說明其語法、參數和傳回值。
概觀
編譯時間函式會在編譯 X++ 程式碼期間儘早執行。 應盡可能在 X++ 程式碼中使用它們,讓程式碼能夠復原儲存在應用程式總管中儲存的中繼資料變更。 編譯時間函式的輸入值會由編譯器驗證。 如果找不到輸入值符合應用程式總管中任何現有物件,編譯器會發出錯誤。 這些函數的輸入必須是文字,因為編譯器無法判斷變數在執行時期所包含的值。 編譯時函數是中繼資料宣告函數。 它會採用代表應用程式總管中實體的引數,並在編譯階段驗證引數。 它在執行階段沒有影響。 屬性是繼承自 SysAttribute 類別的類別。 若要支援表單、報表、查詢和功能表中繼資料的驗證,請在控制項上使用 AutoDeclaration 屬性。 這些函式大部分都會擷取應用程式總管中專案的中繼資料。 一些常見的編譯時函數如下:
-
classNum— 擷取類別的 ID。 -
classStr— 在編譯期間,驗證該名稱的類別是否存在。 此方法比稍後在執行階段探索錯誤更好。 -
evalBuf— 評估 X++ 程式碼的輸入字串,然後將結果傳回為字串。 -
literalStr– 在給定標籤的字串表示法時擷取標籤 ID,例如字串"@SYS12345"。 例如:myLabel.exists(literalStr("@SYS12345"));。
備註
無法從 .NET 程式呼叫 X++ 編譯時間函式。
Functions
屬性Str
驗證指定的屬性類別是否存在於應用程式總管中;如果沒有,則會發生編譯器錯誤。
語法
str classStr(class class)
參數
| 參數 | Description |
|---|---|
| 類別 | 要驗證的屬性名稱。 |
傳回值
屬性的名稱。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
static void attributeStrExample(Args _args)
{
str s;
;
s = attributeStr(AifDocumentOperationAttribute);
print s;
pause;
}
類別編號
擷取指定類別的識別碼。
語法
int classNum(class class)
參數
| 參數 | Description |
|---|---|
| 類別 | 要擷取 ID 的類別。 |
傳回值
指定類別的識別碼。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
static void classNumExample(Args _args)
{
int i;
;
i = classNum(Global);
print i;
pause;
}
類別
以字串的形式擷取類別的名稱。
語法
str classStr(class class)
參數
| 參數 | Description |
|---|---|
| 類別 | 要傳回的類別名稱。 |
傳回值
類別的名稱。
備註
使用此函式,而不是文字文字來擷取包含類別名稱的字串。 如果類別不存在,則函數會在編譯時產生語法錯誤。 這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
static void clStrExample(Args _args)
{
str s;
;
s = classStr(Global);
print s;
pause;
}
組態KeyNum
擷取指定組態金鑰的識別碼。
語法
int configurationKeyNum(str keyname)
參數
| 參數 | Description |
|---|---|
| 鍵名 | 要傳回 ID 的組態金鑰。 |
傳回值
指定組態金鑰的 ID。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
static void configurationKeyNum(Args _args)
{
int i;
;
i = configurationKeyNum(AIF);
print i;
pause;
}
configurationKeyStr
以字串形式擷取組態索引鍵的名稱。
語法
str configurationKeyStr(str keyname)
參數
| 參數 | Description |
|---|---|
| 鍵名 | 組態金鑰的名稱。 |
傳回值
組態金鑰的名稱。
備註
使用此函數,而不是文字文字來擷取包含配置索引鍵名稱的字串。 如果索引鍵不存在,則函數會在編譯時產生語法錯誤。 這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
static void configurationKeyStrExample(Args _args)
{
str s;
;
s = configurationKeyStr(AIF);
print s;
pause;
}
dataEntityDataSourceStr
擷取資料實體的資料來源名稱。
語法
str dataEntityDataSourceStr(str dataEntity, str dataSource)
參數
| 參數 | Description |
|---|---|
| dataEntity | 資料實體的名稱。 |
| dataSource | 資料來源的名稱。 |
傳回值
資料來源的名稱。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
沒有例子。
代表Str
傳回委派的名稱。
語法
str delegateStr(str class, str instanceDelegate)
參數
| 參數 | Description |
|---|---|
| 類別 | 類別、資料表或表單的名稱。 |
| instance委派 | 執行個體委派的名稱。 |
傳回值
代理人的名稱。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
沒有例子。
dimensionHierarchyLevelStr (維度階層層級)
傳回維度階層層級的名稱。
語法
str dimensionHierarchyLevelStr(str dimensionHierarchyLevel)
參數
| 參數 | Description |
|---|---|
| dimensionHierarchyLevel | 維度階層層級的名稱。 |
傳回值
維度階層層級的名稱。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
沒有例子。
dimensionHierarchyStr
傳回維度階層的名稱。
語法
str dimensionHierarchyStr(str dimensionHierarchy)
參數
| 參數 | Description |
|---|---|
| dimensionHierarchy | 維度階層的名稱。 |
傳回值
維度階層的名稱。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
沒有例子。
dimensionReferenceStr
傳回標註參考的名稱。
語法
str dimensionReferenceStr(str dimensionReference)
參數
| 參數 | Description |
|---|---|
| 維度參考 | 標註參考的名稱。 |
傳回值
標註參考的名稱。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
沒有例子。
職責
擷取代表指定安全責任名稱的字串。
語法
str dutyStr(str securityDuty)
參數
| 參數 | Description |
|---|---|
| 安全職責 | 安全職責的名稱。 |
傳回值
字串中的安全責任名稱。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
沒有例子。
列舉Cnt
擷取指定列舉類型中的元素數目。
語法
int enumCnt(enum enumtype)
參數
| 參數 | Description |
|---|---|
| 列舉類型 | 列舉類型。 |
傳回值
指定列舉類型中的元素數目。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
enumCnt(NoYes); //Returns 2, as the two elements are Yes and No.
enumLiteralStr
指出指定的字串是否為指定列舉類型的元素。
語法
\enumLiteralStr(enum enum, string str)
參數
| 參數 | Description |
|---|---|
| 列舉 | 要從中擷取指定值的列舉類型。 |
傳回值
如果找到指定的字串,則 str 參數的值;否則,編譯錯誤。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
static void getEnumValueAsString()
{
str i;
i = enumLiteralStr(ABCEnum, "valueInABCEnum");
print i;
pause;
}
列舉編號
擷取指定列舉類型的識別碼。
語法
int enumNum(enum enum)
參數
| 參數 | Description |
|---|---|
| 列舉 | 要傳回識別碼的列舉。 |
傳回值
指定列舉類型的識別碼。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
static void enumNum(Args _args)
{
int i;
;
i = enumNum(ABC);
print i;
pause;
}
列舉
擷取列舉的名稱為字串。
語法
str enumStr(enum enum)
參數
| 參數 | Description |
|---|---|
| 列舉 | 列舉的名稱。 |
傳回值
列舉的名稱。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
static void enumStrExample(Args _args)
{
str s;
;
s = enumStr(ABC);
print s;
pause;
}
extendedTypeNum
擷取指定擴充資料類型的識別碼。
語法
int extendedTypeNum(int str)
參數
| 參數 | Description |
|---|---|
| str | 要傳回 ID 的擴充資料類型。 |
傳回值
指定擴充資料類型的識別碼。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
static void EDTNum(Args _args)
{
int i;
str s;
;
i = extendedTypeNum(AccountName);
s = extendedTypeStr(AccountName);
print int2Str(i);
print s;
pause;
}
extendedTypeStr
將擴充資料類型的名稱擷取為字串。
語法
str extendedTypeStr(int str)
參數
| 參數 | Description |
|---|---|
| str | 擴充資料類型的名稱。 |
傳回值
擴充資料類型的名稱。
備註
使用此函數,而不是文字文字,以傳回包含擴充資料類型名稱的字串。 如果資料類型不存在,則 extendedTypeStr 函數會在編譯階段產生語法錯誤。 這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
static void EDTStr(Args _args)
{
int i;
str s;
;
i = extendedTypeNum(AccountName);
s = extendedTypeStr(AccountName);
print int2Str(i);
print s;
pause;
}
欄位編號
傳回指定欄位的 ID 號碼。
語法
int fieldNum(str tableName, str fieldName)
參數
| 參數 | Description |
|---|---|
| tableName | 數據表的名稱。 |
| 欄位名稱 | 欄位的名稱。 |
傳回值
指定欄位的識別碼。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
下列範例會列印 CustTable 資料表中 CashDisc 欄位的號碼。
static void fieldNumExample(Args _args)
{
int myInt;
;
myInt = fieldNum(CustTable, CashDisc);
Global::info(strfmt("CashDisc has a field ID of %1 in the CustTable table.", myInt));
}
/****Infolog Display
Message (10:40:00 am)
CashDisc has a field ID of 10 in the CustTable table.
****/
欄位PName
擷取指定欄位的標籤。
語法
str fieldPName(str tableid, str fieldid)
參數
| 參數 | Description |
|---|---|
| 表格ID | 包含指定欄位的資料表。 |
| 欄位識別碼 | 要轉換的欄位。 |
傳回值
欄位的標籤。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
下列範例會列印 CashDisc 欄位的標籤。
static void fieldPNameExample(Args _arg)
{
str myText;
;
myText = fieldPName(CustTable, CashDisc);
Global::info(strfmt("%1 is the label of the CashDisc field.", myText));
}
/****Infolog Display
Message (02:00:57 pm)
Cash discount is the label of the CashDisc field.
****/
欄位Str
擷取指定欄位的欄位名稱。
語法
str fieldStr(str tableid, str fieldid)
參數
| 參數 | Description |
|---|---|
| 表格ID | 包含欄位的資料表。 |
| 欄位識別碼 | 要轉換的欄位。 |
傳回值
指定欄位的欄位名稱。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
下列範例會將 CashDisc 欄位的名稱指派給 myText 變數。
static void fieldStrExample(Args _arg)
{
str myText;
;
myText = fieldStr(CustTable, CashDisc);
Global::info(strfmt("%1 is the specified field.", myText));
}
/****Infolog Display
Message (09:11:52 am)
CashDisc is the specified field.
****/
formControlStr
導致 X++ 編譯器檢查控制項是否存在於表單上,並將函式呼叫取代為有效控制項名稱的字串。
語法
str formControlStr(formName, controlName)
參數
| 參數 | Description |
|---|---|
| formName | 表單的名稱,而不是引號。 |
| 控制名稱 | 表單上的控制項名稱,而不是引號。 |
傳回值
包含控制項名稱的字串,如應用程式總管所示。
備註
如果編譯器判斷表單上不存在控制項,則會發出編譯錯誤。 如果您的 X++ 程式碼使用包含引號的字串來提供控制項名稱,則在執行階段之前無法探索到錯誤。 使用此函式可讓編譯器在編譯階段更早地探索錯誤。 編譯器執行的 X++ 函數 (例如 formControlStr ) 稱為編譯階段函數或編譯階段函數。 這就是為什麼輸入參數不是引號中的標準字串。 編譯時間函數不會在編譯器輸出的 p 程式碼或其他可執行檔中表示。 這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
沒有例子。
formDataFieldStr
傳回表單中資料欄位的名稱。
語法
str formDataFieldStr(str formName, str dataSource, str dataField)
參數
| 參數 | Description |
|---|---|
| formName | 表單的名稱。 |
| dataSource | 表單的資料來源。 |
| data欄位 | 資料來源的資料欄位。 |
傳回值
表單中資料欄位的名稱。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
str a = formDataFieldStr(FMVehicle, FMModelRate, RatePerDay);
formDataSourceStr
傳回表單中資料來源的名稱。
語法
str formDataSourceStr(str formName, str dataSource)
參數
| 參數 | Description |
|---|---|
| formName | 表單的名稱。 |
| dataSource | 表單的資料來源。 |
傳回值
表單中資料來源的名稱。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
str b = formDataSourceStr(FMVehicle, FMModelRate);
formMethodStr
傳回表單方法的名稱。
語法
str formMethodStr(str formName, str methodName)
參數
| 參數 | Description |
|---|---|
| formName | 表單的名稱。 |
| 方法名稱 | 表格的方法。 |
傳回值
表單中方法的名稱。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
下列範例會列印 showDialog 方法的名稱。
str c = formMethodStr(Batch,showDialog);
形式Str
擷取表單的名稱。
語法
str formStr(str form)
參數
| 參數 | Description |
|---|---|
| 表單 | 表單的名稱。 |
傳回值
代表表單名稱的字串。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
下列範例會列印 InventDim 表單的名稱。
static void formStrExample(Args _arg)
{
;
Global::info(formStr(InventDim));
}
/****Infolog Display
Message (11:04:39 am)
InventDim
****/
識別 Str
將指定的識別碼轉換為字串。
語法
str identifierStr(str ident)
參數
| 參數 | Description |
|---|---|
| 識別 | 要轉換的識別碼。 |
傳回值
代表指定識別碼的字串。
備註
如果您使用 identifierStr 函式,您將收到最佳做法警告。 發生這種情況是因為對 identifierStr 執行存在檢查。 如果有的話,請嘗試使用更具體的編譯時間函數。 這是一個編譯時函數。 如需詳細資訊,請參閱 概觀。
Example
下列程式碼範例會將 myvar 變數名稱指派給 thevar 變數。
static void indentifierStrExample(Args _args)
{
str myvar;
str thevar
;
thevar = "[" + identifierStr(myvar) + "]";
Global::info(strfmt(thevar));
}
/****Infolog Display
Message (09:19:49 am)
[myvar]
****/
索引編號
將指定的索引轉換為數字。
語法
int indexNum(str tableid, str indexid)
參數
| 參數 | Description |
|---|---|
| 表格ID | 包含索引的資料表。 |
| indexid | 要轉換的索引。 |
傳回值
代表指定索引的索引號碼。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
下列範例會傳回 Party 索引的索引值。
static void indexNumExample(Args _arg)
{
;
Global::info(strfmt("%1 is the index number of Party.", indexNum(CustTable, Party)));
}
/****Infolog Display
Message (11:28:03 am)
3 is the index number of Party.
****/
索引Str
將指定的索引轉換為字串。
語法
str indexStr(str tableid, str indexid)
參數
| 參數 | Description |
|---|---|
| 表格ID | 包含索引的資料表。 |
| indexid | 要轉換的索引。 |
傳回值
代表指定索引的字串。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
下列範例會將 CashDisc 索引值指派給 myText 變數。
static void fieldStrExample(Args _arg)
{
str myText;
;
myText = fieldStr(CustTable, CashDisc);
Global::info(strfmt("%1 is the specified index.", myText));
}
/****Infolog Display
Message (09:11:52 am)
CashDisc is the specified index.
****/
licenseCodeNum
驗證指定的授權碼是否存在於應用程式總管中;如果沒有,則會發生編譯器錯誤。
語法
int licenseCodeNum(str codename)
參數
| 參數 | Description |
|---|---|
| 代號 | 要驗證的授權代碼名稱。 |
傳回值
指定授權代碼的編號。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
static void licenseCodeNumExample(Args args)
{
int i;
;
i = licenseCodeNum(SysMorphX);
Global::info(strfmt("%1 is the license code number for SysMorphX.", i));
}
/****Infolog Display
Message (01:52:35 pm)
24 is the license code number for SysMorphX.
****/
licenseCodeStr
驗證指定的授權碼是否存在於應用程式總管中;如果沒有,則會發生編譯器錯誤。
語法
str licenseCodeStr(str codename)
參數
| 參數 | Description |
|---|---|
| 代號 | 要驗證的授權代碼名稱。 |
傳回值
指定授權代碼的名稱。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
static void licenseCodeStrExample(Args _arg)
{
str s;
;
s = licenseCodeStr(SysMorphX);
Global::info(strfmt("%1 is the license code string for SysMorphX.", s));
}
/****Infolog Display
Message (02:33:56 pm)
SysMorphX is the license code string for SysMorphX.
****/
文字
驗證指定的字串可以是常值字串;如果沒有,則會發生編譯器錯誤。
語法
str literalStr(int str)
參數
| 參數 | Description |
|---|---|
| 代號 | 要驗證的字串。 |
傳回值
如果有效,則為常值字串。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
{
str s;
;
s = literalStr("This is a literal str");
print s;
pause;
}
最大日期
擷取日期類型變數允許的最大值。
語法
date maxDate()
傳回值
類型為 date 的變數容許的最大值,即 2154-12-31。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
static void maxDateExample(Args _arg)
{
date maximumDate;
;
maximumDate = maxDate();
print maximumDate;
pause;
}
最大單位
擷取可儲存在 int 類型中的最大有正負號值。
語法
int maxInt()
傳回值
整數允許的最大值。
備註
任何其他整數都會小於或等於傳回值。 這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
static void maxIntExample(Args _arg)
{
int i;
;
print "The maximum value for type int is " + int2Str(maxInt());
pause;
}
測量Str
傳回測量的名稱。
語法
str measurementStr(str measurement)
參數
| 參數 | Description |
|---|---|
| 尺寸 | 測量的名稱。 |
傳回值
測量的名稱。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
沒有例子。
測量
傳回量值的名稱。
語法
str measureStr(str measure)
參數
| 參數 | Description |
|---|---|
| 量值 | 量值的名稱。 |
傳回值
量值的名稱。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
沒有例子。
menuItemActionStr
驗證指定的功能表項目動作是否存在於應用程式物件樹狀結構 (應用程式總管) 中;如果沒有,則會發生編譯器錯誤。
語法
str menuItemActionStr(class menuitem)
參數
| 參數 | Description |
|---|---|
| 代號 | 要驗證的功能表項目動作名稱。 |
傳回值
功能表項目動作的名稱 (如果有效)。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
{
str s1, s2, s3, s4;
;
s1 = menuItemActionStr(AssetCopy);
s2 = menuItemDisplayStr(Address);
s3 = menuItemOutputStr(AssetBarcode);
s4 = menuStr(Administration);
print "menuItemActionStr for AssetCopy is " + s1;
print "menuItemDisplayStr for Address is " + s2;
print "menuItemOutputStr for AssetBarcode is " + s3;
print "menuStr for Administration is " + s4;
pause;
}
menuItemDisplayStr
驗證指定的功能表項目顯示是否存在於應用程式總管中;如果沒有,則會發生編譯器錯誤。
語法
str menuitemdisplaystr(class menuItem)
參數
| 參數 | Description |
|---|---|
| 代號 | 要驗證的功能表項目顯示名稱。 |
傳回值
指定功能表項目的名稱顯示(如果有效)。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
{
str s1, s2, s3, s4;
;
s1 = menuItemActionStr(AssetCopy);
s2 = menuItemDisplayStr(Address);
s3 = menuItemOutputStr(AssetBarcode);
s4 = menuStr(Administration);
print "menuItemActionStr for AssetCopy is " + s1;
print "menuItemDisplayStr for Address is " + s2;
print "menuItemOutputStr for AssetBarcode is " + s3;
print "menuStr for Administration is " + s4;
pause;
}
menuItemOutputStr
驗證指定的功能表項目輸出是否存在於應用程式總管中;如果沒有,則會發生編譯器錯誤。
語法
str menuItemOutputStr(class menuitem)
參數
| 參數 | Description |
|---|---|
| 代號 | 要驗證的功能表項目輸出名稱。 |
傳回值
指定的功能表項目輸出 (如果有效)。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
{
str s1, s2, s3, s4;
;
s1 = menuItemActionStr(AssetCopy);
s2 = menuItemDisplayStr(Address);
s3 = menuItemOutputStr(AssetBarcode);
s4 = menuStr(Administration);
print "menuItemActionStr for AssetCopy is " + s1;
print "menuItemDisplayStr for Address is " + s2;
print "menuItemOutputStr for AssetBarcode is " + s3;
print "menuStr for Administration is " + s4;
pause;
}
menuStr
驗證指定的功能表是否存在於應用程式總管中;如果沒有,則會發生編譯器錯誤。
語法
str menuStr(class menu)
參數
| 參數 | Description |
|---|---|
| 功能表 | 要驗證的功能表名稱。 |
傳回值
指定功能表項目的名稱 (如果有效)。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
{
str s1, s2, s3, s4;
;
s1 = menuItemActionStr(AssetCopy);
s2 = menuItemDisplayStr(Address);
s3 = menuItemOutputStr(AssetBarcode);
s4 = menuStr(Administration);
print "menuItemActionStr for AssetCopy is " + s1;
print "menuItemDisplayStr for Address is " + s2;
print "menuItemOutputStr for AssetBarcode is " + s3;
print "menuStr for Administration is " + s4;
pause;
}
方法Str
驗證指定的方法是否存在於指定的類別中;如果沒有,則會發生編譯器錯誤。
語法
str methodStr(class class, int method)
參數
| 參數 | Description |
|---|---|
| 類別 | 類別的名稱。 |
| 方法 | 要驗證的方法名稱。 |
傳回值
指定方法的名稱 (如果有效)。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
{
#define.timeout(50)
str s;
SysHelpInitTimeOut SysHelpInitTimeOut;
;
s = methodStr(SysHelpInitTimeOut, timeout);
print s;
pause;
}
minInt
擷取可儲存在 int 類型中的最小有正負號值。
語法
int minInt()
傳回值
int 類型的最小值。
備註
任何其他整數值都會大於或等於傳回值。 這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
static void minIntExample(Args _arg)
{
int i;
;
i = minInt();
print "minInt() is " + int2Str(i);
pause;
}
特權Str
傳回權限的名稱。
語法
str privilegeStr(str privilege)
參數
| 參數 | Description |
|---|---|
| 權限 | 傳回名稱的專用權。 |
傳回值
許可權的名稱。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
沒有例子。
queryDatasourceStr
導致 X++ 編譯器檢查查詢上是否存在資料來源,並將函式呼叫取代為有效資料來源名稱的字串。
語法
str queryDataSourceStr(queryName, dataSourceName)
參數
| 參數 | Description |
|---|---|
| queryName | 查詢的名稱,不以引號括住。 |
| dataSourceName | 查詢上的資料來源名稱,而不是引號。 |
傳回值
包含資料來源名稱的字串,如應用程式總管所示。
備註
如果編譯器判斷查詢上不存在資料來源,則會發出編譯錯誤。 如果您的 X++ 程式碼使用包含引號的字串來提供資料來源名稱,則在執行階段之前無法探索到錯誤。 使用此函式可讓編譯器在編譯階段更早地探索錯誤。 編譯器所執行的 X++ 函式 (例如 queryDataSourceStr ) 稱為編譯階段函式或編譯時間函式。 這就是為什麼輸入參數不是引號中的標準字串。 編譯時間函數不會在編譯器輸出的 p 程式碼或其他可執行檔中表示。 這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
沒有例子。
queryMethodStr
傳回查詢方法的名稱。
語法
str queryMethodStr(str queryName, str methodName)
參數
| 參數 | Description |
|---|---|
| queryName | 查詢的名稱。 |
| 方法名稱 | 表格的方法。 |
傳回值
查詢中方法的名稱。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
沒有例子。
查詢Str
擷取代表現有查詢的字串。
語法
str queryStr(str query)
參數
| 參數 | Description |
|---|---|
| 查詢 | 要擷取的查詢。 |
傳回值
查詢的名稱。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
static void queryStrExample(Args _arg)
{
str myText;
;
myText = queryStr(AssetTable);
Global::info(strfmt("%1 is the name of the query.",myText));
}
/****Infolog Display
Message (09:45:16 am)
AssetTable is the name of the query.
****/
報告Str
擷取代表指定報告名稱的字串。
語法
str reportStr(str report)
參數
| 參數 | Description |
|---|---|
| 報告 | 要傳回名稱的報表。 |
傳回值
報表的名稱。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
下列範例會將 AssetAddition 報告的名稱指派給 MyTxt 變數。
static void reportStrExample(Args _args)
{
str MyTxt;
;
MyTxt = reportStr(AssetAddition);
Global::info(strfmt("%1 is the name of the report.", MyTxt));
}
/****Infolog Display.
Message (10:46:36 am)
AssetAddition is the name of the report.
****/
資源Str
驗證指定的資源是否存在於應用程式總管中;如果沒有,則會發生編譯器錯誤。
語法
str resourceStr(str resourcename)
參數
| 參數 | Description |
|---|---|
| 資源名稱 | 要驗證的資源名稱。 |
傳回值
指定資源的名稱 (如果有效)。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
{
print "Str for resource StyleSheet_Help_Axapta is "
+ resourceStr(StyleSheet_Help_Axapta);
pause;
}
角色Str
擷取代表指定資訊安全角色名稱的字串。
語法
str roleStr(str securityRole)
參數
| 參數 | Description |
|---|---|
| 安全角色 | 資訊穩定角色的名稱。 |
傳回值
字串中資訊安全角色的名稱。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
沒有例子。
ssrsReportStr
擷取代表指定報告名稱的字串。 當您想要指定應該由報表控制器類別執行的報表時,請使用此函式。
語法
str ssrsReportStr(str report, str design)
參數
| 參數 | Description |
|---|---|
| 報告 | 要傳回名稱的報表。 |
| 設計 | 與報告相關聯的設計名稱。 |
傳回值
報表的名稱。
備註
ssrsReportStr 函式會剖析傳遞給它的兩個值,以驗證它們是否屬於有效的報表。 當功能表項目指向 controller() 時,必須設定報告名稱,以便控制器可以決定必須呼叫哪個報告設計組合。 使用 ssrsReportStr 函式可提供報表和設計名稱編譯階段驗證的優點。 這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
public static void main(Args _args)
{
// Initializing the object for a controller class, in this case, the class named AssetListingController.
SrsReportRunController controller = new AssetListingController();
// Getting the properties of the called object (in this case AssetListing MenuItem)
controller.parmArgs(_args);
// Setting the Report name for the controller.
controller.parmReportName(ssrsReportStr(AssetListing, Report));
// Initiate the report execution.
controller.startOperation();
}
靜態委派Str
傳回靜態委派的名稱。
語法
str staticDelegateStr(str class, str delegate)
參數
| 參數 | Description |
|---|---|
| 類別 | 類別、資料表或表單的名稱。 |
| 委派 | 代理人的名稱。 |
傳回值
代理人的名稱。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
沒有例子。
staticMethodStr
驗證指定的靜態方法是否存在於指定的類別中;如果沒有,則會發生編譯器錯誤。
語法
str staticMethodStr(class class, int method)
參數
| 參數 | Description |
|---|---|
| 類別 | 類別的名稱。 |
| 方法 | 要驗證的靜態方法名稱。 |
傳回值
靜態方法的名稱 (如果有效)。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
沒有例子。
tableCollectionStr
驗證指定的資料表集合是否存在於應用程式總管中;如果沒有,則會發生編譯器錯誤。
語法
str tableCollectionStr(class tablecollection)
參數
| 參數 | Description |
|---|---|
| table集合 | 要驗證的資料表集合名稱。 |
傳回值
指定表格集合的名稱 (如果有效)。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
沒有例子。
tableFieldGroupStr
以字串形式擷取欄位群組的名稱。
語法
str tableFieldGroupStr(str tableName, str fieldGroupName)
參數
| 參數 | Description |
|---|---|
| tableName | 包含欄位群組的資料表。 |
| 欄位群組名稱 | 表格中的欄位群組。 |
傳回值
欄位群組的名稱以字串形式。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
下列範例會擷取 [編輯] 欄位群組的名稱作為字串。
static void tableFieldGroupStrExample(Args _arg)
{
;
Global::info(tableFieldGroupStr(AccountingDistribution, Editing));
}
/****Infolog Display
Message (03:14:54 pm)
Editing
****/
tableMethodStr
驗證指定的方法是否存在於指定的資料表中;如果沒有,則會發生編譯器錯誤。
語法
str tableMethodStr(int table, int method)
參數
| 參數 | Description |
|---|---|
| 表格 | 數據表的名稱。 |
| 方法 | 要驗證的方法名稱。 |
傳回值
方法的名稱 (如果有效)。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
沒有例子。
表格編號
擷取指定資料表的資料表識別碼。
語法
int tableNum(str table)
參數
| 參數 | Description |
|---|---|
| 表格 | 要擷取其資料表 ID 的資料表。 |
傳回值
指定資料表的資料表 ID。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
下列範例會將 tableID 變數設定為 77,這是 CustTable 資料表的識別碼。
static void tableNumExample(Args _args)
{
int tableID;
;
tableID = tableNum(CustTable);
Global::info(strfmt("%1 is the table ID for the CustTable table.", tableID));
}
/****Infolog Display
Message (11:15:54 am)
77 is the table ID for the CustTable table.
****/
tablePName
擷取包含指定資料表可列印名稱的字串。
語法
str tablePName(str table)
參數
| 參數 | Description |
|---|---|
| 表格 | 要擷取可列印名稱的資料表。 |
傳回值
指定資料表的名稱。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
下列範例會將 CustTable 資料表的標籤指派給 MyText 變數。
static void tablePNameExample(Args _args)
{
str MyText;
;
MyText = tablePname(CustTable);
Global::info(strfmt("%1 is the label of the CustTable table.", MyText));
}
/**** Infolog Display.
Message (12:13:53 pm)
Customers is the label of the CustTable table.
****/
tableStaticMethodStr
驗證指定的靜態方法是否存在於指定的資料表中;如果沒有,則會發生編譯器錯誤。
語法
str tableStaticMethodStr(int table, int method)
參數
| 參數 | Description |
|---|---|
| 表格 | 數據表的名稱。 |
| 方法 | 要驗證的靜態方法名稱。 |
傳回值
指定靜態方法的名稱。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
沒有例子。
表格
擷取包含指定資料表名稱的字串。
語法
str tableStr(str table)
參數
| 參數 | Description |
|---|---|
| 表格 | 要擷取字串的資料表。 |
傳回值
包含指定資料表名稱的字串值。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
下列範例會將 CustTable 資料表的名稱指派給 MyTxt 變數。
static void tableStrExample(Args _args)
{
str MyTxt;
;
MyTxt = tableStr(CustTable);
Global::info(strfmt("%1 is the str output of the input of CustTable.", MyTxt));
}
/**** Infolog Display.
Message (01:21:49 pm)
CustTable is the str output of the input of CustTable.
****/
瓷磚
擷取代表指定磚名稱的字串。
語法
str tileStr(str tile)
參數
| 參數 | Description |
|---|---|
| 並排顯示 | 磚的名稱。 |
傳回值
字串中的磚名稱。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
沒有例子。
變種
擷取包含指定變數名稱的字串。
語法
str varStr(str var)
參數
| 參數 | Description |
|---|---|
| var | 變數的名稱。 |
傳回值
包含指定變數名稱的字串。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
static void varStrExample(Args _arg)
{
str myString;
anytype myVariable;
;
myString = varStr(myVariable);
Global::info(strfmt("%1 is the variable name.", myString));
}
/****Infolog Display.
Message (02:26:56 pm)
myVariable is the variable name.
****/
webActionItemStr
驗證指定的 Web 動作項目是否存在於應用程式總管中;如果沒有,則會發生編譯器錯誤。
語法
str webActionItemStr(class webactionitem)
參數
| 參數 | Description |
|---|---|
| webaction項目 | 要驗證的 Web 動作項目名稱。 |
傳回值
指定 Web 動作項目的名稱 (如果有效)。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
{
str s;
;
s = webActionItemStr(EPFlushData);
print "webactionitem str is " + s;
pause;
}
webDisplayContentItemStr
驗證指定的 Web 顯示內容項目是否存在於應用程式總管中;如果沒有,則會發生編譯器錯誤。
語法
str webDisplayContentItemStr(class webdisplaycontentitem)
參數
| 參數 | Description |
|---|---|
| WebDisplayContent項目 | 要驗證的網頁顯示內容項目的名稱。 |
傳回值
指定網頁顯示內容項目的名稱 (如果有效)。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
{
str s;
;
s = webDisplayContentItemStr(EPAdmin);
print "string for webcontent display item EPAdmin is " + s;
pause;
}
webFormStr
驗證指定的 Web 表單是否存在於應用程式總管中;如果沒有,則會發生編譯器錯誤。
語法
str webFormStr(str name)
參數
| 參數 | Description |
|---|---|
| 名稱 | 要驗證的網路表單名稱。 |
傳回值
指定網頁表單的名稱 (如果有效)。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
{
str s;
;
s = webFormStr(EPAdmin);
print "String for web form EPAdmin is " + s;
pause;
}
webletItemStr
驗證指定的 Weblet 項目是否存在於應用程式總管中;如果沒有,則會發生編譯器錯誤。
語法
str webletItemStr(class webletitem)
參數
| 參數 | Description |
|---|---|
| weblet項目 | 要驗證的小孔項目名稱。 |
傳回值
指定 Weblet 項目的名稱 (如果有效)。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
{
str s;
;
s = webletItemStr(WebFormWeblet);
print "String for WebFormWeblet is " + s;
pause;
}
webMenuStr
驗證指定的 Web 功能表是否存在於應用程式總管中;如果沒有,則會發生編譯器錯誤。
語法
str webMenuStr(str name)
參數
| 參數 | Description |
|---|---|
| 名稱 | 要驗證的網頁功能表名稱。 |
傳回值
指定 Web 功能表的名稱 (如果有效)。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
{
str s;
;
s = webMenuStr(ECPAdmin);
print "String for web menu ECPAdmin is " + s;
pause;
}
webOutputContentItemStr
驗證指定的 Web 輸出內容項目是否存在於應用程式總管中;如果沒有,則會發生編譯器錯誤。
語法
str webOutputContentItemStr(class weboutputcontentitem)
參數
| 參數 | Description |
|---|---|
| web輸出內容項目 | 要驗證的 Web 輸出內容項目的名稱。 |
傳回值
指定 Web 輸出內容項目的名稱 (如果有效)。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
{
str s;
;
s = webOutputContentItemStr(EPPriceList);
print "string for weboutput content item EPPriceList is " + s;
pause;
}
網頁DefStr
驗證指定的網頁定義是否存在於應用程式總管中;如果沒有,則會發生編譯器錯誤。
語法
str webpageDefStr(str pagename)
參數
| 參數 | Description |
|---|---|
| 頁面名稱 | 要驗證的網頁定義名稱。 |
傳回值
指定網頁定義的名稱 (如果有效)。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
沒有例子。
webReportStr
驗證指定的 Web 報表是否存在於應用程式總管中;如果沒有,則會發生編譯器錯誤。
語法
str webReportStr(str name)
參數
| 參數 | Description |
|---|---|
| 名稱 | 要驗證的 Web 報告名稱。 |
傳回值
指定 Web 報告的名稱 (如果有效)。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
{
str s;
;
s = webReportStr(EPCSSSalesConfirm);
print "String for web report EPCSSalesConfirm is " + s;
pause;
}
網站DefStr
驗證指定的網站定義是否存在於應用程式總管中;如果沒有,則會發生編譯器錯誤。
語法
str websiteDefStr(str resourcename)
參數
| 參數 | Description |
|---|---|
| 資源名稱 | 要驗證的網站定義名稱。 |
傳回值
指定網站定義的名稱 (如果有效)。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
{
str s;
;
s = websiteDefStr(AxSiteDef_1033_xip);
print "string for web site definition AxSiteDef_1033_xip is " + s;
pause;
}
網站臨時斯特
驗證指定的網站範本是否存在於應用程式總管中;如果沒有,則會發生編譯器錯誤。
語法
str websiteTempStr(str resourcename)
參數
| 參數 | Description |
|---|---|
| 資源名稱 | 要驗證的網站範本名稱。 |
傳回值
指定網站範本的名稱 (如果有效)。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
沒有例子。
webStaticFileStr
驗證指定的 Web 靜態檔案是否存在於應用程式總管中;如果沒有,則會發生編譯器錯誤。
語法
str webStaticFileStr(str pagename)
參數
| 參數 | Description |
|---|---|
| 頁面名稱 | 要驗證的 Web 靜態檔案名稱。 |
傳回值
指定 Web 靜態檔案的名稱 (如果有效)。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
{
str s;
;
s = webStaticFileStr(AXEP);
print "string for web static file AXEP is " + s;
pause;
}
webUrlItemStr
驗證指定的 Web URL 項目是否存在於應用程式總管中;如果沒有,則會發生編譯器錯誤。
語法
str webUrlItemStr(class weburlitem)
參數
| 參數 | Description |
|---|---|
| weburl項目 | 要驗證的 Web URL 項目名稱。 |
傳回值
指定 Web URL 項目的名稱 (如果有效)。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
{
str s;
;
s = webUrlItemStr(EPAdmin);
print "string for web url item EPAdmin is " + s;
pause;
}
webWebPartStr
驗證指定的網頁元件是否存在於應用程式總管中;如果沒有,則會發生編譯器錯誤。
語法
str webWebpartStr(str resourcename)
參數
| 參數 | Description |
|---|---|
| 資源名稱 | 要驗證的網頁組件名稱。 |
傳回值
指定網頁組件的名稱 (如果有效)。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
{
str s;
;
s = webWebpartStr(AxWebParts_cab);
print "string for web part AxWebParts_cab is " + s;
pause;
}
工作流程ApprovalStr
將應用程式物件樹狀結構 (應用程式總管) 中的工作流程核准名稱擷取為字串。
語法
str workflowapprovalstr(approval approval)
參數
| 參數 | Description |
|---|---|
| 核准 | 工作流程核准的應用程式總管名稱。 |
傳回值
字串,代表工作流程核准的應用程式總管名稱。
備註
使用此函式,而不是文字文字,以擷取包含工作流程核准名稱的字串。 如果工作流程核准不存在,則函式會在編譯時產生語法錯誤。 這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
下列程式碼範例會將變數 str s 設定為 MyWorkflowApproval ,這是應用程式總管中工作流程核准的名稱。
static void MyWorkflowApprovalStrExample(Args _args)
{
str s;
;
s = workflowapprovalstr(MyWorkflowApproval);
print s;
pause;
}
workflowCategoryStr
將應用程式物件樹狀結構 (應用程式總管) 中工作流程類別的名稱擷取為字串。
語法
str workflowcategorystr(category category)
參數
| 參數 | Description |
|---|---|
| 分類 | 工作流程類別的應用程式總管名稱。 |
傳回值
代表工作流程類別的應用程式總管名稱的字串。
備註
使用此函式,而不是文字文字,以擷取包含工作流程種類名稱的字串。 如果工作流程種類不存在,則函式會在編譯階段產生語法錯誤。 這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
下列程式碼範例會將變數 str s 設定為 MyWorkflowCategory ,這是應用程式總管中工作流程類別的名稱。
static void MyWorkflowCategoryStrExample(Args _args)
{
str s;
;
s = workflowcategorystr(MyWorkflowCategory);
print s;
pause;
}
工作流程TaskStr
將應用程式物件樹狀結構 (應用程式總管) 中工作流程工作的名稱擷取為字串。
語法
str workflowtaskstr(task task)
參數
| 參數 | Description |
|---|---|
| 工作 | 工作流程工作的應用程式總管名稱。 |
傳回值
代表工作流程工作的應用程式總管名稱的字串。
備註
使用此函式,而不是文字文字,以擷取包含工作流程工作名稱的字串。 如果工作流程作業不存在,則函數會在編譯時產生語法錯誤。 這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
下列程式碼範例會將變數 str s 設定為 MyWorkflowTask ,這是應用程式總管中工作流程工作的名稱。
static void MyWorkflowTaskStrExample(Args _args)
{
str s;
;
s = workflowtaskstr(MyWorkflowTask);
print s;
pause;
}
工作流程類型Str
驗證指定的工作流程類型是否存在於應用程式總管中;如果沒有,則會發生編譯器錯誤。
語法
str workflowTypeStr(str workflow)
參數
| 參數 | Description |
|---|---|
| 工作流程 | 要驗證的工作流程型別名稱。 |
傳回值
工作流程類型的名稱。
備註
這是一個編譯時函數。 如需詳細資訊,請參閱概觀。
Example
static void workFlowTypeStrExample(Args _args)
{
str s;
;
s = workFlowTypeStr(BudgetAccountEntryType);
print s;
pause;
}