TypeConverter.st
changeset 4178 57a7491ecadb
parent 3973 440d7bd84437
child 4422 11f7d9bc365f
equal deleted inserted replaced
4177:871e7b63f408 4178:57a7491ecadb
       
     1 "{ Encoding: utf8 }"
       
     2 
     1 "
     3 "
     2  COPYRIGHT (c) 1997 eXept Software AG
     4  COPYRIGHT (c) 1997 eXept Software AG
     3               All Rights Reserved
     5               All Rights Reserved
     4 
     6 
     5  This software is furnished under a license and may be used
     7  This software is furnished under a license and may be used
  1578         putBlock:
  1580         putBlock:
  1579                 [:model :string |
  1581                 [:model :string |
  1580 
  1582 
  1581                 |value c|
  1583                 |value c|
  1582 
  1584 
  1583                 (string isEmptyOrNil or:[string isBlank]) ifTrue:[
  1585                 (string isNil or:[string isBlank]) ifTrue:[
  1584                     value := nil
  1586                     value := nil
  1585                 ] ifFalse:[
  1587                 ] ifFalse:[
  1586                     value := Number readFromString:string onError:[nil]. 
  1588                     value := Number readFromString:string onError:[nil]. 
  1587                     value isNil ifTrue:[
  1589                     value isNil ifTrue:[
  1588                         
  1590                         
  1600                 self setNumberValue: value inModel: model fromInput: string.
  1602                 self setNumberValue: value inModel: model fromInput: string.
  1601                 ]
  1603                 ]
  1602 
  1604 
  1603         updateBlock: [:m :a :p | true]
  1605         updateBlock: [:m :a :p | true]
  1604 
  1606 
  1605     "Modified: 21.2.1997 / 18:59:44 / cg"
  1607     "Modified: / 21-02-1997 / 18:59:44 / cg"
       
  1608     "Modified: / 14-09-2018 / 10:08:59 / Stefan Vogel"
  1606 !
  1609 !
  1607 
  1610 
  1608 numberOrPointOrNil
  1611 numberOrPointOrNil
  1609     "setup the converter to convert from a string to a number or point
  1612     "setup the converter to convert from a string to a number or point
  1610      and vice versa. Invalid numbers/points are converted to nil."
  1613      and vice versa. Invalid numbers/points are converted to nil."
  1952         putBlock:
  1955         putBlock:
  1953                 [:model :string |
  1956                 [:model :string |
  1954 
  1957 
  1955                     |value c stream scaleChar scale partValue|
  1958                     |value c stream scaleChar scale partValue|
  1956 
  1959 
  1957                     (string isEmptyOrNil or:[string isBlank]) ifTrue:[
  1960                     (string isNil or:[string isBlank]) ifTrue:[
  1958                         value := nil
  1961                         value := nil
  1959                     ] ifFalse:[
  1962                     ] ifFalse:[
  1960                         value := 0.
  1963                         value := 0.
  1961                         stream := string readStream.
  1964                         stream := string readStream.
  1962                         [
  1965                         [
  1971                     ].
  1974                     ].
  1972                     self setNumberValue: value inModel: model fromInput: string.
  1975                     self setNumberValue: value inModel: model fromInput: string.
  1973                 ]
  1976                 ]
  1974 
  1977 
  1975         updateBlock: [:m :a :p | true]
  1978         updateBlock: [:m :a :p | true]
       
  1979 
       
  1980     "Modified: / 14-09-2018 / 10:09:09 / Stefan Vogel"
  1976 !
  1981 !
  1977 
  1982 
  1978 numberWithOptionalScales:scaleDict andThousandsSeparator:sep
  1983 numberWithOptionalScales:scaleDict andThousandsSeparator:sep
  1979     "setup the converter to convert from a string to a number with thousands separator
  1984     "setup the converter to convert from a string to a number with thousands separator
  1980      and vice versa. Allow for scale characters (such as k for thousand) "
  1985      and vice versa. Allow for scale characters (such as k for thousand) "