# HG changeset patch # User Claus Gittinger # Date 1525605165 -7200 # Node ID 815d85b10332981ae1433ad9a0de6b2fb29df512 # Parent c8e84f0ba64e45da0ddb10a295a7eda1d194f5d0 #DOCUMENTATION by cg class: PrintConverter comment/format in: #initForIntegerOrNil #initForNumberOrNil changed: #initForYesNo diff -r c8e84f0ba64e -r 815d85b10332 PrintConverter.st --- a/PrintConverter.st Tue May 01 10:39:23 2018 +0200 +++ b/PrintConverter.st Sun May 06 13:12:45 2018 +0200 @@ -1,3 +1,5 @@ +"{ Encoding: utf8 }" + " COPYRIGHT (c) 1995 by Claus Gittinger All Rights Reserved @@ -386,11 +388,16 @@ "initialize to convert to/from an integer - if the string is empty or invalid, convert to nil" - valueToStringBlock := [:num | - num isNil ifTrue:[''] - ifFalse:[num printString]]. - stringToValueBlock := [:string | - Integer readFromString:string onError:nil] + valueToStringBlock := + [:num | + num isNil + ifTrue:[''] + ifFalse:[num printString] + ]. + stringToValueBlock := + [:string | + Integer readFromString:string onError:nil + ] ! initForNumber @@ -405,22 +412,22 @@ "initialize to convert to/from a number - if the string is empty or invalid, convert to nil" - valueToStringBlock := [:num | - num isNil ifTrue:[''] - ifFalse:[num printString]]. - stringToValueBlock := [:string | - |s| + valueToStringBlock := + [:num | + num isNil + ifTrue:[''] + ifFalse:[num printString] + ]. + stringToValueBlock := + [:string | + |s| - s := string. - (s endsWith:'.') ifTrue:[ - s := s , '0' - ]. - Number readFromString:s onError:nil - ] - - - - + s := string. + (s endsWith:'.') ifTrue:[ + s := s , '0' + ]. + Number readFromString:s onError:nil + ] ! initForString @@ -452,9 +459,14 @@ (i.e. if german, ja/nein has to be entered. Invalid entries are converted to false." - valueToStringBlock := [:bool | bool ifTrue:[ApplicationModel classResources string:'yes'] - ifFalse:[ApplicationModel classResources string:'no']]. - stringToValueBlock := [:string | string = (ApplicationModel classResources string:'yes')] + valueToStringBlock := + [:bool | + ApplicationModel classResources string:(bool ifTrue:['yes'] ifFalse:['no']) + ]. + stringToValueBlock := + [:string | + string = (ApplicationModel classResources string:'yes') + ] ! toPrint:printBlock toRead:readBlock