كشوفات الحساب
مجموعات العبارات هي مجموعات بدون اتصالات إخراج. تعمل هذه مثل
العبارات بلغات نصية.
يمكن تحويل مجموعات العبارات إلى رموز، تمامًا مثل جميع الوحدات الأساسية في Blockly
السلاسل من خلال تحديد منشئ كود الكتلة.
import {javascriptGenerator} from 'blockly/javascript';
javascriptGenerator.forBlock['custom_block'] = function(block, generator) {
// Collect argument strings.
const fieldValue = block.getFieldValue('MY_FIELD');
const innerCode = generator.statementToCode(block, 'MY_STATEMENT_INPUT');
// Return code.
return 'my code string';
}
جمع سلاسل الوسيطات
تتطلب جميع أدوات إنشاء رموز الحظر
وجمع قيم الحقول وجمع رمز
وكتلة داخلية.
// Collect field values.
const fieldValue = block.getFieldValue('MY_FIELD');
// Collect inner block code strings.
const innerCode = generator.statementToCode(block, 'MY_STATEMENT_INPUT');
إذا كنت تشير إلى رمز كتلة داخلية عدة مرات، فيجب عليك إضافة
التخزين المؤقت للوسيطات في الحظر.
القيم المعروضة
نوع الإرجاع لمنشئ كود حظر العبارة هو سلسلة تعليمة برمجية.
return 'my code string';
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2024-10-15 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2024-10-15 (حسب التوقيت العالمي المتفَّق عليه)"],[[["Statement blocks in Blockly, similar to statements in text-based languages, lack output connections and function by defining a block-code generator to convert them into code strings."],["Generating code for statement blocks involves collecting values from fields and inner blocks using dedicated functions within the block-code generator."],["Block-code generators for statement blocks return code strings, representing the translated code for the block, and optionally incorporate argument caching for optimized code generation."]]],["Statement blocks, which lack output connections, are converted to code strings using block-code generators. This process involves collecting values from fields and code from inner blocks. The `getFieldValue` method retrieves field values, while `statementToCode` gathers inner block code. If inner block code is used multiple times, argument caching is recommended. Ultimately, a statement block-code generator returns a string representing the generated code.\n"]]