रिसर्च सर्वे: Blockly के साथ अपने अनुभव के बारे में हमें बताएं
सर्वे शुरू करें
विवरण
स्टेटमेंट ब्लॉक ऐसे ब्लॉक होते हैं जिनमें आउटपुट कनेक्शन नहीं होते. ये ऐसे काम करते हैं
टेक्स्ट आधारित भाषाओं में स्टेटमेंट.
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 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2024-10-15 (UTC) को अपडेट किया गया.
[null,null,["आखिरी बार 2024-10-15 (UTC) को अपडेट किया गया."],[[["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"]]