# جملة IF الشرطية

#### **التحقق مما إذا كان المتغير غير فارغ**

{% hint style="info" %}
للتحقق من أن المتغير يحتوي على قيمة (أي أنه ليس `None` وليس سلسلة فارغة)، يجب أن تتحقق من أنه **غير مساوٍ لـ** لسلسلة فارغة.

**الصيغة الصحيحة:**

`"#{value}" != ""`

هذا ضروري للتحقق من صحة البيانات، مثل التأكد من استلام استجابة من استدعاء API خارجي قبل المتابعة.
{% endhint %}

### IF()

<details>

<summary>الوصف</summary>

**if(condition, value\_if\_true, value\_if\_false)**

**condition** - trigger

**value\_if\_true** - value if True

**value\_if\_false** - value if False

{% hint style="warning" %}
الحد الأقصى لطول التعبير: 2000 حرف
{% endhint %}

</details>

<details>

<summary>مثال</summary>

لنمرّ عبر بعض الأمثلة:

SILENCEDAYS\_2 = if(SILENCEDAYS\_2 == 1, 1, 0). في هذه الحالة، إذا كان المتغير `SILENCEDAYS_2` موجودًا ويساوي 1، فستبقى قيمته 1. وإذا لم يكن موجودًا أو كانت له قيمة مختلفة، فسيتم تعيينه إلى 0. هذا مفيد قبل إجراء العمليات الحسابية للحماية من قيم المتغيرات الفارغة أو غير المحددة.

ClientName = if(ClientName == 1, P1, if(ClientName == 2, P2, if(ClientName == 3, P3, 7))), حيث إن P1 وP2 وP3 هي متغيرات.&#x20;

إذا كان ClientName يساوي 1، فسيتم تعيين القيمة P1؛\
إذا كان ClientName يساوي 2، فسيتم تعيين القيمة P2؛\
إذا كان ClientName يساوي 3، فسيتم تعيين القيمة P3؛\
وإلا فسيتم تعيين القيمة 7.

كما ترى، يمكن استخدام تراكيب if المتداخلة. وهذا مفيد عندما تريد تعليم الروبوت حساب قيمة الطلب، حيث يعتمد سعر الوحدة على الكمية:

Order\_Amount = round(if(Quantity >=100, if(Quantity >=200, if(Quantity >=300, if(Quantity >=400, if(Quantity >=500, if(Quantity >=1000, if(Quantity >=2000, if(Quantity >=3000, if(Quantity >=5000, 25\*Quantit&#x79;*, 30\**&#x51;uantity), 35\*Quantit&#x79;*), 40\**&#x51;uantity), 45\*Quantit&#x79;*), 50\**&#x51;uantity), 55\*Quantit&#x79;*), 60\**&#x51;uantity), 65\*Quantit&#x79;*), "لا يمكن الحساب... حدث خطأ ما في طلبك. يرجى المحاولة مرة أخرى من البداية.")* \* 100) / 100

<div data-with-frame="true"><figure><img src="/files/f1438ef2c08ed50bc2e2fb191b96d51de1f97c9c" alt=""><figcaption></figcaption></figure></div>

<div data-with-frame="true"><figure><img src="/files/b0c02d6daf111741a853c659573df6ddea413afd" alt=""><figcaption></figcaption></figure></div>

<div data-with-frame="true"><figure><img src="/files/29c469ea8001ea121a0f5f11c284530921b57996" alt=""><figcaption></figcaption></figure></div>

</details>

<details>

<summary>مثال على الكود للنسخ</summary>

<pre><code>SILENCEDAYS_2 = if(SILENCE_DAYS_2 == 1, 1, 0)
ClientName = if(ClientName == 1, Р1, if(ClientName == 2, Р2, if(ClientName == 3, Р3, 7)))
<strong>Order_Amount = round(if(Quantity >=100, if(Quantity >=200, if(Quantity >=300, if(Quantity >=400, if(Quantity >=500, if(Quantity >=1000, if(Quantity >=2000, if(Quantity >=3000, if(Quantity >=5000, 25*Quantity, 30*Quantity), 35*Quantity), 40*Quantity), 45*Quantity), 50*Количество), 55*Quantity), 60*Quantity), 65*Quantity), "لا يمكن الحساب... حدث خطأ ما في طلبك. يرجى المحاولة مرة أخرى من البداية.")  * 100) / 100
</strong></code></pre>

</details>


---

# Agent Instructions: 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:

```
GET https://docs.mavibot.ai/doc/ar/chatbot/functions/alaalh-alhasbh/conditional.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
