MCPcopy
hub / github.com/RaspberryPiFoundation/blockly / text_indexOf

Function text_indexOf

packages/blockly/generators/dart/text.ts:80–95  ·  view source on GitHub ↗
(
  block: Block,
  generator: DartGenerator,
)

Source from the content-addressed store, hash-verified

78}
79
80export function text_indexOf(
81 block: Block,
82 generator: DartGenerator,
83): [string, Order] {
84 // Search the text for a substring.
85 const operator =
86 block.getFieldValue('END') === 'FIRST' ? 'indexOf' : 'lastIndexOf';
87 const substring = generator.valueToCode(block, 'FIND', Order.NONE) || "''";
88 const text =
89 generator.valueToCode(block, 'VALUE', Order.UNARY_POSTFIX) || "''";
90 const code = text + '.' + operator + '(' + substring + ')';
91 if (block.workspace.options.oneBasedIndex) {
92 return [code + ' + 1', Order.ADDITIVE];
93 }
94 return [code, Order.UNARY_POSTFIX];
95}
96
97export function text_charAt(
98 block: Block,

Callers

nothing calls this directly

Calls 2

getFieldValueMethod · 0.80
valueToCodeMethod · 0.80

Tested by

no test coverage detected