forked from AUEB-BALab/blockly_unix
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3fd2f85
commit bb3fbf2
Showing
9 changed files
with
266 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
var conditionBlock = { | ||
type: 'condition', | ||
category: 'Field Processing', | ||
message0: '%1', // First message line for left_part | ||
args0: [ | ||
{ | ||
type: 'input_value', | ||
name: 'left_part', | ||
check: ['String', 'Number', 'Boolean'] // Allow both String and Number types | ||
} | ||
], | ||
message1: '%1', // Second message line for operator | ||
args1: [ | ||
{ | ||
type: 'field_dropdown', | ||
name: 'operator', | ||
options: [ | ||
['==', '=='], | ||
['!=', '!='], | ||
['<', '<'], | ||
['<=', '<='], | ||
['>', '>'], | ||
['>=', '>='] | ||
] | ||
} | ||
], | ||
message2: '%1', // Third message line for right_part | ||
args2: [ | ||
{ | ||
type: 'input_value', | ||
name: 'right_part', | ||
check: ['String', 'Number', 'Boolean'] // Allow both String and Number types | ||
} | ||
], | ||
style: 'Field Processing', | ||
previousStatement: null, | ||
generateCommand: function (block) { | ||
var awkCondition = ''; | ||
const leftPartBlock = block.getInputTargetBlock('left_part'); | ||
const rightPartBlock = block.getInputTargetBlock('right_part'); | ||
|
||
const operator = block.getFieldValue('operator'); | ||
var leftPart = ''; | ||
var rightPart = ''; | ||
|
||
// Retrieve the command for the left part block, if it exists | ||
if (leftPartBlock !== null) { | ||
leftPart = handleBlockByType(leftPartBlock); | ||
} | ||
if (leftPart === '') { | ||
leftPart = leftPartBlock.getFieldValue('TEXT'); | ||
} | ||
console.log('leftPartBlock:', leftPart); | ||
|
||
// Retrieve the command for the right part block, if it exists | ||
if (rightPartBlock !== null) { | ||
rightPart = handleBlockByType(rightPartBlock); | ||
} | ||
|
||
console.log('leftPart:', leftPart); | ||
console.log('operator:', operator); | ||
console.log('rightPart:', rightPart); | ||
|
||
// Combine the parts to form the AWK condition | ||
awkCondition = leftPart + ' ' + operator + ' ' + rightPart; | ||
|
||
return awkCondition; | ||
} | ||
}; | ||
|
||
Blockly.defineBlocksWithJsonArray([conditionBlock]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.