গবেষণা সমীক্ষা: ব্লকলি
স্টার্ট সার্ভে নিয়ে আপনার অভিজ্ঞতা সম্পর্কে আমাদের বলুন
বিবৃতি
স্টেটমেন্ট ব্লক হল আউটপুট সংযোগ ছাড়া ব্লক। এগুলি পাঠ্য-ভিত্তিক ভাষায় বিবৃতির মতো কাজ করে।
ব্লকলির সমস্ত ব্লকের মতো, স্টেটমেন্ট ব্লকগুলিকে ব্লক-কোড জেনারেটর সংজ্ঞায়িত করে কোড স্ট্রিংয়ে পরিণত করা যেতে পারে।
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 সাইট নীতি দেখুন। Java হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-01-10 UTC-তে শেষবার আপডেট করা হয়েছে।
[null,null,["2025-01-10 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"]]