-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
action to add multiple variants in a range of numbers
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
Extension { #name : #SBStNumber } | ||
|
||
{ #category : #'*Sandblocks-Babylonian' } | ||
SBStNumber >> wrapInVariantCoveringRange [ | ||
<action> | ||
|
||
| 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]) | ||
|
||
|
||
|
||
] |