--- SECTION: Example 7: Language Initialization Logic --- - كتاب هندسة البرمجيات - الصف 12 - الفصل 1 - المملكة العربية السعودية

الكتاب: كتاب هندسة البرمجيات - الصف 12 - الفصل 1 | المادة: هندسة البرمجيات | المرحلة: الصف 12 | الفصل الدراسي: 1

الدولة: المملكة العربية السعودية | المنهج: المنهج السعودي - وزارة التعليم

الدرس: Example 7: Language Initialization Logic

📚 معلومات الصفحة

الكتاب: كتاب هندسة البرمجيات - الصف 12 - الفصل 1 | المادة: هندسة البرمجيات | المرحلة: الصف 12 | الفصل الدراسي: 1

الدولة: المملكة العربية السعودية | المنهج: المنهج السعودي - وزارة التعليم

📝 ملخص الصفحة

ملخص الصفحة 172

تقدم هذه الصفحة أمثلة توضيحية لاستخدام المنطق الشرطي (Conditional Logic) في تهيئة تطبيق باستخدام MIT App Inventor، مع التركيز على تحديد المحتوى بناءً على إعدادات اللغة.

1. مثال للمنطق الشرطي للتهيئة:

يوضح هذا المثال كيفية استخدام هيكل `if-then-else if` للتحقق من قيمة بدء (`start value`) لتحديد الإجراءات اللاحقة. يتم فحص ما إذا كانت القيمة هي `"en"` (الإنجليزية) أو `"ar"` (العربية). الكتلة المميزة بالرقم (7) هي كتلة `join`، والتي تُستخدم عادةً لدمج السلاسل النصية (Concatenation).

2. مثال لتعيين خاصية النص:

يوضح هذا المثال كيفية تعيين خاصية `Text` لعنصر واجهة المستخدم `title_label` بناءً على تفضيل اللغة. إذا كانت قيمة البدء `"en"`، يتم تعيين نص التسمية إلى المتغير العام `title_en`. وإذا كانت `"ar"`، يتم تعيينه إلى المتغير العام `title_ar`. الكتلة المميزة بالرقم (8) هي كتلة `set title_label .Text to`، المستخدمة لتعيين قيمة لخاصية النص الخاصة بالتسمية.

الأشكال التوضيحية:

الشكل 1: محرر كتل MIT App Inventor (الجزء العلوي)

* يظهر لوحة `Blocks` على اليسار تحتوي على فئات مثل `Control`، `Logic`، `Variables`.

* يظهر في لوحة `Viewer` على اليمين كتلة تهيئة رئيسية بنية `when AlMasmak .Initialize do`.

* تحتوي كتلة التهيئة على هيكل شرطي `if-then-else if-then` للتحقق من `get start value`.

* توجد كتلة `join` (مرقمة بـ 7) موجهة نحو كتلة التهيئة.

الشكل 2: محرر كتل MIT App Inventor (الجزء السفلي)

* تظهر لوحة `Blocks` على اليسار مكونات شاشة `AlMasmak` مثل `title_label` و `description_label`.

* تظهر في لوحة `Viewer` على اليمين كتل لتعيين خصائص `title_label`، بما في ذلك `set title_label .Text to` (مرقمة بـ 8).

* يتم توصيل كتلة التعيين هذه بكتلة التهيئة `when AlMasmak .Initialize do` الموجودة أسفلها.

* تحتوي كتلة التهيئة على هيكل شرطي مكتمل: إذا كانت `start value` تساوي `"en"`، فاضبط النص على `get global title_en`، وإذا كانت تساوي `"ar"`، فاضبط النص على `get global title_ar`.

📋 المحتوى المنظم

📖 محتوى تعليمي مفصّل

Example 7: Language Initialization Logic

نوع: محتوى تعليمي

This example demonstrates conditional logic for initializing an application based on a 'start value', likely a language setting. It checks if the 'start value' is 'en' (English) or 'ar' (Arabic) to determine further actions. The highlighted block (7) is a 'join' block, typically used for concatenating text strings.

Example 8: UI Text Property Setting

نوع: محتوى تعليمي

This example illustrates how to set the 'Text' property of a 'title_label' UI component based on a language preference. If the 'start value' is 'en', the 'title_label' text is set to a global English title variable. If it's 'ar', it's set to a global Arabic title variable. The highlighted block (8) is a 'set title_label .Text to' block, used for assigning a value to the text property of the label.

نوع: METADATA

وزارة التعليم Ministry of Education 2023 - 1447 172

🔍 عناصر مرئية

MIT App Inventor Blocks Editor with Initialization Logic

A screenshot of the MIT App Inventor Blocks editor. The left panel, labeled 'Blocks', shows categories like 'Built-in' (Control, Logic, Math, Text, Lists, Dictionaries, Colors, Variables, Procedures). The right panel, labeled 'Viewer', displays several code blocks. These include a pink text block with empty quotes, a blue 'join' block with a gear icon (highlighted by blue circle '7'), a pink 'length' block, and a pink 'is empty' block. A dashed blue arrow points from the 'join' block to a larger, brown 'when AlMasmak .Initialize do' block on the far right. This initialization block contains a conditional 'if-then-else if-then' structure. The first condition checks 'if get start value = "en"', followed by an empty 'then' slot. The 'else if' condition checks 'get start value = "ar"', also followed by an empty 'then' slot. There is a final empty 'then' slot at the end of the block.

MIT App Inventor Blocks Editor with UI Property Setting Logic

A screenshot of the MIT App Inventor Blocks editor. The left panel, 'Blocks', shows the 'AlMasmak' component category expanded, listing UI elements like 'discover_label', 'VerticalArrangement1', 'title_label', 'image', 'description_label', 'HorizontalArrangement', 'map_button', 'Map1', and 'Any component'. The right panel, 'Viewer', displays several blocks related to setting properties of a 'title_label'. These include getter blocks for 'title_label .Height', 'title_label .HeightPercent', 'title_label .Text', and 'title_label .TextColor'. It also shows setter blocks: 'set title_label .Height to', 'set title_label .HeightPercent to', 'set title_label .Text to' (highlighted by blue circle '8'), and 'set title_label .TextColor to', all with empty value slots. A dashed blue arrow points from the highlighted 'set title_label .Text to' block to a larger, brown 'when AlMasmak .Initialize do' block below it. This initialization block contains a conditional 'if-then-else if-then' structure. The first condition checks 'if get start value = "en"', and its 'then' slot contains 'set title_label .Text to get global title_en'. The 'else if' condition checks 'get start value = "ar"', and its 'then' slot contains 'set title_label .Text to get global title_ar'.

📄 النص الكامل للصفحة

--- SECTION: Example 7: Language Initialization Logic --- This example demonstrates conditional logic for initializing an application based on a 'start value', likely a language setting. It checks if the 'start value' is 'en' (English) or 'ar' (Arabic) to determine further actions. The highlighted block (7) is a 'join' block, typically used for concatenating text strings. --- SECTION: Example 8: UI Text Property Setting --- This example illustrates how to set the 'Text' property of a 'title_label' UI component based on a language preference. If the 'start value' is 'en', the 'title_label' text is set to a global English title variable. If it's 'ar', it's set to a global Arabic title variable. The highlighted block (8) is a 'set title_label .Text to' block, used for assigning a value to the text property of the label. وزارة التعليم Ministry of Education 2023 - 1447 172 --- VISUAL CONTEXT --- **FIGURE**: MIT App Inventor Blocks Editor with Initialization Logic Description: A screenshot of the MIT App Inventor Blocks editor. The left panel, labeled 'Blocks', shows categories like 'Built-in' (Control, Logic, Math, Text, Lists, Dictionaries, Colors, Variables, Procedures). The right panel, labeled 'Viewer', displays several code blocks. These include a pink text block with empty quotes, a blue 'join' block with a gear icon (highlighted by blue circle '7'), a pink 'length' block, and a pink 'is empty' block. A dashed blue arrow points from the 'join' block to a larger, brown 'when AlMasmak .Initialize do' block on the far right. This initialization block contains a conditional 'if-then-else if-then' structure. The first condition checks 'if get start value = "en"', followed by an empty 'then' slot. The 'else if' condition checks 'get start value = "ar"', also followed by an empty 'then' slot. There is a final empty 'then' slot at the end of the block. Context: This figure demonstrates the visual programming environment of MIT App Inventor, showcasing built-in blocks for text manipulation and the structure of an 'Initialize' event handler with conditional logic for language selection. **FIGURE**: MIT App Inventor Blocks Editor with UI Property Setting Logic Description: A screenshot of the MIT App Inventor Blocks editor. The left panel, 'Blocks', shows the 'AlMasmak' component category expanded, listing UI elements like 'discover_label', 'VerticalArrangement1', 'title_label', 'image', 'description_label', 'HorizontalArrangement', 'map_button', 'Map1', and 'Any component'. The right panel, 'Viewer', displays several blocks related to setting properties of a 'title_label'. These include getter blocks for 'title_label .Height', 'title_label .HeightPercent', 'title_label .Text', and 'title_label .TextColor'. It also shows setter blocks: 'set title_label .Height to', 'set title_label .HeightPercent to', 'set title_label .Text to' (highlighted by blue circle '8'), and 'set title_label .TextColor to', all with empty value slots. A dashed blue arrow points from the highlighted 'set title_label .Text to' block to a larger, brown 'when AlMasmak .Initialize do' block below it. This initialization block contains a conditional 'if-then-else if-then' structure. The first condition checks 'if get start value = "en"', and its 'then' slot contains 'set title_label .Text to get global title_en'. The 'else if' condition checks 'get start value = "ar"', and its 'then' slot contains 'set title_label .Text to get global title_ar'. Context: This figure demonstrates how to programmatically control UI component properties in MIT App Inventor, specifically setting the text of a label based on a language preference using global variables within an 'Initialize' event handler.