#DOCUMENTATION by cg
authorClaus Gittinger <cg@exept.de>
Sun, 06 May 2018 13:12:45 +0200
changeset 4085815d85b10332
parent 4084 c8e84f0ba64e
child 4086 de7c2d6148e1
#DOCUMENTATION by cg
class: PrintConverter
comment/format in:
#initForIntegerOrNil
#initForNumberOrNil
changed: #initForYesNo
PrintConverter.st
     1.1 --- a/PrintConverter.st	Tue May 01 10:39:23 2018 +0200
     1.2 +++ b/PrintConverter.st	Sun May 06 13:12:45 2018 +0200
     1.3 @@ -1,3 +1,5 @@
     1.4 +"{ Encoding: utf8 }"
     1.5 +
     1.6  "
     1.7   COPYRIGHT (c) 1995 by Claus Gittinger
     1.8  	      All Rights Reserved
     1.9 @@ -386,11 +388,16 @@
    1.10      "initialize to convert to/from an integer 
    1.11       - if the string is empty or invalid, convert to nil"
    1.12  
    1.13 -    valueToStringBlock := [:num | 
    1.14 -	num isNil ifTrue:[''] 
    1.15 -		  ifFalse:[num printString]].
    1.16 -    stringToValueBlock := [:string | 
    1.17 -	Integer readFromString:string onError:nil]
    1.18 +    valueToStringBlock := 
    1.19 +        [:num | 
    1.20 +            num isNil 
    1.21 +                ifTrue:[''] 
    1.22 +                ifFalse:[num printString]
    1.23 +        ].
    1.24 +    stringToValueBlock := 
    1.25 +        [:string | 
    1.26 +            Integer readFromString:string onError:nil
    1.27 +        ]
    1.28  !
    1.29  
    1.30  initForNumber
    1.31 @@ -405,22 +412,22 @@
    1.32      "initialize to convert to/from a number 
    1.33       - if the string is empty or invalid, convert to nil"
    1.34  
    1.35 -    valueToStringBlock := [:num | 
    1.36 -        num isNil ifTrue:[''] 
    1.37 -                  ifFalse:[num printString]].
    1.38 -    stringToValueBlock := [:string |
    1.39 -        |s|
    1.40 +    valueToStringBlock := 
    1.41 +        [:num | 
    1.42 +            num isNil 
    1.43 +                ifTrue:[''] 
    1.44 +                ifFalse:[num printString]
    1.45 +        ].
    1.46 +    stringToValueBlock := 
    1.47 +        [:string |
    1.48 +            |s|
    1.49  
    1.50 -        s := string.
    1.51 -        (s endsWith:'.') ifTrue:[
    1.52 -            s := s , '0'
    1.53 -        ].
    1.54 -        Number readFromString:s onError:nil
    1.55 -    ]
    1.56 -
    1.57 -
    1.58 -
    1.59 -
    1.60 +            s := string.
    1.61 +            (s endsWith:'.') ifTrue:[
    1.62 +                s := s , '0'
    1.63 +            ].
    1.64 +            Number readFromString:s onError:nil
    1.65 +        ]
    1.66  !
    1.67  
    1.68  initForString
    1.69 @@ -452,9 +459,14 @@
    1.70       (i.e. if german, ja/nein has to be entered.
    1.71       Invalid entries are converted to false."
    1.72  
    1.73 -    valueToStringBlock := [:bool | bool ifTrue:[ApplicationModel classResources string:'yes']
    1.74 -                                        ifFalse:[ApplicationModel classResources string:'no']].
    1.75 -    stringToValueBlock := [:string | string = (ApplicationModel classResources string:'yes')]
    1.76 +    valueToStringBlock := 
    1.77 +        [:bool | 
    1.78 +            ApplicationModel classResources string:(bool ifTrue:['yes'] ifFalse:['no'])
    1.79 +        ].
    1.80 +    stringToValueBlock := 
    1.81 +        [:string | 
    1.82 +            string = (ApplicationModel classResources string:'yes')
    1.83 +        ]
    1.84  !
    1.85  
    1.86  toPrint:printBlock toRead:readBlock