注释
社区兴趣团体现已从 Yammer 迁移到Microsoft Viva Engage。 若要加入 Viva Engage 社区并参与最新讨论,请填写 “请求访问财务和运营 Viva Engage 社区 ”表单,然后选择要加入的社区。
本文介绍 X++ 运行时函数。
X++ 语言提供近 200 个系统函数,这些函数不属于任何类并在运行时运行。 对数据类型转换、数学运算和类似任务使用运行时函数。 下面是一些常见的运行时函数:
- str2Int – 从 str 值创建 int 值。
- abs – 从正值或负值创建正实值。
- conFind – 检索容器中元素的位置。
从 .NET 调用运行时函数
X++ 运行时函数的逻辑也在以下 .NET 程序集中实现。
Microsoft.Dynamics.AX.Xpp.Support.DLL
在此程序集中,X++ 运行时函数作为以下类的静态方法实现。
Microsoft.Dynamics.AX.Xpp.PredefinedFunctions
类别和函数
下表列出了并描述了 X++ 函数的类别。 这些类别可帮助你了解许多函数。 但是,这些类别并不表示任何正式构造。
| 类别 | Description |
|---|---|
| 业务 | 输入财务数据和计算公式的函数。 有关详细信息,请参阅 X++ Business Run-Time Functions。 |
| 容器 | 对 X++ 的容器数据类型进行作的函数。 有关详细信息,请参阅 X++ 容器 Run-Time 函数。 |
| 转换 | 将一种类型的数据转换为另一种类型的数据的函数。 有关详细信息,请参阅 X++ 转换 Run-Time 函数。 |
| 日期 | 对日期数据类型进行作的函数。 有关详细信息,请参阅 X++ 日期 Run-Time 函数。 |
| Math | 执行数学计算的函数。 有关详细信息,请参阅 X++ 数学 Run-Time 函数。 |
| 反思 | 访问有关对象的元数据并返回有关这些对象的其他元数据的函数。 有关详细信息,请参阅 X++ 反射 Run-Time 函数。 |
| 会期 | 更改或报告当前用户连接的上下文的函数。 有关详细信息,请参阅 X++ 会话 Run-Time 函数。 |
| 字符串 | 对 str 数据类型进行作的函数。 有关详细信息,请参阅 X++ 字符串 Run-Time 函数。 |
| Other | 蜂鸣, newGuid, 睡眠 |
企业
有关详细信息,请参阅 X++ Business Run-Time Functions。
| cTerm | ddb | dg | 抗体 |
| idg | intvMax | intvName | intvNo |
| intvNorm | pmt | pt | 光伏 |
| 率 | sln | 西德妮 | term |
集装箱
有关详细信息,请参阅 X++ 容器 Run-Time 函数。
- conDel
- conFind
- conIns
- conLen
- conNull
- conPeek
- conPoke
Conversion
有关详细信息,请参阅 X++ 转换 Run-Time 函数。
| any2Date | any2Enum | any2Guid | any2Int |
| any2Int64 | any2Real | any2Str | anytodate |
| anytoenum | anytoguid | anytoint | anytoint64 |
| anytoreal | anytostr | char2Num | date2Num |
| date2Str | datetime2Str | enum2str | guid2Str |
| int2Str | int642Str | num2Char | num2Date |
| num2Str | str2Date | str2Datetime | str2Enum |
| str2Guid | str2Int | str2Int64 | str2Num |
| str2Time | time2Str | uint2Str |
日期
有关详细信息,请参阅 X++ 日期 Run-Time 函数。
| dayName | dayOfMth | dayOfWk | dayOfYr |
| endMth | mkDate | mthName | mthOfYr |
| nextMth | nextQtr | nextYr | prevMth |
| prevQtr | prevYr | systemDateGet | systemDateSet |
| timeNow | 今天 | wkOfYr | 年 |
数学
有关详细信息,请参阅 X++ 数学 Run-Time 函数。
| 腹肌 | acos | asin | atan |
| corrFlagGet | corrFlagSet | 因为 | cosh |
| decRound | exp | exp10 | frac |
| log10 | logN | 最大值 | 分钟 |
| 权力 | 四舍五入 | sin | sinh |
| 鞣 | tanh | trunc |
Reflection
有关详细信息,请参阅 X++ 反射 Run-Time 函数。
| classIdGet | dimOf | fieldId2Name | fieldId2PName |
| fieldName2Id | indexId2Name | indexName2Id | refPrintAll |
| tableId2Name | tableId2PName | tableName2Id | typeOf |
Session
有关详细信息,请参阅 X++ 会话 Run-Time 函数。
| curExt | curUserId | funcName | getCurrentPartition |
| getCurrentPartitionRecId | getPrefix | sessionId | prmIsDefault |
| runAs | setPrefix |
String
有关详细信息,请参阅 X++ 字符串 Run-Time 函数。
| 火柴 | strAlpha | strCmp | strColSeq |
| strDel | strFind | strFmt | strIns |
| strKeep | strLen | strLine | strLTrim |
| strLwr | strNFind | strPoke | strPrompt |
| strRem | strRep | strRTrim | strScan |
| strUpr | subStr |
嘟嘟响
从计算机上的扬声器发出简短的声音。
void beep()
beep 示例
static void beepExample(Args _args)
{
beep();
}
newGuid
创建全局唯一标识符(GUID)。
guid newGuid()
返回值
GUID。
newGuid 示例
以下示例创建 GUID。
static void newGuidExample(Args _arg)
{
guid myGuid;
myGuid = newguid();
print strfmt("The GUID is: %1", myGuid);
}
sleep
为指定的毫秒数暂停当前线程的执行。
int sleep(int _duration)
参数
| 参数 | Description |
|---|---|
| _期间 | 要暂停的毫秒数。 |
睡眠返回值
线程实际暂停的毫秒数。
Example
static void sleepExample(Args _arg)
{
int seconds = 10;
int i;
i = sleep(seconds*1000);
print "job slept for " + int2str(i/1000) + " seconds";
}