--- a/PrintConverter.st Sat Apr 27 19:51:19 1996 +0200
+++ b/PrintConverter.st Sat Apr 27 19:56:35 1996 +0200
@@ -57,27 +57,29 @@
"
stupid examples:
convert date <-> string:
-
+ [exBegin]
|conv|
conv := (PrintConverter new)
- toPrint:[:date | date printString]
- toRead:[:string | Date readFromString:string].
+ toPrint:[:date | date printString]
+ toRead:[:string | Date readFromString:string].
(conv printStringFor:(Date today)) inspect.
(conv readValueFrom:(Date today printString)) inspect
+ [exEnd]
convert number <-> string:
-
+ [exBegin]
|conv|
conv := (PrintConverter new) initForNumber.
(conv printStringFor:12345) inspect.
(conv readValueFrom:'12345') inspect
+ [exEnd]
convert boolean <-> string:
-
+ [exBegin]
|conv|
conv := (PrintConverter new) initForYesNo.
@@ -88,10 +90,11 @@
'if language is german:'.
(conv readValueFrom:'ja').
(conv readValueFrom:'nein')
+ [exEnd]
concrete examples:
convert in an inputField:
-
+ [exBegin]
|dialog field|
dialog := Dialog new.
@@ -103,11 +106,12 @@
dialog addOkButton.
dialog open.
dialog accepted ifTrue:[
- Transcript showCr:field editValue
+ Transcript showCr:field editValue
]
+ [exEnd]
convert a models value for a label:
-
+ [exBegin]
|top v1 v2 l1 l2|
v1 := 0 asValue.
@@ -130,16 +134,17 @@
'now, change the values ...'.
[
- 1 to:50 do:[:i|
- v1 value:(v1 value + 1).
- v2 value:(v2 value addDays:1).
- (Delay forSeconds:0.5) wait
- ]
+ 1 to:50 do:[:i|
+ v1 value:(v1 value + 1).
+ v2 value:(v2 value addDays:1).
+ (Delay forSeconds:0.5) wait
+ ]
] fork
+ [exEnd]
convert a models value for a label with limited precision
float conversion:
-
+ [exBegin]
|top v l1 l2|
v := 0.0 asValue.
@@ -161,15 +166,16 @@
'now, change the values ...'.
[
- 1 to:100 do:[:i|
- v value:(v value + 0.005).
- (Delay forSeconds:0.5) wait
- ]
+ 1 to:100 do:[:i|
+ v value:(v value + 0.005).
+ (Delay forSeconds:0.5) wait
+ ]
] fork
+ [exEnd]
a custom converter, converting a number to either 'odd'
or 'even' strings (we only need a one-way converter for labels):
-
+ [exBegin]
|top v l1 l2|
v := 0 asValue.
@@ -184,10 +190,10 @@
l2 := Label origin:0.0@0.5 corner:1.0@1.0 in:top.
l2 converter:(PrintConverter
- new
- toPrint:[:num | num even ifTrue:['even']
- ifFalse:['odd']]
- toRead:[:string | ]).
+ new
+ toPrint:[:num | num even ifTrue:['even']
+ ifFalse:['odd']]
+ toRead:[:string | ]).
l2 model:v; labelMessage:#value; aspect:#value.
l2 level:-1; inset:10.
@@ -195,11 +201,12 @@
'now, change the values ...'.
[
- 1 to:100 do:[:i|
- v value:(v value + 1).
- (Delay forSeconds:0.5) wait
- ]
+ 1 to:100 do:[:i|
+ v value:(v value + 1).
+ (Delay forSeconds:0.5) wait
+ ]
] fork
+ [exEnd]
see more examples in the EditField examples.
"
@@ -408,5 +415,5 @@
!PrintConverter class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview2/PrintConverter.st,v 1.12 1996-04-25 16:42:28 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview2/PrintConverter.st,v 1.13 1996-04-27 17:56:35 cg Exp $'
! !