블록은 프로그래밍에 사용하는 것입니다. 그것들은 표현과 문을 나타냄 텍스트 기반 프로그래밍 언어를 지원합니다.
블록과 블록의 구성 요소에 대한 자세한 내용은 시각적 용어집을 참조하세요.
차단 정의
블록 정의는 스프레드시트의 퍼즐 조각 연결과 필드를 차단될 수 있습니다. 블록의 모양과 스타일은 대부분 다른 방식으로 지정됩니다. 이 블록이 변환되는 문자열 (일반적으로 코드)는 블록 코드 생성기를 사용합니다.
간단한 블록을 정의하는 가장 쉬운 방법은 JSON을 사용하는 것입니다.
이 코드 스니펫은 '앞으로 이동' 다음 및 이전 항목으로 차단 연결, 거리에 대한 필드가 하나 있습니다.
// Create the definition.
const definitions = Blockly.createBlockDefinitionsFromJsonArray([
{
// The type is like the "class name" for your block. It is used to construct
// new instances. E.g. in the toolbox.
type: 'my_custom_block',
// The message defines the basic text of your block, and where inputs or
// fields will be inserted.
message0: 'move forward %1',
args0: [
// Each arg is associated with a %# in the message.
// This one gets substituted for %1.
{
// The type specifies the kind of input or field to be inserted.
type: 'field_number',
// The name allows you to reference the field and get its value.
name: 'FIELD_NAME',
}
],
// Adds an untyped previous connection to the top of the block.
previousStatement: null,
// Adds an untyped next connection to the bottom of the block.
nextStatement: null,
}
]);
// Register the definition.
Blockly.defineBlocks(definitions);
블록을 정의하는 방법에 대한 자세한 내용은 다음을 참조하세요. 블록 정의
도구 상자에 블록을 포함하는 방법에 대한 자세한 내용은 도구 상자 개요를 참조하세요.