> For the complete documentation index, see [llms.txt](https://hamsterbaron.gitbook.io/hamsterbaron/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hamsterbaron.gitbook.io/hamsterbaron/mechanic-guides/function/evalex.md).

# EvalEx 运算符与函数

## 使用 EvalEx 运算符与函数

本组件支持在配置中直接插入 EvalEx 提供的表达式求值库。EvalEx是一个轻量级的Java库，允许您方便地解析并执行各种类型的表达式字符串，包括数字、布尔值、字符串、日期时间、持续时间和自定数据结构。您可以在任何支持插入占位符或变量的地方直接使用 EvalEx 运算符，常量与数学函数。

> 全部的 EvalEx 表达式可通过此链接查阅：[点击此处跳转至 EvalEx Reference Docs](https://ezylang.github.io/EvalEx/references/operators.html)&#x20;

***

## 使用逻辑运算符

开发过程中，有时候我们希望在单个占位符中进行更精确的取值判断

* 三元条件运算符 `IF`&#x20;

该运算符可用于

```javascript
IF(Condition, trueValue, falseValue)
```

此处的三个参数均可插入完整的表达式

* 多路分支运算符 `SWITCH`

与上一运算符相比

```javascript
SWITCH(Expression, value1, result1, [value2-N, result2-N, ...], [default])
```

***

## 常用函数与示例

借助 EvalEx，您可以在 Arcana 技能配置中灵活应用各种

<table><thead><tr><th width="125">简述</th><th>表达式格式</th><th>说明</th></tr></thead><tbody><tr><td>获得时间戳</td><td><code>DT_DATE_TO_EPOCH(DT_NOW())</code></td><td>在调用时返回当前UNIX时间戳</td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

<table><thead><tr><th width="125"></th><th></th><th></th></tr></thead><tbody><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr></tbody></table>

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hamsterbaron.gitbook.io/hamsterbaron/mechanic-guides/function/evalex.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
