Skip to content

Commit

Permalink
action to add multiple variants in a range of numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeAtHPI committed Nov 21, 2023
1 parent 677d513 commit 565523e
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions packages/Sandblocks-Babylonian/SBStNumber.extension.st
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])



]

0 comments on commit 565523e

Please sign in to comment.