diff --git a/packages/Sandblocks-Babylonian/SBStNumber.extension.st b/packages/Sandblocks-Babylonian/SBStNumber.extension.st new file mode 100644 index 00000000..819b0e0c --- /dev/null +++ b/packages/Sandblocks-Babylonian/SBStNumber.extension.st @@ -0,0 +1,42 @@ +Extension { #name : #SBStNumber } + +{ #category : #'*Sandblocks-Babylonian' } +SBStNumber >> wrapInVariantCoveringRange [ + + + | rangeString range | + rangeString := UIManager default + request: 'Enter range of numbers' + initialAnswer: '1 to: 5'. + rangeString ifNil: [^ self]. + + range := [Compiler evaluate: rangeString] on: Error do: [:ex | UIManager inform: 'Not a valid range'. ^ self]. + range start > range stop ifTrue: [range := range stop to: range start. range := range reversed]. + + self wrapInVariantGivenInterval: range. + + + +] + +{ #category : #'*Sandblocks-Babylonian' } +SBStNumber >> wrapInVariantGivenInterval: anInterval [ + + | variant | + variant := SBVariant new. + self sandblockEditor do: + (SBWrapCommand new + selectAfter: #block; + outer: variant; + inner: self; + wrap: [:outer :inner | variant + named: anInterval asString + alternatives: (anInterval collect: [:aNumber | + SBNamedBlock block: (SBStBlockBody new + statements: {(inner veryDeepCopy value: aNumber)}) + named: aNumber asString]) + activeIndex: 1]) + + + +]