TypeConverter.st
author Claus Gittinger <cg@exept.de>
Wed, 29 Apr 2009 21:58:04 +0200
changeset 2623 cadc459b3c53
parent 2620 7bd45a3ea825
child 2737 0c83579be3d3
permissions -rw-r--r--
*** empty log message ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1355
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
     1
"
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
     2
 COPYRIGHT (c) 1997 eXept Software AG
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
     3
              All Rights Reserved
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
     4
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
     5
 This software is furnished under a license and may be used
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
     6
 only in accordance with the terms of that license and with the
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
     8
 be provided or otherwise made available to, or used by, any
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
     9
 other person.  No title to or ownership of the software is
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    10
 hereby transferred.
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    11
"
1406
7cd10ca1a425 smalltalkObject conversion fixed (allow nil)
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
    12
"{ Package: 'stx:libview2' }"
7cd10ca1a425 smalltalkObject conversion fixed (allow nil)
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
    13
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
PluggableAdaptor subclass:#TypeConverter
1426
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
    15
	instanceVariableNames:''
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
    16
	classVariableNames:''
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
    17
	poolDictionaries:''
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
    18
	category:'Interface-Support-Models'
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!TypeConverter class methodsFor:'documentation'!
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
1355
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    23
copyright
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    24
"
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    25
 COPYRIGHT (c) 1997 eXept Software AG
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    26
              All Rights Reserved
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    27
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    28
 This software is furnished under a license and may be used
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    29
 only in accordance with the terms of that license and with the
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    31
 be provided or otherwise made available to, or used by, any
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    32
 other person.  No title to or ownership of the software is
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    33
 hereby transferred.
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    34
"
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    35
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    36
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    37
!
55f97e2d97d2 copyrights
Claus Gittinger <cg@exept.de>
parents: 1335
diff changeset
    38
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
documentation
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
"
722
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
    41
    a typeConverter can be used as an editFields model
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
    42
    (remember, that an editField expects a string in its model),
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
    43
    to convert the fields string value to some object and vice versa.
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
    44
    Its main use is when building interfaces with inputFields,
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
    45
    where the datum to be entered is a non-string and you
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
    46
    want to have the entered value be converted automatically.
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
    47
    (and vice versa, to convert the datum to a string).
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
    48
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
    No real new functionality is added here - all is inherited
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
    from PluggableAdapter; however, some specialized instance creation
947
a5325410e4fd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 946
diff changeset
    51
    methods are added here.
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
    Notice: 
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
        this class was implemented using protocol information
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
        from alpha testers - it may not be complete or compatible to
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
        the corresponding ST-80 class. 
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
        If you encounter any incompatibilities, please forward a note 
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
        describing the incompatibility verbal (i.e. no code) to the ST/X team.
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
    [author:]
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
        Claus Gittinger
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
"
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
!
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
examples 
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
"
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
    convert a number to a string:
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
                                                                        [exBegin]
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
        |v t i|
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
        v := 1 asValue.
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
        t := HorizontalPanelView new.
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
        t extent:200@50.
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
        t horizontalLayout:#fitSpace.
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
        i := EditField in:t.
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
        i model:(TypeConverter onNumberValue:v).
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
        t open.
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
        (Delay forSeconds:3) wait.
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
        v value:2.
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
                                                                        [exEnd]
942
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
    86
    convert a number to a string with range:
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
    87
                                                                        [exBegin]
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
    88
        |v t i|
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
    89
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
    90
        v := 1 asValue.
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
    91
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
    92
        t := HorizontalPanelView new.
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
    93
        t extent:200@50.
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
    94
        t horizontalLayout:#fitSpace.
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
    95
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
    96
        i := EditField in:t.
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
    97
        i model:(TypeConverter onNumberValue:v minValue:0 maxValue:100).
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
    98
        t open.
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
    99
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
   100
        (Delay forSeconds:3) wait.
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
   101
        v value:2.
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
   102
                                                                        [exEnd]
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   103
    convert a date to a string:
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   104
                                                                        [exBegin]
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   105
        |d v|
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   106
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   107
        v := nil asValue.
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   108
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   109
        d := DialogBox new.
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   110
        d addInputFieldOn:(TypeConverter onDateValue:v).
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   111
        d addOkButton.
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   112
        d open.
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   113
        d accepted ifTrue:[
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   114
            Transcript showCR:v value
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   115
        ]
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   116
                                                                        [exEnd]
2379
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   117
    convert with thousands:
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   118
                                                                        [exBegin]
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   119
        |d v|
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   120
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   121
        v := 1234567 asValue.
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   122
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   123
        d := DialogBox new.
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   124
        d addInputFieldOn:((TypeConverter on:v) integerWithThousandsSeparator:$').
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   125
        d addOkButton.
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   126
        d open.
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   127
        d accepted ifTrue:[
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   128
            Transcript showCR:v value
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   129
        ]
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   130
                                                                        [exEnd]
2613
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   131
    convert with scale character:
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   132
                                                                        [exBegin]
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   133
        |d v|
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   134
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   135
        v := 1234567 asValue.
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   136
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   137
        d := DialogBox new.
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   138
        d addInputFieldOn:((TypeConverter on:v) numberWithOptionalScale).
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   139
        d addOkButton.
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   140
        d open.
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   141
        d accepted ifTrue:[
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   142
            Transcript showCR:v value
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   143
        ]
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   144
                                                                        [exEnd]
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   145
    convert with scale character and thousands separator:
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   146
                                                                        [exBegin]
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   147
        |d v scaleDict|
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   148
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   149
        scaleDict := Dictionary new.
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   150
        scaleDict at:$t put:1000.
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   151
        scaleDict at:$k put:1000.
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   152
        scaleDict at:$m put:1000000.
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   153
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   154
        v := 1234567 asValue.
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   155
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   156
        d := DialogBox new.
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   157
        d addInputFieldOn:((TypeConverter on:v) 
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   158
                            numberWithOptionalScales:scaleDict 
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   159
                            andThousandsSeparator:$').
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   160
        d addOkButton.
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   161
        d open.
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   162
        d accepted ifTrue:[
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   163
            Transcript showCR:v value
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   164
        ]
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   165
                                                                        [exEnd]
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
"
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
! !
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
!TypeConverter class methodsFor:'instance creation'!
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
486
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   171
onDateValue:aValueHolder
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   172
    "create and return a typeConverter, which retrieves
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   173
     a date via #value, and converts
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   174
     a date-string to a date via #value:.
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   175
     Useful as an editFields model, which operates on some
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   176
     date value (or aspectAdaptor, which adapts to a numeric slot)"
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   177
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   178
    ^ (self on:aValueHolder) dateToText
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   179
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   180
    "Modified: 21.2.1997 / 18:46:11 / cg"
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   181
    "Created: 4.3.1997 / 12:30:49 / cg"
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   182
!
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   183
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
onNumberValue:aValueHolder
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
    "create and return a typeConverter, which retrieves
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
     a values string representation via #value, and converts
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
     a number-string to a value via #value:.
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
     Useful as an editFields model, which operates on some
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
     numeric value (or aspectAdaptor, which adapts to a numeric slot)"
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
    ^ (self on:aValueHolder) numberToText
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
    "Modified: 21.2.1997 / 18:46:11 / cg"
446
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   194
!
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   195
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   196
onNumberValue:aValueHolder format:formatString
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   197
    "create and return a typeConverter, which retrieves
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   198
     a values string representation via #value, and converts
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   199
     a number-string to a value via #value:.
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   200
     Useful as an editFields model, which operates on some
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   201
     numeric value (or aspectAdaptor, which adapts to a numeric slot)"
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   202
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   203
    ^ (self on:aValueHolder) numberToTextFormattedBy:formatString
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   204
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   205
    "Created: 4.3.1997 / 11:51:25 / cg"
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   206
    "Modified: 4.3.1997 / 11:51:41 / cg"
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   207
!
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   208
1426
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   209
onNumberValue:aValueHolder leftPaddedTo:aSize with:aCharacter
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   210
    "create and return a typeConverter, which retrieves
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   211
     a values string representation via #value, and converts
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   212
     a number-string to a value via #value:.
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   213
     Useful as an editFields model, which operates on some
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   214
     numeric value (or aspectAdaptor, which adapts to a numeric slot)"
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   215
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   216
    ^ (self on:aValueHolder) numberToTextLeftPaddedTo:aSize with:aCharacter
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   217
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   218
"
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   219
  |m|
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   220
  m := 5 asValue.
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   221
  ((EditField model:(TypeConverter onNumberValue:m leftPaddedTo:2 with:$-)) width:100) openAt:(200@200).
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   222
  m inspect.
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   223
"
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   224
!
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   225
941
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   226
onNumberValue:aValueHolder minValue:min maxValue:max
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   227
    "create and return a typeConverter, which retrieves
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   228
     a values string representation via #value, and converts
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   229
     a number-string to a value via #value:.
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   230
     Useful as an editFields model, which operates on some
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   231
     numeric value (or aspectAdaptor, which adapts to a numeric slot)"
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   232
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   233
    ^ (self on:aValueHolder) numberToTextMinValue:min maxValue:max
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   234
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   235
    "Created: 4.3.1997 / 11:51:25 / cg"
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   236
    "Modified: 4.3.1997 / 11:51:41 / cg"
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   237
!
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   238
747
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   239
onNumberValue:aValueHolder postDecimalDigits:numPostDecimalDigits
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   240
    "create and return a typeConverter, which retrieves
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   241
     a values string representation via #value, and converts
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   242
     a number-string to a value via #value:.
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   243
     Useful as an editFields model, which operates on some
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   244
     numeric value (or aspectAdaptor, which adapts to a numeric slot)"
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   245
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   246
    ^ (self on:aValueHolder) numberToText:numPostDecimalDigits
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   247
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   248
    "Modified: / 21.2.1997 / 18:46:11 / cg"
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   249
    "Created: / 5.12.1997 / 02:55:18 / cg"
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   250
!
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   251
446
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   252
onSymbolValue:aValueHolder
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   253
    "create and return a typeConverter, which retrieves
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   254
     a symbol-values string representation via #value, and converts
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   255
     a string to a symbol via #value:.
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   256
     Useful as an editFields model, which operates on some
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   257
     numeric value (or aspectAdaptor, which adapts to a numeric slot)"
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   258
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   259
    ^ (self on:aValueHolder) symbolOrNil
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   260
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   261
    "Modified: 21.2.1997 / 18:46:11 / cg"
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   262
!
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   263
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   264
onTimeValue:aValueHolder
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   265
    "create and return a typeConverter, which retrieves
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   266
     a time via #value, and converts
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   267
     a time-string to a time via #value:.
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   268
     Useful as an editFields model, which operates on some
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   269
     date value (or aspectAdaptor, which adapts to a numeric slot)"
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   270
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   271
    ^ (self on:aValueHolder) timeToText
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   272
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   273
    "Modified: 21.2.1997 / 18:46:11 / cg"
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   274
    "Created: 4.3.1997 / 11:52:10 / cg"
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
! !
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
!TypeConverter methodsFor:'accessing'!
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
subject
2406
0f7d2545e089 #dateWithFormat: - allow string dates
Stefan Vogel <sv@exept.de>
parents: 2401
diff changeset
   280
    "return the subject to be converted"
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
    ^ model
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
!
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
value:newValue
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
    "convert and change"
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
    self setValue:newValue
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
    "Created: 21.2.1997 / 18:45:39 / cg"
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
! !
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
1001
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   293
!TypeConverter methodsFor:'input testing'!
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   294
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   295
setNumberValue: value inModel: model fromInput: string
1463
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   296
    "for invalid numbers, the model is set to nil. 
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   297
     By this, the dependents are forced to update their contents
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   298
     (that is: a bad input string will lead to a cleared input field here)."
1001
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   299
1463
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   300
    |lastInputChar needChange|
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   301
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   302
    string notEmpty ifTrue:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   303
        1 to: string size - 1 do: [:i| (string at: i) isLetter ifTrue: [needChange := true]].
1001
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   304
        lastInputChar := string at: string size.
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   305
        (lastInputChar isDigit not and: [lastInputChar isPrintable and: [
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   306
        (string size > 1               or: [lastInputChar ~~ $-])  and: [
1463
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   307
        (string occurrencesOf: $.) > 1 or: [lastInputChar ~~ $.]]]]) ifTrue: [needChange := true].
1001
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   308
    ].
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   309
1463
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   310
    needChange == true ifTrue:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   311
        value notNil ifTrue:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   312
            model setValue:nil
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   313
        ] ifFalse:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   314
            model value isNil ifTrue:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   315
                model changed:#value.
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   316
                ^ self
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   317
            ]
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   318
        ].
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   319
    ].
1001
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   320
    model value:value
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   321
! !
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   322
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   323
!TypeConverter methodsFor:'standard converters'!
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
1149
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   325
arrayLiteralOrStringOrSymbolOrNil
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   326
    "setup the converter to convert from a string to either a literal
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   327
     Array, a String or a symbol and vice versa. 
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   328
     Invalid strings (i.e. empty) are converted to nil;
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   329
     nil values are converted to an empty string.
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   330
     This is a very special converter (for the GUI builder) 
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   331
     - probably not belonging to here"
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   332
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   333
    self
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   334
        getBlock:[:model |
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   335
                |symbolValue|
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   336
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   337
                (symbolValue := model value) isNil ifTrue:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   338
                    String new
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   339
                ] ifFalse:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   340
                    symbolValue storeString
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   341
                ]]
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   342
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   343
        putBlock:
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   344
                [:model :string |
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   345
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   346
                |value s|
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   347
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
   348
                string isEmptyOrNil ifTrue:[
1149
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   349
                    value := nil
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   350
                ] ifFalse:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   351
                    s := string withoutSeparators.
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   352
                    (s startsWith:'#(') ifTrue:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   353
                        value := Array readFrom:s onError:nil
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   354
                    ] ifFalse:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   355
                        (s startsWith:'''') ifTrue:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   356
                            value := String readFrom:s onError:nil
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   357
                        ] ifFalse:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   358
                            (s startsWith:'#') ifTrue:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   359
                                s := s copyFrom:2
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   360
                            ].
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   361
                            value := s asSymbol
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   362
                        ]
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   363
                    ]
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   364
                ].
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   365
                model value:value]
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   366
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   367
        updateBlock: [:m :a :p | true]
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   368
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   369
    "Modified: / 26.10.1997 / 13:50:32 / cg"
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   370
    "Created: / 26.10.1997 / 14:01:02 / cg"
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   371
!
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   372
722
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   373
arrayLiteralOrSymbolOrNil
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   374
    "setup the converter to convert from a string to either a literal
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   375
     Array or a symbol and vice versa. 
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   376
     Invalid strings (i.e. empty) are converted to nil;
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   377
     nil values are converted to an empty string.
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   378
     This is a very special converter (for the GUI builder) 
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   379
     - probably not belonging to here"
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   380
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   381
    self
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   382
        getBlock:[:model |
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   383
                |symbolValue|
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   384
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   385
                (symbolValue := model value) isNil ifTrue:[
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   386
                    String new
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   387
                ] ifFalse:[
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   388
                    symbolValue isArray ifTrue:[
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   389
                        symbolValue storeString
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   390
                    ] ifFalse:[
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   391
                        '#' , symbolValue asString
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   392
                    ]
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   393
                ]]
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   394
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   395
        putBlock:
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   396
                [:model :string |
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   397
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   398
                |value s|
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   399
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
   400
                string isEmptyOrNil ifTrue:[
722
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   401
                    value := nil
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   402
                ] ifFalse:[
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   403
                    s := string withoutSeparators.
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   404
                    (s startsWith:'#(') ifTrue:[
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   405
                        value := Array readFrom:s onError:nil
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   406
                    ] ifFalse:[
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   407
                        (s startsWith:'#') ifTrue:[
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   408
                            s := s copyFrom:2
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   409
                        ].
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   410
                        value := s asSymbol
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   411
                    ]
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   412
                ].
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   413
                model value:value]
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   414
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   415
        updateBlock: [:m :a :p | true]
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   416
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   417
    "Modified: / 26.10.1997 / 13:50:32 / cg"
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   418
    "Created: / 26.10.1997 / 14:01:02 / cg"
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   419
!
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   420
2607
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   421
convertOldVWDateFormatSpecifierToNewSTXFormat:oldFormatSpec
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   422
    "private helper to convert an old (VW) format-Array
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   423
     of the form:
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   424
        'mm/dd/yyyy'      (VW-backward compatibility)
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   425
     into:
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   426
        '%m %d %y'        (new ST/X format)
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   427
    "
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   428
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   429
    |in out c nDigits|
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   430
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   431
    oldFormatSpec isArray ifTrue:[^ oldFormatSpec].
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   432
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   433
    out := '' writeStream.
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   434
    in := oldFormatSpec readStream.
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   435
    [in atEnd] whileFalse:[
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   436
        c := in next.
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   437
        nDigits := 1.
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   438
        c == $m ifTrue:[
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   439
            [in peek == $m] whileTrue:[ nDigits := nDigits + 1. in next ].
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   440
            nDigits == 1 ifTrue:[
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   441
                out nextPutAll:'%M'.    "/ unpadded
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   442
            ] ifFalse:[
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   443
                out nextPutAll:'%m'.
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   444
            ].
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   445
        ] ifFalse:[
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   446
            c == $d ifTrue:[
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   447
                [in peek == $d] whileTrue:[ nDigits := nDigits + 1. in next ].
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   448
                nDigits == 1 ifTrue:[
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   449
                    out nextPutAll:'%D'.    "/ unpadded
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   450
                ] ifFalse:[
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   451
                    out nextPutAll:'%d'.
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   452
                ].
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   453
            ] ifFalse:[
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   454
                c == $y ifTrue:[
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   455
                    [in peek == $y] whileTrue:[ nDigits := nDigits + 1. in next ].
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   456
                    nDigits == 2 ifTrue:[
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   457
                        out nextPutAll:'%Y'.    "/ 2 digits only
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   458
                    ] ifFalse:[
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   459
                        out nextPutAll:'%y'.
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   460
                    ].
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   461
                ] ifFalse:[
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   462
                    out nextPut:c.
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   463
                ].
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   464
            ].
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   465
        ].
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   466
    ].
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   467
    ^ out contents.
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   468
!
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   469
2401
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
   470
date
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
   471
    "setup the converter to convert from a string to a date
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
   472
     and vice versa. Nil is converted to todays date-string,
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
   473
     likewise, an empty string is converted back to todays date."
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
   474
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
   475
    ^ self dateWithFormat:nil orDefault:Date today
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
   476
!
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
   477
1047
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   478
dateDDMMYYYY
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   479
    "setup the converter to convert from a string to a date formatted by printFormat
2607
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   480
     DD-MM-YYYY; see also Date>>printFormat:
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   481
     This is a backward compatibility method for very old code to print european-style dates.
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   482
     Please use dateWithFormat: which is much more flexible."
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   483
1266
3420e3a98217 Fix output format of european date.
Stefan Vogel <sv@exept.de>
parents: 1265
diff changeset
   484
    self dateToTextFormattedBy: #(1 2 3 $- 1 1 true)
2607
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   485
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   486
    "
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   487
     |vh|
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   488
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   489
     vh := Date today asValue.
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   490
     TypeConverter new
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   491
        dateDDMMYYYY
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   492
            model:vh;
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   493
            value.    
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   494
     vh value       
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   495
    "
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   496
    "
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   497
     |vh|
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   498
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   499
     vh := Date today asValue.
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   500
     TypeConverter new
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   501
        dateDDMMYYYY
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   502
            model:vh;
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   503
            value:'12-01-2008'.    
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   504
     vh value       
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   505
    "
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   506
!
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   507
1047
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   508
dateMMDDYYYY
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   509
    "setup the converter to convert from a string to a date formatted by printFormat
2607
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   510
     MM/DD/YYYY; see also Date>>printFormat:
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   511
     This is a backward compatibility method for very old code to print us-style dates.
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   512
     Please use dateWithFormat: which is much more flexible."
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   513
1266
3420e3a98217 Fix output format of european date.
Stefan Vogel <sv@exept.de>
parents: 1265
diff changeset
   514
    self dateToTextFormattedBy: #(2 1 3 $/ 1 1 true)
2607
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   515
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   516
    "
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   517
     |vh|
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   518
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   519
     vh := Date today asValue.
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   520
     TypeConverter new
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   521
        dateMMDDYYYY
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   522
            model:vh;
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   523
            value.    
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   524
     vh value       
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   525
    "
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   526
    "
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   527
     |vh|
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   528
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   529
     vh := Date today asValue.
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   530
     TypeConverter new
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   531
        dateMMDDYYYY
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   532
            model:vh;
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   533
            value:'01/12/2008'.    
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   534
     vh value       
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   535
    "
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   536
!
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   537
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   538
dateOrNil
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   539
    "setup the converter to convert from a string to a date
722
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   540
     and vice versa. Invalid dates are converted to nil; likewise,
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   541
     a nil date is converted to an empty string."
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   542
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   543
    ^ self dateWithFormat:nil orDefault:nil
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   544
!
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   545
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   546
dateOrNilWithFormat:aFormatString
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   547
    "setup the converter to convert from a string to a date
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   548
     and vice versa. Invalid dates are converted to nil; likewise,
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   549
     a nil date is converted to an empty string.
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   550
     The format string must have one of the forms:
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   551
        'mm/dd/yyyy'      (for VW-backward compatibility)
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   552
     or:
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   553
        '%m %d %y'
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   554
    "
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   555
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   556
    ^ self dateWithFormat:aFormatString orDefault:nil
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   557
!
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   558
486
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   559
dateToText
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   560
    "setup the converter to convert from a string to a date
722
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   561
     and vice versa. Nil is converted to todays date-string,
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   562
     likewise, an empty string is converted back to todays date."
486
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   563
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   564
    ^ self dateWithFormat:nil orDefault:Date today
486
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   565
!
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   566
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   567
dateToTextFormattedBy: printFormat
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   568
    "setup the converter to convert from a string to a date formatted by printFormat
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   569
     and vice versa. Nil is converted to todays date-string,
1697
3111ef381ed1 *** empty log message ***
penk
parents: 1696
diff changeset
   570
     likewise, an empty string is converted back to todays date.
3111ef381ed1 *** empty log message ***
penk
parents: 1696
diff changeset
   571
     Uses the old, obsolete ST80 printFormat (see Date printFormat:)"
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   572
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   573
    ^ self dateWithFormat:printFormat orDefault:Date today
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   574
!
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   575
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   576
dateWithFormat:aFormatString
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   577
    "setup the converter to convert from a string to a date
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   578
     and vice versa. Invalid dates are converted to nil; likewise,
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   579
     a nil date is converted to an empty string.
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   580
     The format string must have one of the forms:
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   581
        'mm/dd/yyyy'      (for VW-backward compatibility)
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   582
     or:
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   583
        '%m %d %y'
2607
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   584
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   585
     see Date addPrintBindingsTo:language: for a format description.
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   586
    "
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   587
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   588
    ^ self dateWithFormat:aFormatString orDefault:Date today
2607
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   589
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   590
    "
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   591
     |vh|
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   592
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   593
     vh := Date today asValue.
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   594
     (TypeConverter new
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   595
        dateWithFormat:'%m%d%y')
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   596
            model:vh;
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   597
            value.    
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   598
     vh value       
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   599
    "
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   600
!
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   601
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   602
dateWithFormat:aFormatString orDefault:defaultValue
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   603
    "setup the converter to convert from a string to a date
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   604
     and vice versa. Invalid dates are converted to nil; likewise,
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   605
     a nil date is converted to an empty string.
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   606
     The format string must have one of the forms:
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   607
        'mm/dd/yyyy'      (for VW-backward compatibility)
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   608
     or:
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   609
        '%m %d %y'
2607
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   610
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   611
     see Date addPrintBindingsTo:language: for a format description.
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   612
    "
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   613
2607
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   614
    |stxFormat|
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   615
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   616
    aFormatString notNil ifTrue:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   617
        (aFormatString includes:$%) ifTrue:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   618
            "/ a new (ST/X) formatString
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   619
            stxFormat := aFormatString
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   620
        ] ifFalse:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   621
            "/ an old (VW) formatString
2607
2f81fde8732a comments and examples; old-style VW format fixed.
Claus Gittinger <cg@exept.de>
parents: 2560
diff changeset
   622
            stxFormat := self convertOldVWDateFormatSpecifierToNewSTXFormat:aFormatString
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   623
        ].
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   624
    ].
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   625
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   626
    self
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   627
        getBlock:[:model |
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   628
                |date|
1696
7dbac9fb8894 *** empty log message ***
penk
parents: 1695
diff changeset
   629
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   630
                (date := model value) isNil ifTrue:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   631
                    date := defaultValue
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   632
                ].
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   633
                date isNil ifTrue:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   634
                    ''
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   635
                ] ifFalse:[
2406
0f7d2545e089 #dateWithFormat: - allow string dates
Stefan Vogel <sv@exept.de>
parents: 2401
diff changeset
   636
                    (stxFormat isNil or:[date isString]) ifTrue:[
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   637
                        date printString
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   638
                    ] ifFalse:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   639
                        date printStringFormat:stxFormat
2406
0f7d2545e089 #dateWithFormat: - allow string dates
Stefan Vogel <sv@exept.de>
parents: 2401
diff changeset
   640
                    ].
0f7d2545e089 #dateWithFormat: - allow string dates
Stefan Vogel <sv@exept.de>
parents: 2401
diff changeset
   641
                ]]
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   642
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   643
        putBlock:
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   644
                [:model :string |
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   645
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   646
                |value|
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   647
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
   648
                string isEmptyOrNil ifTrue:[
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   649
                    value := defaultValue
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   650
                ] ifFalse:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   651
                    stxFormat isNil ifTrue:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   652
                        value := Date readFrom:string onError:defaultValue
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   653
                    ] ifFalse:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   654
                        value := Date readFrom:string printFormat:stxFormat onError:defaultValue
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   655
                    ]
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   656
                ].
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   657
                model value:value]
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   658
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   659
        updateBlock: [:m :a :p | true]
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   660
!
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   661
1791
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   662
fileSize
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   663
    "setup the converter to convert from a fileSize string to a number
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   664
     and vice versa.
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   665
     A fileSize can have a scale of 1024 (k or kB),
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   666
     1024*1024 (m or mB), 1024*1024*1024 (g or gB)."
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   667
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   668
    self
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   669
        getBlock:[:model |
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   670
                |numericValue|
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   671
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   672
                (numericValue := model value) isNumber ifFalse:[
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   673
                    String new
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   674
                ] ifTrue:[  
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   675
                    UnitConverter fileSizeStringFor:numericValue
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   676
                ]]
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   677
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   678
        putBlock:
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   679
                [:model :string |
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   680
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   681
                model value:(UnitConverter fileSizeFromString:string)]
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   682
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   683
        updateBlock: [:m :a :p | true]
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   684
!
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   685
1122
d8e73d8209d7 hexilein -> hexa
tm
parents: 1047
diff changeset
   686
hexadecimal
1047
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   687
    "setup the converter to convert from a hexadecimal string to a number
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   688
     and vice versa."
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   689
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   690
    self
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   691
        getBlock:[:model |
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   692
                |hexValue|
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   693
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   694
                (hexValue := model value) isNumber ifFalse:[
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   695
                    String new
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   696
                ] ifTrue:[  
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   697
                    hexValue hexPrintString
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   698
                ]]
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   699
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   700
        putBlock:
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   701
                [:model :string |
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   702
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   703
                |value|
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   704
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
   705
                string isEmptyOrNil ifTrue:[
1047
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   706
                    value := 0
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   707
                ] ifFalse:[     
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   708
                    value := Integer readFrom: string radix:16 onError:[0]
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   709
                ].
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   710
                model value:value]
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   711
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   712
        updateBlock: [:m :a :p | true]
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   713
!
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   714
2623
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   715
integer
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   716
    "setup the converter to convert from a string to an integer
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   717
     and vice versa. Invalid integers are converted to nil."
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   718
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   719
    self integerToText
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   720
!
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   721
2366
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   722
integerToHexTextMinValue:minVal maxValue:maxVal format:formatStringOrNil
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   723
    "setup the converter to convert from a string to a number
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   724
     and vice versa, but clamping the number into the range."
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   725
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   726
    ^ self integerToTextMinValue:minVal maxValue:maxVal radix:16 format:formatStringOrNil
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   727
!
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   728
2623
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   729
integerToText
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   730
    "setup the converter to convert from a string to a integer
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   731
     and vice versa."
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   732
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   733
    self
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   734
        getBlock:[:model |
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   735
                |numericValue|
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   736
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   737
                (numericValue := model value) isInteger ifFalse:[
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   738
                    String new
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   739
                ] ifTrue:[
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   740
                    numericValue printString
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   741
                ]]
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   742
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   743
        putBlock:
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   744
                [:model :string |
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   745
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   746
                |value|
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   747
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   748
                string isEmptyOrNil ifTrue:[
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   749
                    value := 0
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   750
                ] ifFalse:[
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   751
                    value := Integer readFromString: string onError:[0]
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   752
                ].
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   753
                model value:value]
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   754
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   755
        updateBlock: [:m :a :p | true]
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   756
!
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
   757
1974
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   758
integerToTextMinValue:minVal maxValue:maxVal format:formatStringOrNil
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   759
    "setup the converter to convert from a string to a number
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   760
     and vice versa, but clamping the number into the range."
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   761
2366
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   762
    ^ self integerToTextMinValue:minVal maxValue:maxVal radix:10 format:formatStringOrNil
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   763
!
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   764
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   765
integerToTextMinValue:minVal maxValue:maxVal radix:radix format:formatStringOrNil
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   766
    "setup the converter to convert from a string to a number
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   767
     and vice versa, but clamping the number into the range."
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   768
1974
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   769
    self
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   770
        getBlock:[:model |
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   771
                |numericValue|
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   772
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   773
                (numericValue := model value) isNil ifTrue:[
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   774
                    String new
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   775
                ] ifFalse:[
2379
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   776
                    numericValue isString ifTrue:[
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   777
                        numericValue    
1974
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   778
                    ] ifFalse:[
2379
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   779
                        formatStringOrNil isNil ifTrue:[    
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   780
                            numericValue printStringRadix:radix
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   781
                        ] ifFalse:[
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   782
                            numericValue printfPrintString:formatStringOrNil
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   783
                        ]
1974
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   784
                    ]
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   785
                ]]
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   786
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   787
        putBlock:
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   788
                [:model :string |
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   789
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   790
                |value c|
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   791
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
   792
                string isEmptyOrNil ifTrue:[
1974
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   793
                    value := 0
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   794
                ] ifFalse:[
2366
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   795
                    value := Integer readFromString:string radix:radix onError:[0]. 
1974
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   796
                ].               
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   797
                minVal notNil ifTrue:[
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   798
                    (value < minVal and: [string notEmpty]) ifTrue: [model setValue:nil].
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   799
                    value := value max:minVal.
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   800
                ].
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   801
                maxVal notNil ifTrue:[
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   802
                    (value > maxVal and: [string notEmpty]) ifTrue: [model setValue:nil].
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   803
                    value := value min:maxVal.
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   804
                ].
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   805
                self setNumberValue: value inModel: model fromInput: string.
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   806
                ]
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   807
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   808
        updateBlock: [:m :a :p | true]
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   809
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   810
    "Modified: 21.2.1997 / 18:59:44 / cg"
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   811
!
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   812
2379
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   813
integerWithThousandsSeparator    
2613
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   814
    ^ self numberWithThousandsSeparator
2379
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   815
!
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   816
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   817
integerWithThousandsSeparator:sep
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   818
    "setup the converter to convert from a string to a number with thousands separator
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   819
     and vice versa."
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   820
2613
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
   821
    ^ self numberWithThousandsSeparator:sep
2379
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   822
!
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   823
1464
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   824
literal
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   825
    "setup the converter to convert from a string to a literal
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   826
     and vice versa. Invalid symbols (i.e. empty) are converted to nil;
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   827
     nil values are converted to an empty string.
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   828
     true, false, Numbers are parsed"
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   829
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   830
    self
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   831
        getBlock:[:model |
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   832
                |val s|
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   833
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   834
                val := model value.
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   835
                (val isLiteral and:[val notNil]) ifTrue:[
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   836
                    val isSymbol ifTrue:[
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   837
                        "print 'special' symbols as symbols i.e. as #'symbol'"
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   838
                        (s := val storeString) second == $' ifTrue:[
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   839
                            s
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   840
                        ] ifFalse:[
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   841
                            val printString
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   842
                        ]
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   843
                    ] ifFalse:[
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   844
                        val storeString
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   845
                    ].
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   846
                ] ifFalse:[
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   847
                    ''.
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   848
                ]]
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   849
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   850
        putBlock:
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   851
                [:model :string |
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   852
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   853
                |value s|
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   854
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   855
                string size == 0 ifTrue:[
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   856
                    value := nil
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   857
                ] ifFalse:[
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   858
                    s := string withoutSeparators.
1465
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   859
                    "be careful, #readFrom:onError: returns nil for an undefined identifier"
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   860
                    s = 'true' ifTrue:[
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   861
                        value := true.
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   862
                    ] ifFalse:[s = 'false' ifTrue:[
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   863
                        value := false.
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   864
                    ] ifFalse:[s = 'nil' ifTrue:[
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   865
                        value := nil.
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   866
                    ] ifFalse:[s first isLetter ifTrue:[
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   867
                        value := s asSymbol.
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   868
                    ] ifFalse:[
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   869
                        value := Object readFrom:s onError:[
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   870
                            s asSymbol
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   871
                        ].
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   872
                    ]]]].
1464
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   873
                ].
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   874
                model value:value]
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   875
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   876
        updateBlock: [:m :a :p | true]
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   877
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   878
    "Created: / 21.2.1997 / 18:58:38 / cg"
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   879
    "Modified: / 26.5.1998 / 15:06:06 / cg"
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   880
!
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   881
508
64ee54ff8a77 added #number
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   882
number
64ee54ff8a77 added #number
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   883
    "setup the converter to convert from a string to a number
64ee54ff8a77 added #number
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   884
     and vice versa. Invalid numbers are converted to nil."
64ee54ff8a77 added #number
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   885
64ee54ff8a77 added #number
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   886
    self numberToText
64ee54ff8a77 added #number
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   887
64ee54ff8a77 added #number
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   888
    "Created: 4.4.1997 / 12:46:14 / cg"
64ee54ff8a77 added #number
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   889
!
64ee54ff8a77 added #number
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   890
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   891
numberOrNil
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   892
    "setup the converter to convert from a string to a number
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   893
     and vice versa. Invalid numbers are converted to nil."
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   894
2372
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
   895
    self objectOrNilOfType:Number
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   896
2372
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
   897
    "Modified: / 12-01-2008 / 19:08:42 / cg"
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   898
!
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   899
1463
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   900
numberOrNilToTextMinValue:minVal maxValue:maxVal
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   901
    "setup the converter to convert from a string to a number or nil
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   902
     and vice versa, but clamping the number into the range."
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   903
1974
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   904
    self numberOrNilToTextMinValue:minVal maxValue:maxVal format:nil
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   905
!
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   906
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   907
numberOrNilToTextMinValue:minVal maxValue:maxVal format:formatStringOrNil
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   908
    "setup the converter to convert from a string to a number or nil
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   909
     and vice versa, but clamping the number into the range."
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   910
1463
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   911
    self
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   912
        getBlock:[:model |
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   913
                |numericValue|
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   914
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   915
                (numericValue := model value) isNil ifTrue:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   916
                    String new
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   917
                ] ifFalse:[
1974
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   918
                    formatStringOrNil isNil ifTrue:[    
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   919
                        numericValue printString
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   920
                    ] ifFalse:[
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   921
                        numericValue printfPrintString:formatStringOrNil
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   922
                    ]
1463
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   923
                ]]
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   924
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   925
        putBlock:
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   926
                [:model :string |
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   927
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   928
                |value c|
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   929
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
   930
                (string isEmptyOrNil or:[string isBlank]) ifTrue:[
1463
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   931
                    value := nil
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   932
                ] ifFalse:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   933
                    value := Number readFromString:string onError:[nil]. 
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   934
                    value isNil ifTrue:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   935
                        
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   936
                    ] ifFalse:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   937
                        minVal notNil ifTrue:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   938
                            (value < minVal and: [string notEmpty]) ifTrue: [model setValue:nil].
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   939
                            value := value max:minVal.
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   940
                        ].
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   941
                        maxVal notNil ifTrue:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   942
                            (value > maxVal and: [string notEmpty]) ifTrue: [model setValue:nil].
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   943
                            value := value min:maxVal.
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   944
                        ].
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   945
                    ].
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   946
                ].
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   947
                self setNumberValue: value inModel: model fromInput: string.
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   948
                ]
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   949
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   950
        updateBlock: [:m :a :p | true]
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   951
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   952
    "Modified: 21.2.1997 / 18:59:44 / cg"
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   953
!
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   954
1335
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   955
numberOrPointOrNil
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   956
    "setup the converter to convert from a string to a number or point
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   957
     and vice versa. Invalid numbers/points are converted to nil."
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   958
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   959
    self
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   960
        getBlock:[:model |
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   961
                |value|
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   962
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   963
                (value := model value) isNil ifTrue:[
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   964
                    String new
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   965
                ] ifFalse:[
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   966
                    value printString
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   967
                ]]
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   968
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   969
        putBlock:
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   970
                [:model :string |
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   971
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   972
                |value|
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   973
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   974
                string size > 0 ifTrue:[
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   975
                    value := Point readFrom:string onError:[
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   976
                        Number readFrom:string onError:nil
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   977
                    ]
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   978
                ]. 
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   979
                model value:value]
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   980
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   981
        updateBlock: [:m :a :p | true]
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   982
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   983
    "Created: / 5.2.2000 / 01:26:48 / cg"
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   984
!
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   985
1149
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   986
numberOrStringOrSymbolOrNil
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   987
    "setup the converter to convert from a string to either a numeric literal
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   988
     or a symbol and vice versa. 
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   989
     Invalid strings (i.e. empty) are converted to nil;
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   990
     nil values are converted to an empty string.
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   991
     This is a very special converter (for the GUI builder) 
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   992
     - probably not belonging to here"
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   993
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   994
    self
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   995
        getBlock:[:model |
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   996
                |litValue|
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   997
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   998
                (litValue := model value) isNil ifTrue:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   999
                    String new
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1000
                ] ifFalse:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1001
                    litValue storeString
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1002
                ]]
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1003
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1004
        putBlock:
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1005
                [:model :string |
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1006
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1007
                |value s|
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1008
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
  1009
                string isEmptyOrNil ifTrue:[
1149
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1010
                    value := nil
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1011
                ] ifFalse:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1012
                    value := Number readFrom:string onError:nil.
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1013
                    value isNil ifTrue:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1014
                        s := string withoutSeparators.
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1015
                        (s startsWith:'''') ifTrue:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1016
                            value := String readFrom:s readStream onError:nil
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1017
                        ] ifFalse:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1018
                            (s startsWith:'#') ifTrue:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1019
                                s := s copyFrom:2.
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1020
                                (s startsWith:$') ifTrue:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1021
                                    s := s copyFrom:2 to:(s size - 1)
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1022
                                ].
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1023
                            ].
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1024
                            value := s asSymbol
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1025
                        ]
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1026
                    ]
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1027
                ].
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1028
                model value:value]
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1029
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1030
        updateBlock: [:m :a :p | true]
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1031
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1032
    "Modified: / 26.10.1997 / 13:50:32 / cg"
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1033
    "Created: / 29.10.1997 / 15:49:26 / cg"
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1034
!
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
  1035
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1036
numberOrSymbolOrNil
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1037
    "setup the converter to convert from a string to either a numeric literal
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1038
     or a symbol and vice versa. 
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1039
     Invalid strings (i.e. empty) are converted to nil;
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1040
     nil values are converted to an empty string.
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1041
     This is a very special converter (for the GUI builder) 
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1042
     - probably not belonging to here"
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1043
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1044
    self
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1045
        getBlock:[:model |
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1046
                |litValue|
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1047
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1048
                (litValue := model value) isNil ifTrue:[
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1049
                    String new
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1050
                ] ifFalse:[
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1051
                    litValue storeString
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1052
                ]]
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1053
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1054
        putBlock:
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1055
                [:model :string |
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1056
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1057
                |value s|
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1058
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
  1059
                string isEmptyOrNil ifTrue:[
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1060
                    value := nil
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1061
                ] ifFalse:[
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1062
                    value := Number readFrom:string onError:nil.
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1063
                    value isNil ifTrue:[
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1064
                        s := string withoutSeparators.
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1065
                        (s startsWith:'#') ifTrue:[
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1066
                            s := s copyFrom:2.
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1067
                            (s startsWith:$') ifTrue:[
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1068
                                s := s copyFrom:2 to:(s size - 1)
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1069
                            ].
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1070
                        ].
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1071
                        value := s asSymbol
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1072
                    ]
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1073
                ].
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1074
                model value:value]
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1075
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1076
        updateBlock: [:m :a :p | true]
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1077
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1078
    "Modified: / 26.10.1997 / 13:50:32 / cg"
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1079
    "Created: / 29.10.1997 / 15:49:26 / cg"
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1080
!
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1081
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1082
numberToText
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1083
    "setup the converter to convert from a string to a number
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1084
     and vice versa."
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1085
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1086
    self
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1087
        getBlock:[:model |
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1088
                |numericValue|
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1089
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1090
                (numericValue := model value) isNumber ifFalse:[
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1091
                    String new
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1092
                ] ifTrue:[
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1093
                    numericValue printString
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1094
                ]]
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1095
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1096
        putBlock:
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1097
                [:model :string |
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1098
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1099
                |value|
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1100
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
  1101
                string isEmptyOrNil ifTrue:[
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1102
                    value := 0
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1103
                ] ifFalse:[
1000
70e95e4dca22 use #readFromString:onError: for string->number convertations
tz
parents: 997
diff changeset
  1104
                    value := Number readFromString: string onError:[0]
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1105
                ].
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1106
                model value:value]
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1107
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1108
        updateBlock: [:m :a :p | true]
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1109
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1110
    "Created: / 21.2.1997 / 18:57:05 / cg"
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1111
    "Modified: / 29.10.1997 / 15:49:21 / cg"
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1112
!
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1113
747
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1114
numberToText:numberOfPostDecimals
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1115
    "setup the converter to convert from a string to a number
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1116
     and vice versa."
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1117
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1118
    self
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1119
        getBlock:[:model |
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1120
                |numericValue|
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1121
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1122
                (numericValue := model value) isNumber ifFalse:[
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1123
                    String new
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1124
                ] ifTrue:[
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1125
                    (numericValue asFixedPoint:numberOfPostDecimals) printString
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1126
                ]]
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1127
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1128
        putBlock:
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1129
                [:model :string |
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1130
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1131
                |value|
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1132
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
  1133
                string isEmptyOrNil ifTrue:[
747
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1134
                    value := 0
1000
70e95e4dca22 use #readFromString:onError: for string->number convertations
tz
parents: 997
diff changeset
  1135
                ] ifFalse:[     
70e95e4dca22 use #readFromString:onError: for string->number convertations
tz
parents: 997
diff changeset
  1136
                    value := Number readFromString:string onError:[0]
747
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1137
                ].
1001
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
  1138
                self setNumberValue: value inModel: model fromInput: string.
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
  1139
                ]
747
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1140
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1141
        updateBlock: [:m :a :p | true]
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1142
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1143
    "Created: / 5.12.1997 / 02:54:13 / cg"
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1144
    "Modified: / 5.12.1997 / 18:21:04 / cg"
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1145
!
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1146
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1147
numberToTextFormattedBy:formatString
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1148
    "setup the converter to convert from a string to a number
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1149
     and vice versa, using formatString.
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1150
     The formatString is currently ignored when numbers are converted
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1151
     from a string."
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1152
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1153
    self
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1154
        getBlock:[:model |
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1155
                |numericValue|
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1156
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1157
                (numericValue := model value) isNil ifTrue:[
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1158
                    String new
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1159
                ] ifFalse:[
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1160
                    PrintConverter print:numericValue formattedBy:formatString
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1161
                ]]
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1162
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1163
        putBlock:
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1164
                [:model :string |
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1165
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1166
                |value|
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1167
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
  1168
                string isEmptyOrNil ifTrue:[
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1169
                    value := 0
1000
70e95e4dca22 use #readFromString:onError: for string->number convertations
tz
parents: 997
diff changeset
  1170
                ] ifFalse:[          
70e95e4dca22 use #readFromString:onError: for string->number convertations
tz
parents: 997
diff changeset
  1171
                    value := Number readFromString: string onError:[0]. "asNumberFromFormatString:formatString"
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1172
                ].
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1173
                model value:value]
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1174
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1175
        updateBlock: [:m :a :p | true]
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1176
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1177
    "Modified: 21.2.1997 / 18:59:44 / cg"
446
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1178
!
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1179
1426
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1180
numberToTextLeftPaddedTo:aSize with:aCharacter
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1181
    "setup the converter to convert from a string to a number
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1182
     and vice versa, using formatString.
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1183
     The formatString is currently ignored when numbers are converted
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1184
     from a string."
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1185
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1186
    self
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1187
        getBlock:[:model |
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1188
                |numericValue|
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1189
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1190
                (numericValue := model value) isNil ifTrue:[
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1191
                    String new
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1192
                ] ifFalse:[
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1193
                    numericValue printStringLeftPaddedTo:aSize with:aCharacter
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1194
                ]]
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1195
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1196
        putBlock:
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1197
                [:model :string |
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1198
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1199
                |value|
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1200
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
  1201
                string isEmptyOrNil ifTrue:[
1426
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1202
                    value := 0
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1203
                ] ifFalse:[          
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1204
                    value := Number readFromString: string onError:[0]. "asNumberFromFormatString:formatString"
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1205
                ].
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1206
                model value:value]
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1207
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1208
        updateBlock: [:m :a :p | true]
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1209
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1210
    "Modified: 21.2.1997 / 18:59:44 / cg"
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1211
!
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1212
941
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1213
numberToTextMinValue:minVal maxValue:maxVal
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1214
    "setup the converter to convert from a string to a number
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1215
     and vice versa, but clamping the number into the range."
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1216
1974
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1217
    self numberToTextMinValue:minVal maxValue:maxVal format:nil
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1218
!
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1219
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1220
numberToTextMinValue:minVal maxValue:maxVal format:formatStringOrNil
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1221
    "setup the converter to convert from a string to a number
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1222
     and vice versa, but clamping the number into the range."
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1223
941
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1224
    self
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1225
        getBlock:[:model |
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1226
                |numericValue|
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1227
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1228
                (numericValue := model value) isNil ifTrue:[
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1229
                    String new
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1230
                ] ifFalse:[
1974
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1231
                    formatStringOrNil isNil ifTrue:[    
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1232
                        numericValue printString
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1233
                    ] ifFalse:[
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1234
                        numericValue printfPrintString:formatStringOrNil
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1235
                    ]
941
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1236
                ]]
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1237
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1238
        putBlock:
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1239
                [:model :string |
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1240
1001
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
  1241
                |value c|
941
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1242
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
  1243
                string isEmptyOrNil ifTrue:[
941
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1244
                    value := 0
1001
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
  1245
                ] ifFalse:[
997
9871b863dc3a it does invoke a debugger for wrong inputs
tz
parents: 947
diff changeset
  1246
                    value := Number readFromString: string onError:[0]. 
1000
70e95e4dca22 use #readFromString:onError: for string->number convertations
tz
parents: 997
diff changeset
  1247
                ].               
942
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
  1248
                minVal notNil ifTrue:[
1001
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
  1249
                    (value < minVal and: [string notEmpty]) ifTrue: [model setValue:nil].
942
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
  1250
                    value := value max:minVal.
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
  1251
                ].
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
  1252
                maxVal notNil ifTrue:[
1001
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
  1253
                    (value > maxVal and: [string notEmpty]) ifTrue: [model setValue:nil].
944
4ef99f8da24f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 943
diff changeset
  1254
                    value := value min:maxVal.
1001
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
  1255
                ].
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
  1256
                self setNumberValue: value inModel: model fromInput: string.
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
  1257
                ]
941
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1258
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1259
        updateBlock: [:m :a :p | true]
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1260
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1261
    "Modified: 21.2.1997 / 18:59:44 / cg"
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1262
!
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1263
2613
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1264
numberWithOptionalScale
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1265
    "setup the converter to convert from a string to a number
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1266
     and vice versa. Invalid numbers are converted to nil.
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1267
     The number may be followed by one of m (for million) or
2620
7bd45a3ea825 Fix #numberWithOptionalScale to handle '1m2k55'
Stefan Vogel <sv@exept.de>
parents: 2613
diff changeset
  1268
     k (for thousand). E.g.: '1m2k55' "
2613
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1269
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1270
    |scaleDict|
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1271
2620
7bd45a3ea825 Fix #numberWithOptionalScale to handle '1m2k55'
Stefan Vogel <sv@exept.de>
parents: 2613
diff changeset
  1272
    scaleDict := Dictionary withKeysAndValues:#(
7bd45a3ea825 Fix #numberWithOptionalScale to handle '1m2k55'
Stefan Vogel <sv@exept.de>
parents: 2613
diff changeset
  1273
            $m 1000000
7bd45a3ea825 Fix #numberWithOptionalScale to handle '1m2k55'
Stefan Vogel <sv@exept.de>
parents: 2613
diff changeset
  1274
            $k    1000
7bd45a3ea825 Fix #numberWithOptionalScale to handle '1m2k55'
Stefan Vogel <sv@exept.de>
parents: 2613
diff changeset
  1275
            $t    1000
7bd45a3ea825 Fix #numberWithOptionalScale to handle '1m2k55'
Stefan Vogel <sv@exept.de>
parents: 2613
diff changeset
  1276
        ).
2613
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1277
    self numberWithOptionalScales:scaleDict
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1278
!
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1279
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1280
numberWithOptionalScales:scaleDict
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1281
    "setup the converter to convert from a string to a number or nil
2620
7bd45a3ea825 Fix #numberWithOptionalScale to handle '1m2k55'
Stefan Vogel <sv@exept.de>
parents: 2613
diff changeset
  1282
     and vice versa; allow for scale characters (such as k for thousand).
7bd45a3ea825 Fix #numberWithOptionalScale to handle '1m2k55'
Stefan Vogel <sv@exept.de>
parents: 2613
diff changeset
  1283
7bd45a3ea825 Fix #numberWithOptionalScale to handle '1m2k55'
Stefan Vogel <sv@exept.de>
parents: 2613
diff changeset
  1284
     E.g. '1m2k55' "
2613
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1285
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1286
    self
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1287
        getBlock:[:model |
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1288
                    |numericValue|
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1289
2620
7bd45a3ea825 Fix #numberWithOptionalScale to handle '1m2k55'
Stefan Vogel <sv@exept.de>
parents: 2613
diff changeset
  1290
                    numericValue := model value.
7bd45a3ea825 Fix #numberWithOptionalScale to handle '1m2k55'
Stefan Vogel <sv@exept.de>
parents: 2613
diff changeset
  1291
                    numericValue isEmptyOrNil ifTrue:[
7bd45a3ea825 Fix #numberWithOptionalScale to handle '1m2k55'
Stefan Vogel <sv@exept.de>
parents: 2613
diff changeset
  1292
                        ''
2613
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1293
                    ] ifFalse:[
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1294
                        numericValue printString
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1295
                    ]
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1296
                ]
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1297
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1298
        putBlock:
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1299
                [:model :string |
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1300
2620
7bd45a3ea825 Fix #numberWithOptionalScale to handle '1m2k55'
Stefan Vogel <sv@exept.de>
parents: 2613
diff changeset
  1301
                    |value c stream scaleChar scale partValue|
2613
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1302
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1303
                    (string isEmptyOrNil or:[string isBlank]) ifTrue:[
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1304
                        value := nil
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1305
                    ] ifFalse:[
2620
7bd45a3ea825 Fix #numberWithOptionalScale to handle '1m2k55'
Stefan Vogel <sv@exept.de>
parents: 2613
diff changeset
  1306
                        value := 0.
2613
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1307
                        stream := string readStream.
2620
7bd45a3ea825 Fix #numberWithOptionalScale to handle '1m2k55'
Stefan Vogel <sv@exept.de>
parents: 2613
diff changeset
  1308
                        [
7bd45a3ea825 Fix #numberWithOptionalScale to handle '1m2k55'
Stefan Vogel <sv@exept.de>
parents: 2613
diff changeset
  1309
                            partValue := Number readFrom:stream onError:[nil]. 
7bd45a3ea825 Fix #numberWithOptionalScale to handle '1m2k55'
Stefan Vogel <sv@exept.de>
parents: 2613
diff changeset
  1310
                            partValue notNil ifTrue:[
7bd45a3ea825 Fix #numberWithOptionalScale to handle '1m2k55'
Stefan Vogel <sv@exept.de>
parents: 2613
diff changeset
  1311
                                stream skipSeparators.
7bd45a3ea825 Fix #numberWithOptionalScale to handle '1m2k55'
Stefan Vogel <sv@exept.de>
parents: 2613
diff changeset
  1312
                                scaleChar := stream nextOrNil.
7bd45a3ea825 Fix #numberWithOptionalScale to handle '1m2k55'
Stefan Vogel <sv@exept.de>
parents: 2613
diff changeset
  1313
                                scale := scaleDict at:scaleChar ifAbsent:1.
7bd45a3ea825 Fix #numberWithOptionalScale to handle '1m2k55'
Stefan Vogel <sv@exept.de>
parents: 2613
diff changeset
  1314
                                value := value + (partValue * scale).
7bd45a3ea825 Fix #numberWithOptionalScale to handle '1m2k55'
Stefan Vogel <sv@exept.de>
parents: 2613
diff changeset
  1315
                            ].
7bd45a3ea825 Fix #numberWithOptionalScale to handle '1m2k55'
Stefan Vogel <sv@exept.de>
parents: 2613
diff changeset
  1316
                        ] doWhile:[partValue notNil].
2613
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1317
                    ].
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1318
                    self setNumberValue: value inModel: model fromInput: string.
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1319
                ]
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1320
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1321
        updateBlock: [:m :a :p | true]
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1322
!
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1323
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1324
numberWithOptionalScales:scaleDict andThousandsSeparator:sep
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1325
    "setup the converter to convert from a string to a number with thousands separator
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1326
     and vice versa. Allow for scale characters (such as k for thousand) "
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1327
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1328
    self
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1329
        getBlock:[:model |
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1330
                    |numericValue|
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1331
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1332
                    (numericValue := model value) isNumber ifFalse:[
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1333
                        String new
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1334
                    ] ifTrue:[
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1335
                        String streamContents:[:s | numericValue printOn:s thousandsSeparator:sep].
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1336
                    ]
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1337
                ]
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1338
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1339
        putBlock:
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1340
                [:model :string |
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1341
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1342
                    |value c stream scaleChar scale s2|
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1343
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1344
                    string isEmptyOrNil ifTrue:[
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1345
                        value := 0
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1346
                    ] ifFalse:[
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1347
                        s2 := string reject:[:ch | ch = sep].    
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1348
                        stream := s2 readStream.
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1349
                        value := Number readFrom:stream onError:[nil]. 
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1350
                        value notNil ifTrue:[
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1351
                            stream skipSeparators.
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1352
                            scaleChar := stream peek.
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1353
                            scale := scaleDict at:scaleChar ifAbsent:1.
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1354
                            value := value * scale.
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1355
                        ].
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1356
                    ].
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1357
                    "/ model value:value
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1358
                    self setNumberValue: value inModel: model fromInput: string.
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1359
                ]
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1360
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1361
        updateBlock: [:m :a :p | true]
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1362
!
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1363
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1364
numberWithThousandsSeparator    
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1365
    ^ self numberWithThousandsSeparator:$'
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1366
"/     ^ self numberWithThousandsSeparator:(UserPreferences current thousandsSeparatorCharacter)
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1367
!
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1368
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1369
numberWithThousandsSeparator:sep
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1370
    "setup the converter to convert from a string to a number with thousands separator
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1371
     and vice versa."
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1372
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1373
    self
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1374
        getBlock:[:model |
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1375
                |numericValue|
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1376
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1377
                (numericValue := model value) isNumber ifFalse:[
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1378
                    String new
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1379
                ] ifTrue:[
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1380
                    String streamContents:[:s | numericValue printOn:s thousandsSeparator:sep].
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1381
                ]]
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1382
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1383
        putBlock:
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1384
                [:model :string |
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1385
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1386
                |value s2|
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1387
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1388
                string isEmptyOrNil ifTrue:[
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1389
                    value := 0
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1390
                ] ifFalse:[
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1391
                    s2 := string reject:[:ch | ch = sep].    
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1392
                    value := Number readFromString:s2 onError:[0]
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1393
                ].
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1394
                model value:value]
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1395
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1396
        updateBlock: [:m :a :p | true]
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1397
!
4c6bedf19f55 new typeConverter: numberWithOptionalScale
Claus Gittinger <cg@exept.de>
parents: 2607
diff changeset
  1398
2372
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1399
objectOrNilOfType:timeOrDateClass
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1400
    "common code for timeOrNil, dateOrNil and timeStampOrNil"
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1401
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1402
    self
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1403
        getBlock:[:model |
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1404
                |timeOrDate|
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1405
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1406
                (timeOrDate := model value) isNil ifTrue:[
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1407
                    ''
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1408
                ] ifFalse:[
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1409
                    timeOrDate printString
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1410
                ]]
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1411
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1412
        putBlock:
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1413
                [:model :string |
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1414
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1415
                |value|
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1416
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
  1417
                string isEmptyOrNil ifTrue:[
2372
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1418
                    value := nil
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1419
                ] ifFalse:[
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1420
                    value := timeOrDateClass readFrom:string onError:nil
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1421
                ].
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1422
                model value:value]
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1423
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1424
        updateBlock: [:m :a :p | true]
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1425
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1426
    "Created: / 12-01-2008 / 19:05:18 / cg"
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1427
!
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1428
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1429
smalltalkObject
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1430
    "setup the converter to convert from a string to any smalltalk object
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1431
     and vice versa. The string used is the objects storeString.
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1432
     Invalid strings (i.e. empty) are converted to nil.
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1433
     This is a very special converter (for the GUI builder) 
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1434
     - probably not belonging to here"
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1435
1786
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1436
    ^ self smalltalkObjectWithClass:Object
1407
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1437
!
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1438
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1439
smalltalkObjectOrNil
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1440
    "setup the converter to convert from a string to any smalltalk object
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1441
     and vice versa. The string used is the objects storeString.
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1442
     Invalid strings (i.e. empty) are converted to nil.
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1443
     This is a very special converter (for the GUI builder) 
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1444
     - probably not belonging to here"
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1445
1786
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1446
    ^ self smalltalkObjectOrNilWithClass:Object
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1447
!
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1448
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1449
smalltalkObjectOrNilWithClass:classOfObject
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1450
    "setup the converter to convert from a string to a smalltalk object
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1451
     and vice versa. The string used is the objects storeString.
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1452
     Invalid strings (i.e. empty) are converted to nil.
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1453
     This is a very special converter (for the GUI builder) 
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1454
     - probably not belonging to here"
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1455
1407
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1456
    self
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1457
        getBlock:[:model | |v s|
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1458
                     v := model value.
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1459
                     v isNil ifTrue:[
1406
7cd10ca1a425 smalltalkObject conversion fixed (allow nil)
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
  1460
                        s := 'nil'
1199
623c4cfe253d better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents: 1197
diff changeset
  1461
                     ] ifFalse:[
623c4cfe253d better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents: 1197
diff changeset
  1462
                            s := v storeString.
623c4cfe253d better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents: 1197
diff changeset
  1463
                            (v isString or:[v isNumber]) ifFalse:[
623c4cfe253d better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents: 1197
diff changeset
  1464
                                s := s , ' "' , v class name , '" '
623c4cfe253d better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents: 1197
diff changeset
  1465
                            ]
623c4cfe253d better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents: 1197
diff changeset
  1466
                     ].
623c4cfe253d better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents: 1197
diff changeset
  1467
                     s
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1468
                 ]
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1469
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1470
        putBlock:
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1471
                [:model :string |
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1472
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1473
                    |value|
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1474
1199
623c4cfe253d better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents: 1197
diff changeset
  1475
                    string size > 0 ifTrue:[
2199
4ec7c01ed26a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1974
diff changeset
  1476
                        value := classOfObject readFrom:string onError:nil.
4ec7c01ed26a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1974
diff changeset
  1477
                        value := value ? string.
1192
6db390e6463e default: String in SmalltalkObject
Claus Gittinger <cg@exept.de>
parents: 1149
diff changeset
  1478
                    ].
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1479
                    model value:value
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1480
                ]
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1481
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1482
        updateBlock: [:m :a :p | true]
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1483
2199
4ec7c01ed26a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1974
diff changeset
  1484
    "Created: / 29-10-1997 / 15:50:16 / cg"
4ec7c01ed26a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1974
diff changeset
  1485
    "Modified: / 05-09-2006 / 17:57:53 / cg"
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1486
!
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1487
1786
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1488
smalltalkObjectWithClass:classOfObject
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1489
    "setup the converter to convert from a string to a smalltalk object
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1490
     and vice versa. The string used is the objects storeString.
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1491
     Invalid strings (i.e. empty) are converted to nil.
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1492
     This is a very special converter (for the GUI builder) 
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1493
     - probably not belonging to here"
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1494
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1495
    self
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1496
        getBlock:[:model | |v s|
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1497
                     v := model value.
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1498
                     v isNil ifTrue:[
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1499
                        s := ''
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1500
                     ] ifFalse:[
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1501
                            s := v storeString.
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1502
                            (v isString or:[v isNumber]) ifFalse:[
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1503
                                s := s , ' "' , v class name , '" '
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1504
                            ]
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1505
                     ].
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1506
                     s
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1507
                 ]
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1508
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1509
        putBlock:
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1510
                [:model :string |
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1511
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1512
                    |value|
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1513
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1514
                    string size > 0 ifTrue:[
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1515
                        value := classOfObject readFrom:string onError:nil.
2199
4ec7c01ed26a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1974
diff changeset
  1516
                        model value:value ? string
1786
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1517
                    ].
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1518
                ]
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1519
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1520
        updateBlock: [:m :a :p | true]
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1521
2199
4ec7c01ed26a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1974
diff changeset
  1522
    "Created: / 29-10-1997 / 15:50:16 / cg"
4ec7c01ed26a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1974
diff changeset
  1523
    "Modified: / 05-09-2006 / 17:57:37 / cg"
1786
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1524
!
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1525
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1526
smalltalkPoint
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1527
    "setup the converter to convert from a string to a point object
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1528
     and vice versa. The string used is the points storeString.
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1529
     Invalid strings (i.e. empty) are converted to nil.
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1530
     This is a very special converter (for the GUI builder) 
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1531
     - probably not belonging to here"
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1532
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1533
    ^ self smalltalkObjectWithClass:Point
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1534
!
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1535
1653
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1536
symbolOrBooleanOrNil
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1537
    "setup the converter to convert from a string to a symbol or boolean
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1538
     and vice versa. Invalid symbols (i.e. empty) are converted to nil;
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1539
     nil values are converted to an empty string.
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1540
     In addition, the strings true/false convert to/from booleans."
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1541
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1542
    self
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1543
        getBlock:[:model |
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1544
                |symbolValue|
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1545
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1546
                ((symbolValue := model value) isSymbol 
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1547
                or:[symbolValue isBoolean]) 
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1548
                ifFalse:[
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1549
                    ''
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1550
                ] ifTrue:[
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1551
                    symbolValue printString. "/ storeString
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1552
                ]]
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1553
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1554
        putBlock:
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1555
                [:model :string |
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1556
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1557
                |value s|
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1558
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1559
                string size == 0 ifTrue:[
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1560
                    value := nil
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1561
                ] ifFalse:[
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1562
                    s := string withoutSeparators.
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1563
                    (s startsWith:'#') ifTrue:[
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1564
                        s := s copyFrom:2.
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1565
                        (s startsWith:$') ifTrue:[
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1566
                            s := s copyFrom:2 to:(s size - 1)
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1567
                        ].
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1568
                        value := s asSymbol
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1569
                    ] ifFalse:[
2440
83ae5c86ce7a fixed #symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  1570
                        (#('true' 'false') includes:s) ifTrue:[
1653
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1571
                            value := Object readFromString:s.
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1572
                        ] ifFalse:[
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1573
                            value := s asSymbol
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1574
                        ]
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1575
                    ].
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1576
                ].
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1577
                model value:value]
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1578
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1579
        updateBlock: [:m :a :p | true]
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1580
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1581
    "Created: / 21.2.1997 / 18:58:38 / cg"
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1582
    "Modified: / 26.5.1998 / 15:06:06 / cg"
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1583
!
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1584
446
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1585
symbolOrNil
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1586
    "setup the converter to convert from a string to a symbol
722
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
  1587
     and vice versa. Invalid symbols (i.e. empty) are converted to nil;
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
  1588
     nil values are converted to an empty string."
446
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1589
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1590
    self
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1591
        getBlock:[:model |
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1592
                |symbolValue|
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1593
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1594
                (symbolValue := model value) isSymbol ifFalse:[
446
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1595
                    String new
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1596
                ] ifTrue:[
946
94682a54c197 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 944
diff changeset
  1597
                    symbolValue printString. "/ storeString
446
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1598
                ]]
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1599
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1600
        putBlock:
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1601
                [:model :string |
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1602
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1603
                |value s|
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1604
1314
d81678f19c9d bug fix; test not for empty, test for size == 0
ca
parents: 1266
diff changeset
  1605
                string size == 0 ifTrue:[
446
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1606
                    value := nil
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1607
                ] ifFalse:[
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1608
                    s := string withoutSeparators.
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1609
                    (s startsWith:'#') ifTrue:[
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1610
                        s := s copyFrom:2.
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1611
                        (s startsWith:$') ifTrue:[
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1612
                            s := s copyFrom:2 to:(s size - 1)
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1613
                        ]
446
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1614
                    ].
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1615
                    value := s asSymbol
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1616
                ].
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1617
                model value:value]
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1618
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1619
        updateBlock: [:m :a :p | true]
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1620
722
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
  1621
    "Created: / 21.2.1997 / 18:58:38 / cg"
946
94682a54c197 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 944
diff changeset
  1622
    "Modified: / 26.5.1998 / 15:06:06 / cg"
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1623
!
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1624
2401
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1625
time
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1626
     ^ self time24H
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1627
!
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1628
1047
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
  1629
time12H
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1630
    "setup the converter to convert from a string to a time formatted by 12 hours
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1631
     and vice versa."
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1632
1027
eb4d24dd7e43 printStringXXHourFormat selectors changed
tz
parents: 1026
diff changeset
  1633
    self timeToTextFormattedBy: #printString12HourFormat
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1634
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1635
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1636
!
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1637
1047
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
  1638
time24H
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1639
    "setup the converter to convert from a string to a time formatted by 24 hours
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1640
     and vice versa."
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1641
1027
eb4d24dd7e43 printStringXXHourFormat selectors changed
tz
parents: 1026
diff changeset
  1642
    self timeToTextFormattedBy: #printString24HourFormat
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1643
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1644
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1645
!
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1646
2401
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1647
timeOfClass:timeClass withFormat:aFormatString orDefault:defaultValue
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1648
    "setup the converter to convert from a string to a time
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1649
     and vice versa. TimeClass is the class that should be used (e.g. Time or Timestamp). 
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1650
     Invalid times are converted to defaultValue; likewise,
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1651
     a nil time is converted to an empty string."
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1652
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1653
    self
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1654
        getBlock:[:model |
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1655
                |time|
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1656
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1657
                (time := model value) isNil ifTrue:[
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1658
                    time := defaultValue
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1659
                ].
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1660
                time isNil ifTrue:[
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1661
                    ''
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1662
                ] ifFalse:[
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1663
                    aFormatString isNil ifTrue:[
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1664
                        time printString
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1665
                    ] ifFalse:[
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1666
                        time printStringFormat:aFormatString
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1667
                ]]]
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1668
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1669
        putBlock:
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1670
                [:model :string |
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1671
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1672
                |value|
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1673
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
  1674
                string isEmptyOrNil ifTrue:[
2401
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1675
                    value := defaultValue
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1676
                ] ifFalse:[
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1677
"/                    aFormatString isNil ifTrue:[
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1678
                        value := timeClass readFrom:string onError:defaultValue
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1679
"/                    ] ifFalse:[
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1680
"/                        value := timeClass readFrom:string printFormat:aFormatString onError:defaultValue
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1681
"/                    ]
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1682
                ].
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1683
                model value:value]
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1684
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1685
        updateBlock: [:m :a :p | true]
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1686
!
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1687
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1688
timeOrNil
2372
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1689
    "setup the converter to convert from a string to a time and vice versa."
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1690
2372
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1691
    self objectOrNilOfType:Time
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1692
2372
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1693
    "Created: / 04-03-1997 / 11:52:47 / cg"
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1694
    "Modified: / 12-01-2008 / 19:06:21 / cg"
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1695
!
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1696
2372
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1697
timeStampOrNil
2401
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1698
    <resource: #obsolete>
2372
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1699
    "setup the converter to convert from a string to a timeStamp and vice versa."
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1700
2401
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1701
    self timestampOrNil
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1702
!
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1703
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1704
timeToText
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1705
    "setup the converter to convert from a string to a time
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1706
     and vice versa."
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1707
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1708
    self timeToTextFormattedBy: #printString
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1709
!
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1710
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1711
timeToTextFormattedBy: format
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1712
    "setup the converter to convert from a string to a time formatted by format
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1713
     and vice versa."
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1714
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1715
    self
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1716
        getBlock:[:model |
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1717
                |time|
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1718
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1719
                (time := model value) isNil ifTrue:[
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1720
                    Time now perform: format
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1721
                ] ifFalse:[
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1722
                    time perform: format
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1723
                ]]
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1724
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1725
        putBlock:
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1726
                [:model :string |
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1727
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1728
                |value|
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1729
2560
03c5e1535b9d isEmptyOrNil
sr
parents: 2559
diff changeset
  1730
                string isEmptyOrNil ifTrue:[
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1731
                    value := Time now
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1732
                ] ifFalse:[              
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1733
                    value := Time readFrom:string onError:[Time now]
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1734
                ].
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1735
                model value:value]
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1736
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1737
        updateBlock: [:m :a :p | true]
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1738
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1739
    "Modified: 21.2.1997 / 18:59:06 / cg"
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1740
    "Created: 4.3.1997 / 11:52:47 / cg"
2401
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1741
!
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1742
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1743
timestamp
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1744
    "setup the converter to convert from a string to a timestamp and vice versa."
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1745
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1746
    ^ self timeOfClass:Timestamp withFormat:nil orDefault:Timestamp now
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1747
!
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1748
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1749
timestampOrNil
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1750
    "setup the converter to convert from a string to a timestamp and vice versa."
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1751
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1752
    self objectOrNilOfType:Timestamp
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1753
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1754
    "Modified: / 12-01-2008 / 19:06:06 / cg"
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1755
! !
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1756
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1757
!TypeConverter class methodsFor:'documentation'!
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1758
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1759
version
2623
cadc459b3c53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2620
diff changeset
  1760
    ^ '$Header: /cvs/stx/stx/libview2/TypeConverter.st,v 1.61 2009-04-29 19:58:04 cg Exp $'
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1761
! !