Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Open a Workspace with content
Last updated at 7:36 am UTC on 24 February 2018
To programmatically open a workspace with some text already in it, execute this Squeak code:

StringHolder 
  new textContents: ('Hello  World!! This is a test.') 
  withSqueakLineEndings; 
  openLabel: 'Workspace test'




 | st ws |
 st := WriteStream  on: String new.
 
 0 to: 30 do: [:i | st nextPutAll: (Date today addDays: i) printString.
	             st nextPutAll: ': '.
	             st cr].

 ws := Workspace new.
 ws contents: st contents.
 ws openLabel: 'Next 31 days'.

Workspace_with_next_31_days.png

To include the weekday
 | st ws |
 st := WriteStream  on: String new.
 
 0 to: 30 do: [:i | | d |
 	                      d := Date today addDays: i.
 	                      st nextPutAll: d dayOfWeekName.
 	                      st nextPutAll: ', '.
 	                      st nextPutAll: d printString.
 	                      st nextPutAll: ': '.
 	                      st cr].
 
 ws := Workspace new.
 ws contents: st contents.
 ws openLabel: 'Next 31 days'.


With Text

TextStyle default font sizes.png

 | currentFont fa string textStream |
 textStream := TextStream on: (Text new: 5000).

 string := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
 currentFont := TextStyle default.
fa := currentFont fontArray.
fa do: [:font | 
textStream withAttribute: 
                (TextFontReference toFont: font)
                    do: [textStream nextPutAll: font pointSize asString, ': ', string; cr].
].	
   Workspace new
    contents: textStream contents;
    openLabel: 'TextStyle default font sizes'