TypeConverter.st
author Stefan Vogel <sv@exept.de>
Thu, 05 Jun 2008 11:21:41 +0200
changeset 2490 9bcc1b3fd7e0
parent 2440 83ae5c86ce7a
child 2559 87d81ccdf4a0
permissions -rw-r--r--
MIMEType>>#suffix
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]
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
"
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
! !
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
!TypeConverter class methodsFor:'instance creation'!
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
486
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   136
onDateValue:aValueHolder
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   137
    "create and return a typeConverter, which retrieves
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   138
     a date via #value, and converts
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   139
     a date-string to a date via #value:.
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   140
     Useful as an editFields model, which operates on some
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   141
     date value (or aspectAdaptor, which adapts to a numeric slot)"
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   142
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   143
    ^ (self on:aValueHolder) dateToText
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   144
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   145
    "Modified: 21.2.1997 / 18:46:11 / cg"
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   146
    "Created: 4.3.1997 / 12:30:49 / cg"
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   147
!
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   148
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
onNumberValue:aValueHolder
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
    "create and return a typeConverter, which retrieves
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
     a values string representation via #value, and converts
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
     a number-string to a value via #value:.
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
     Useful as an editFields model, which operates on some
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
     numeric value (or aspectAdaptor, which adapts to a numeric slot)"
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
    ^ (self on:aValueHolder) numberToText
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
    "Modified: 21.2.1997 / 18:46:11 / cg"
446
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   159
!
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   160
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   161
onNumberValue:aValueHolder format:formatString
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   162
    "create and return a typeConverter, which retrieves
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   163
     a values string representation via #value, and converts
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   164
     a number-string to a value via #value:.
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   165
     Useful as an editFields model, which operates on some
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   166
     numeric value (or aspectAdaptor, which adapts to a numeric slot)"
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   167
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   168
    ^ (self on:aValueHolder) numberToTextFormattedBy:formatString
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   169
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   170
    "Created: 4.3.1997 / 11:51:25 / cg"
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   171
    "Modified: 4.3.1997 / 11:51:41 / cg"
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   172
!
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   173
1426
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   174
onNumberValue:aValueHolder leftPaddedTo:aSize with:aCharacter
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   175
    "create and return a typeConverter, which retrieves
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   176
     a values string representation via #value, and converts
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   177
     a number-string to a value via #value:.
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   178
     Useful as an editFields model, which operates on some
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   179
     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
   180
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   181
    ^ (self on:aValueHolder) numberToTextLeftPaddedTo:aSize with:aCharacter
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   182
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   183
"
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   184
  |m|
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   185
  m := 5 asValue.
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   186
  ((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
   187
  m inspect.
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   188
"
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   189
!
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
   190
941
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   191
onNumberValue:aValueHolder minValue:min maxValue:max
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   192
    "create and return a typeConverter, which retrieves
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   193
     a values string representation via #value, and converts
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   194
     a number-string to a value via #value:.
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   195
     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
   196
     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
   197
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   198
    ^ (self on:aValueHolder) numberToTextMinValue:min maxValue:max
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   199
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   200
    "Created: 4.3.1997 / 11:51:25 / cg"
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   201
    "Modified: 4.3.1997 / 11:51:41 / cg"
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   202
!
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
   203
747
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   204
onNumberValue:aValueHolder postDecimalDigits:numPostDecimalDigits
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   205
    "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
   206
     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
   207
     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
   208
     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
   209
     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
   210
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   211
    ^ (self on:aValueHolder) numberToText:numPostDecimalDigits
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   212
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   213
    "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
   214
    "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
   215
!
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   216
446
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   217
onSymbolValue:aValueHolder
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   218
    "create and return a typeConverter, which retrieves
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   219
     a symbol-values string representation via #value, and converts
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   220
     a string to a symbol via #value:.
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   221
     Useful as an editFields model, which operates on some
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   222
     numeric value (or aspectAdaptor, which adapts to a numeric slot)"
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   223
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   224
    ^ (self on:aValueHolder) symbolOrNil
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   225
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
   226
    "Modified: 21.2.1997 / 18:46:11 / cg"
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   227
!
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   228
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   229
onTimeValue:aValueHolder
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   230
    "create and return a typeConverter, which retrieves
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   231
     a time via #value, and converts
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   232
     a time-string to a time via #value:.
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   233
     Useful as an editFields model, which operates on some
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   234
     date value (or aspectAdaptor, which adapts to a numeric slot)"
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   235
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   236
    ^ (self on:aValueHolder) timeToText
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   237
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   238
    "Modified: 21.2.1997 / 18:46:11 / cg"
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   239
    "Created: 4.3.1997 / 11:52:10 / cg"
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
! !
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
!TypeConverter methodsFor:'accessing'!
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
subject
2406
0f7d2545e089 #dateWithFormat: - allow string dates
Stefan Vogel <sv@exept.de>
parents: 2401
diff changeset
   245
    "return the subject to be converted"
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
    ^ model
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
!
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
value:newValue
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
    "convert and change"
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
    self setValue:newValue
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
    "Created: 21.2.1997 / 18:45:39 / cg"
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
! !
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
1001
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   258
!TypeConverter methodsFor:'input testing'!
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   259
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   260
setNumberValue: value inModel: model fromInput: string
1463
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   261
    "for invalid numbers, the model is set to nil. 
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   262
     By this, the dependents are forced to update their contents
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   263
     (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
   264
1463
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   265
    |lastInputChar needChange|
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   266
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   267
    string notEmpty ifTrue:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   268
        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
   269
        lastInputChar := string at: string size.
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   270
        (lastInputChar isDigit not and: [lastInputChar isPrintable and: [
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   271
        (string size > 1               or: [lastInputChar ~~ $-])  and: [
1463
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   272
        (string occurrencesOf: $.) > 1 or: [lastInputChar ~~ $.]]]]) ifTrue: [needChange := true].
1001
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   273
    ].
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   274
1463
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   275
    needChange == true ifTrue:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   276
        value notNil ifTrue:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   277
            model setValue:nil
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   278
        ] ifFalse:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   279
            model value isNil ifTrue:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   280
                model changed:#value.
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   281
                ^ self
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   282
            ]
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   283
        ].
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   284
    ].
1001
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   285
    model value:value
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   286
! !
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
   287
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   288
!TypeConverter methodsFor:'standard converters'!
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
1149
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   290
arrayLiteralOrStringOrSymbolOrNil
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   291
    "setup the converter to convert from a string to either a literal
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   292
     Array, a String or a symbol and vice versa. 
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   293
     Invalid strings (i.e. empty) are converted to nil;
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   294
     nil values are converted to an empty string.
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   295
     This is a very special converter (for the GUI builder) 
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   296
     - probably not belonging to here"
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   297
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   298
    self
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   299
        getBlock:[:model |
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   300
                |symbolValue|
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   301
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   302
                (symbolValue := model value) isNil ifTrue:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   303
                    String new
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   304
                ] ifFalse:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   305
                    symbolValue storeString
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   306
                ]]
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   307
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   308
        putBlock:
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   309
                [:model :string |
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   310
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   311
                |value s|
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   312
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   313
                string isEmpty ifTrue:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   314
                    value := nil
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   315
                ] ifFalse:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   316
                    s := string withoutSeparators.
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   317
                    (s startsWith:'#(') ifTrue:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   318
                        value := Array readFrom:s onError:nil
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   319
                    ] ifFalse:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   320
                        (s startsWith:'''') ifTrue:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   321
                            value := String readFrom:s onError:nil
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   322
                        ] ifFalse:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   323
                            (s startsWith:'#') ifTrue:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   324
                                s := s copyFrom:2
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   325
                            ].
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   326
                            value := s asSymbol
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   327
                        ]
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   328
                    ]
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   329
                ].
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   330
                model value:value]
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   331
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   332
        updateBlock: [:m :a :p | true]
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   333
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   334
    "Modified: / 26.10.1997 / 13:50:32 / cg"
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   335
    "Created: / 26.10.1997 / 14:01:02 / cg"
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
722
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   338
arrayLiteralOrSymbolOrNil
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   339
    "setup the converter to convert from a string to either a literal
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   340
     Array or a symbol and vice versa. 
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   341
     Invalid strings (i.e. empty) are converted to nil;
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   342
     nil values are converted to an empty string.
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   343
     This is a very special converter (for the GUI builder) 
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   344
     - probably not belonging to here"
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   345
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   346
    self
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   347
        getBlock:[:model |
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   348
                |symbolValue|
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   349
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   350
                (symbolValue := model value) isNil ifTrue:[
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   351
                    String new
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   352
                ] ifFalse:[
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   353
                    symbolValue isArray ifTrue:[
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   354
                        symbolValue storeString
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   355
                    ] ifFalse:[
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   356
                        '#' , symbolValue asString
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   357
                    ]
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   358
                ]]
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   359
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   360
        putBlock:
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   361
                [:model :string |
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   362
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   363
                |value s|
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   364
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   365
                string isEmpty ifTrue:[
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   366
                    value := nil
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   367
                ] ifFalse:[
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   368
                    s := string withoutSeparators.
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   369
                    (s startsWith:'#(') ifTrue:[
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   370
                        value := Array readFrom:s onError:nil
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   371
                    ] ifFalse:[
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   372
                        (s startsWith:'#') ifTrue:[
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   373
                            s := s copyFrom:2
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   374
                        ].
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   375
                        value := s asSymbol
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   376
                    ]
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   377
                ].
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   378
                model value:value]
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   379
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   380
        updateBlock: [:m :a :p | true]
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   381
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   382
    "Modified: / 26.10.1997 / 13:50:32 / cg"
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   383
    "Created: / 26.10.1997 / 14:01:02 / cg"
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
2401
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
   386
date
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
   387
    "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
   388
     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
   389
     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
   390
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
   391
    ^ self dateWithFormat:nil orDefault:Date today
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
   392
!
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
   393
1047
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   394
dateDDMMYYYY
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   395
    "setup the converter to convert from a string to a date formatted by printFormat
1266
3420e3a98217 Fix output format of european date.
Stefan Vogel <sv@exept.de>
parents: 1265
diff changeset
   396
     DD-MM-YYYY; see also Date>>printFormat:"
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   397
1266
3420e3a98217 Fix output format of european date.
Stefan Vogel <sv@exept.de>
parents: 1265
diff changeset
   398
    self dateToTextFormattedBy: #(1 2 3 $- 1 1 true)
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   399
!
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   400
1047
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   401
dateMMDDYYYY
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   402
    "setup the converter to convert from a string to a date formatted by printFormat
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   403
     MM:DD:YYYY; see also Date>>printFormat:"
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   404
1266
3420e3a98217 Fix output format of european date.
Stefan Vogel <sv@exept.de>
parents: 1265
diff changeset
   405
    self dateToTextFormattedBy: #(2 1 3 $/ 1 1 true)
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   406
!
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   407
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   408
dateOrNil
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   409
    "setup the converter to convert from a string to a date
722
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   410
     and vice versa. Invalid dates are converted to nil; likewise,
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   411
     a nil date is converted to an empty string."
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   412
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   413
    ^ self dateWithFormat:nil orDefault:nil
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   414
!
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   415
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   416
dateOrNilWithFormat:aFormatString
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   417
    "setup the converter to convert from a string to a date
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   418
     and vice versa. Invalid dates are converted to nil; likewise,
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   419
     a nil date is converted to an empty string.
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   420
     The format string must have one of the forms:
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   421
        'mm/dd/yyyy'      (for VW-backward compatibility)
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   422
     or:
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   423
        '%m %d %y'
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   424
    "
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   425
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   426
    ^ self dateWithFormat:aFormatString orDefault:nil
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   427
!
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
   428
486
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   429
dateToText
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   430
    "setup the converter to convert from a string to a date
722
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   431
     and vice versa. Nil is converted to todays date-string,
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   432
     likewise, an empty string is converted back to todays date."
486
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   433
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   434
    ^ self dateWithFormat:nil orDefault:Date today
486
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   435
!
f21ed8fd7df3 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 447
diff changeset
   436
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   437
dateToTextFormattedBy: printFormat
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   438
    "setup the converter to convert from a string to a date formatted by printFormat
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   439
     and vice versa. Nil is converted to todays date-string,
1697
3111ef381ed1 *** empty log message ***
penk
parents: 1696
diff changeset
   440
     likewise, an empty string is converted back to todays date.
3111ef381ed1 *** empty log message ***
penk
parents: 1696
diff changeset
   441
     Uses the old, obsolete ST80 printFormat (see Date printFormat:)"
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   442
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   443
    ^ self dateWithFormat:printFormat orDefault:Date today
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   444
!
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   445
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   446
dateWithFormat:aFormatString
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   447
    "setup the converter to convert from a string to a date
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   448
     and vice versa. Invalid dates are converted to nil; likewise,
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   449
     a nil date is converted to an empty string.
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   450
     The format string must have one of the forms:
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   451
        'mm/dd/yyyy'      (for VW-backward compatibility)
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   452
     or:
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   453
        '%m %d %y'
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   454
    "
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   455
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   456
    ^ self dateWithFormat:aFormatString orDefault:Date today
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   457
!
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   458
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   459
dateWithFormat:aFormatString orDefault:defaultValue
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   460
    "setup the converter to convert from a string to a date
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   461
     and vice versa. Invalid dates are converted to nil; likewise,
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   462
     a nil date is converted to an empty string.
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   463
     The format string must have one of the forms:
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   464
        'mm/dd/yyyy'      (for VW-backward compatibility)
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   465
     or:
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   466
        '%m %d %y'
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   467
    "
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   468
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   469
    |in out stxFormat c nDigits|
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   470
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   471
    aFormatString notNil ifTrue:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   472
        (aFormatString includes:$%) ifTrue:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   473
            "/ a new (ST/X) formatString
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   474
            stxFormat := aFormatString
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   475
        ] ifFalse:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   476
            "/ an old (VW) formatString
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   477
            out := '' writeStream.
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   478
            in := aFormatString readStream.
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   479
            [in atEnd] whileFalse:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   480
                c := in next.
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   481
                nDigits := 1.
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   482
                c == $m ifTrue:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   483
                    [in peek == $m] whileTrue:[ nDigits := nDigits + 1. in next ].
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   484
                    nDigits == 1 ifTrue:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   485
                        out nextPutAll:'%M'.    "/ unpadded
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   486
                    ] ifFalse:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   487
                        out nextPutAll:'%m'.
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   488
                    ].
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   489
                ] ifFalse:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   490
                    c == $d ifTrue:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   491
                        [in peek == $d] whileTrue:[ nDigits := nDigits + 1. in next ].
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   492
                        nDigits == 1 ifTrue:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   493
                            out nextPutAll:'%D'.    "/ unpadded
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   494
                        ] ifFalse:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   495
                            out nextPutAll:'%d'.
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   496
                        ].
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   497
                    ] ifFalse:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   498
                        c == $y ifTrue:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   499
                            [in peek == $y] whileTrue:[ nDigits := nDigits + 1. in next ].
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   500
                            nDigits == 2 ifTrue:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   501
                                out nextPutAll:'%Y'.    "/ 2 digits only
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   502
                            ] ifFalse:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   503
                                out nextPutAll:'%y'.
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   504
                            ].
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   505
                        ] ifFalse:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   506
                            out nextPut:c.
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   507
                        ].
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   508
                    ].
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   509
                ].
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   510
            ].
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   511
            stxFormat := out contents.
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   512
        ].
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   513
    ].
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   514
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   515
    self
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   516
        getBlock:[:model |
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   517
                |date|
1696
7dbac9fb8894 *** empty log message ***
penk
parents: 1695
diff changeset
   518
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   519
                (date := model value) isNil ifTrue:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   520
                    date := defaultValue
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   521
                ].
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   522
                date isNil ifTrue:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   523
                    ''
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   524
                ] ifFalse:[
2406
0f7d2545e089 #dateWithFormat: - allow string dates
Stefan Vogel <sv@exept.de>
parents: 2401
diff changeset
   525
                    (stxFormat isNil or:[date isString]) ifTrue:[
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   526
                        date printString
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   527
                    ] ifFalse:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   528
                        date printStringFormat:stxFormat
2406
0f7d2545e089 #dateWithFormat: - allow string dates
Stefan Vogel <sv@exept.de>
parents: 2401
diff changeset
   529
                    ].
0f7d2545e089 #dateWithFormat: - allow string dates
Stefan Vogel <sv@exept.de>
parents: 2401
diff changeset
   530
                ]]
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   531
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   532
        putBlock:
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   533
                [:model :string |
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   534
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   535
                |value|
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   536
1832
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   537
                string isEmpty ifTrue:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   538
                    value := defaultValue
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   539
                ] ifFalse:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   540
                    stxFormat isNil ifTrue:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   541
                        value := Date readFrom:string onError:defaultValue
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   542
                    ] ifFalse:[
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   543
                        value := Date readFrom:string printFormat:stxFormat onError:defaultValue
fb54a0eabe13 date conversion cleanup.
Claus Gittinger <cg@exept.de>
parents: 1791
diff changeset
   544
                    ]
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   545
                ].
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   546
                model value:value]
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   547
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   548
        updateBlock: [:m :a :p | true]
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   549
!
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
   550
1791
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   551
fileSize
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   552
    "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
   553
     and vice versa.
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   554
     A fileSize can have a scale of 1024 (k or kB),
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   555
     1024*1024 (m or mB), 1024*1024*1024 (g or gB)."
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   556
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   557
    self
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   558
        getBlock:[:model |
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   559
                |numericValue|
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   560
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   561
                (numericValue := model value) isNumber ifFalse:[
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   562
                    String new
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   563
                ] ifTrue:[  
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   564
                    UnitConverter fileSizeStringFor:numericValue
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   565
                ]]
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   566
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   567
        putBlock:
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   568
                [:model :string |
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   569
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   570
                model value:(UnitConverter fileSizeFromString:string)]
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   571
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   572
        updateBlock: [:m :a :p | true]
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   573
!
33b4fcbb69cf added fileSize converter
Claus Gittinger <cg@exept.de>
parents: 1787
diff changeset
   574
1122
d8e73d8209d7 hexilein -> hexa
tm
parents: 1047
diff changeset
   575
hexadecimal
1047
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   576
    "setup the converter to convert from a hexadecimal string to a number
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   577
     and vice versa."
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   578
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   579
    self
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   580
        getBlock:[:model |
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   581
                |hexValue|
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   582
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   583
                (hexValue := model value) isNumber ifFalse:[
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   584
                    String new
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   585
                ] ifTrue:[  
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   586
                    hexValue hexPrintString
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   587
                ]]
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   588
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   589
        putBlock:
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   590
                [:model :string |
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   591
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   592
                |value|
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   593
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   594
                string isEmpty ifTrue:[
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   595
                    value := 0
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   596
                ] ifFalse:[     
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   597
                    value := Integer readFrom: string radix:16 onError:[0]
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   598
                ].
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   599
                model value:value]
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   600
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   601
        updateBlock: [:m :a :p | true]
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   602
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   603
   
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   604
!
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
   605
2366
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   606
integerToHexTextMinValue:minVal maxValue:maxVal format:formatStringOrNil
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   607
    "setup the converter to convert from a string to a number
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   608
     and vice versa, but clamping the number into the range."
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   609
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   610
    ^ self integerToTextMinValue:minVal maxValue:maxVal radix:16 format:formatStringOrNil
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   611
!
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   612
1974
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   613
integerToTextMinValue:minVal maxValue:maxVal format:formatStringOrNil
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   614
    "setup the converter to convert from a string to a number
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   615
     and vice versa, but clamping the number into the range."
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   616
2366
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   617
    ^ self integerToTextMinValue:minVal maxValue:maxVal radix:10 format:formatStringOrNil
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   618
!
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   619
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   620
integerToTextMinValue:minVal maxValue:maxVal radix:radix format:formatStringOrNil
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   621
    "setup the converter to convert from a string to a number
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   622
     and vice versa, but clamping the number into the range."
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   623
1974
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   624
    self
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   625
        getBlock:[:model |
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   626
                |numericValue|
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   627
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   628
                (numericValue := model value) isNil ifTrue:[
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   629
                    String new
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   630
                ] ifFalse:[
2379
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   631
                    numericValue isString ifTrue:[
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   632
                        numericValue    
1974
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   633
                    ] ifFalse:[
2379
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   634
                        formatStringOrNil isNil ifTrue:[    
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   635
                            numericValue printStringRadix:radix
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   636
                        ] ifFalse:[
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   637
                            numericValue printfPrintString:formatStringOrNil
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   638
                        ]
1974
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   639
                    ]
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   640
                ]]
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   641
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   642
        putBlock:
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   643
                [:model :string |
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   644
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   645
                |value c|
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   646
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   647
                string isEmpty ifTrue:[
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   648
                    value := 0
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   649
                ] ifFalse:[
2366
9865c8d52068 +integerToHex
Claus Gittinger <cg@exept.de>
parents: 2199
diff changeset
   650
                    value := Integer readFromString:string radix:radix onError:[0]. 
1974
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   651
                ].               
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   652
                minVal notNil ifTrue:[
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   653
                    (value < minVal and: [string notEmpty]) ifTrue: [model setValue:nil].
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   654
                    value := value max:minVal.
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   655
                ].
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   656
                maxVal notNil ifTrue:[
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   657
                    (value > maxVal and: [string notEmpty]) ifTrue: [model setValue:nil].
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   658
                    value := value min:maxVal.
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   659
                ].
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   660
                self setNumberValue: value inModel: model fromInput: string.
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   661
                ]
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   662
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   663
        updateBlock: [:m :a :p | true]
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   664
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   665
    "Modified: 21.2.1997 / 18:59:44 / cg"
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   666
!
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   667
2379
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   668
integerWithThousandsSeparator    
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   669
    ^ self integerWithThousandsSeparator:$'
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   670
"/     ^ self integerWithThousandsSeparator:(UserPreferences current thousandsSeparatorCharacter)
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   671
!
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   672
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   673
integerWithThousandsSeparator:sep
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   674
    "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
   675
     and vice versa."
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   676
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   677
    self
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   678
        getBlock:[:model |
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   679
                |numericValue|
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   680
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   681
                (numericValue := model value) isNumber ifFalse:[
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   682
                    String new
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   683
                ] ifTrue:[
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   684
                    String streamContents:[:s | numericValue printOn:s thousandsSeparator:sep].
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   685
                ]]
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   686
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   687
        putBlock:
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   688
                [:model :string |
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   689
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   690
                |value s2|
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   691
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   692
                string isEmpty ifTrue:[
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   693
                    value := 0
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   694
                ] ifFalse:[
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   695
                    s2 := string reject:[:ch | ch = sep].    
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   696
                    value := Number readFromString:s2 onError:[0]
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   697
                ].
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   698
                model value:value]
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   699
2407
d66421abe47d Avoid stc compiler warning
Stefan Vogel <sv@exept.de>
parents: 2406
diff changeset
   700
        updateBlock: [:m :a :p | true]
2379
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   701
!
d884e4efa6e0 business number printing
Claus Gittinger <cg@exept.de>
parents: 2372
diff changeset
   702
1464
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   703
literal
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   704
    "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
   705
     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
   706
     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
   707
     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
   708
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   709
    self
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   710
        getBlock:[:model |
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   711
                |val s|
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   712
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   713
                val := model value.
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   714
                (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
   715
                    val isSymbol ifTrue:[
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   716
                        "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
   717
                        (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
   718
                            s
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   719
                        ] ifFalse:[
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   720
                            val printString
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   721
                        ]
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   722
                    ] ifFalse:[
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   723
                        val storeString
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   724
                    ].
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   725
                ] ifFalse:[
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   726
                    ''.
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   727
                ]]
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   728
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   729
        putBlock:
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   730
                [:model :string |
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   731
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   732
                |value s|
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   733
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   734
                string size == 0 ifTrue:[
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   735
                    value := nil
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   736
                ] ifFalse:[
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   737
                    s := string withoutSeparators.
1465
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   738
                    "be careful, #readFrom:onError: returns nil for an undefined identifier"
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   739
                    s = 'true' ifTrue:[
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   740
                        value := true.
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   741
                    ] ifFalse:[s = 'false' ifTrue:[
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   742
                        value := false.
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   743
                    ] ifFalse:[s = 'nil' ifTrue:[
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   744
                        value := nil.
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   745
                    ] ifFalse:[s first isLetter ifTrue:[
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   746
                        value := s asSymbol.
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   747
                    ] ifFalse:[
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   748
                        value := Object readFrom:s onError:[
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   749
                            s asSymbol
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   750
                        ].
02c6dfc01257 Fix prev change (#literal)
Stefan Vogel <sv@exept.de>
parents: 1464
diff changeset
   751
                    ]]]].
1464
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   752
                ].
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   753
                model value:value]
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   754
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   755
        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
   756
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   757
    "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
   758
    "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
   759
!
883cfaa89ffa Add #literal conversion to convert strings to literals or symbols.
Stefan Vogel <sv@exept.de>
parents: 1463
diff changeset
   760
508
64ee54ff8a77 added #number
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   761
number
64ee54ff8a77 added #number
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   762
    "setup the converter to convert from a string to a number
64ee54ff8a77 added #number
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   763
     and vice versa. Invalid numbers are converted to nil."
64ee54ff8a77 added #number
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   764
64ee54ff8a77 added #number
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   765
    self numberToText
64ee54ff8a77 added #number
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   766
64ee54ff8a77 added #number
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   767
    "Created: 4.4.1997 / 12:46:14 / cg"
64ee54ff8a77 added #number
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   768
!
64ee54ff8a77 added #number
Claus Gittinger <cg@exept.de>
parents: 487
diff changeset
   769
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   770
numberOrNil
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   771
    "setup the converter to convert from a string to a number
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   772
     and vice versa. Invalid numbers are converted to nil."
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   773
2372
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
   774
    self objectOrNilOfType:Number
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   775
2372
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
   776
    "Modified: / 12-01-2008 / 19:08:42 / cg"
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   777
!
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   778
1463
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   779
numberOrNilToTextMinValue:minVal maxValue:maxVal
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   780
    "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
   781
     and vice versa, but clamping the number into the range."
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   782
1974
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   783
    self numberOrNilToTextMinValue:minVal maxValue:maxVal format:nil
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
numberOrNilToTextMinValue:minVal maxValue:maxVal format:formatStringOrNil
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   787
    "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
   788
     and vice versa, but clamping the number into the range."
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   789
1463
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   790
    self
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   791
        getBlock:[:model |
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   792
                |numericValue|
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   793
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   794
                (numericValue := model value) isNil ifTrue:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   795
                    String new
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   796
                ] ifFalse:[
1974
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   797
                    formatStringOrNil isNil ifTrue:[    
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   798
                        numericValue printString
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   799
                    ] ifFalse:[
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   800
                        numericValue printfPrintString:formatStringOrNil
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
   801
                    ]
1463
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   802
                ]]
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   803
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   804
        putBlock:
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   805
                [:model :string |
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   806
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   807
                |value c|
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   808
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   809
                (string isEmpty or:[string isBlank]) ifTrue:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   810
                    value := nil
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   811
                ] ifFalse:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   812
                    value := Number readFromString:string onError:[nil]. 
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   813
                    value isNil ifTrue:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   814
                        
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   815
                    ] ifFalse:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   816
                        minVal notNil ifTrue:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   817
                            (value < minVal and: [string notEmpty]) ifTrue: [model setValue:nil].
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   818
                            value := value max:minVal.
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   819
                        ].
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   820
                        maxVal notNil ifTrue:[
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   821
                            (value > maxVal and: [string notEmpty]) ifTrue: [model setValue:nil].
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   822
                            value := value min:maxVal.
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   823
                        ].
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   824
                    ].
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   825
                ].
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   826
                self setNumberValue: value inModel: model fromInput: string.
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   827
                ]
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   828
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   829
        updateBlock: [:m :a :p | true]
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   830
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   831
    "Modified: 21.2.1997 / 18:59:44 / cg"
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   832
!
df2fec4aad9c added numberInRangeOrNil
Claus Gittinger <cg@exept.de>
parents: 1426
diff changeset
   833
1335
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   834
numberOrPointOrNil
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   835
    "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
   836
     and vice versa. Invalid numbers/points are converted to nil."
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   837
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   838
    self
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   839
        getBlock:[:model |
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   840
                |value|
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   841
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   842
                (value := model value) isNil ifTrue:[
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   843
                    String new
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   844
                ] ifFalse:[
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   845
                    value printString
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   846
                ]]
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   847
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   848
        putBlock:
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   849
                [:model :string |
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   850
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   851
                |value|
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   852
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   853
                string size > 0 ifTrue:[
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   854
                    value := Point readFrom:string onError:[
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   855
                        Number readFrom:string onError:nil
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   856
                    ]
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   857
                ]. 
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   858
                model value:value]
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   859
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   860
        updateBlock: [:m :a :p | true]
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   861
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   862
    "Created: / 5.2.2000 / 01:26:48 / cg"
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   863
!
275352274890 a new converter: numberOrPointOrNil.
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
   864
1149
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   865
numberOrStringOrSymbolOrNil
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   866
    "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
   867
     or a symbol and vice versa. 
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   868
     Invalid strings (i.e. empty) are converted to nil;
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   869
     nil values are converted to an empty string.
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   870
     This is a very special converter (for the GUI builder) 
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   871
     - probably not belonging to here"
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   872
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   873
    self
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   874
        getBlock:[:model |
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   875
                |litValue|
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   876
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   877
                (litValue := model value) isNil ifTrue:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   878
                    String new
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   879
                ] ifFalse:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   880
                    litValue storeString
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   881
                ]]
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   882
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   883
        putBlock:
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   884
                [:model :string |
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   885
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   886
                |value s|
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   887
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   888
                string isEmpty ifTrue:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   889
                    value := nil
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   890
                ] ifFalse:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   891
                    value := Number readFrom:string onError:nil.
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   892
                    value isNil ifTrue:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   893
                        s := string withoutSeparators.
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   894
                        (s startsWith:'''') ifTrue:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   895
                            value := String readFrom:s readStream onError:nil
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   896
                        ] ifFalse:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   897
                            (s startsWith:'#') ifTrue:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   898
                                s := s copyFrom:2.
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   899
                                (s startsWith:$') ifTrue:[
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   900
                                    s := s copyFrom:2 to:(s size - 1)
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   901
                                ].
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   902
                            ].
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   903
                            value := s asSymbol
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   904
                        ]
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   905
                    ]
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   906
                ].
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   907
                model value:value]
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   908
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   909
        updateBlock: [:m :a :p | true]
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   910
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   911
    "Modified: / 26.10.1997 / 13:50:32 / cg"
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   912
    "Created: / 29.10.1997 / 15:49:26 / cg"
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   913
!
80a780b5a1b5 new converters
Claus Gittinger <cg@exept.de>
parents: 1122
diff changeset
   914
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   915
numberOrSymbolOrNil
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   916
    "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
   917
     or a symbol and vice versa. 
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   918
     Invalid strings (i.e. empty) are converted to nil;
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   919
     nil values are converted to an empty string.
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   920
     This is a very special converter (for the GUI builder) 
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   921
     - probably not belonging to here"
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   922
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   923
    self
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   924
        getBlock:[:model |
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   925
                |litValue|
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   926
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   927
                (litValue := model value) isNil ifTrue:[
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   928
                    String new
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   929
                ] ifFalse:[
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   930
                    litValue storeString
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   931
                ]]
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   932
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   933
        putBlock:
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   934
                [:model :string |
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   935
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   936
                |value s|
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   937
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   938
                string isEmpty ifTrue:[
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   939
                    value := nil
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   940
                ] ifFalse:[
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   941
                    value := Number readFrom:string onError:nil.
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   942
                    value isNil ifTrue:[
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   943
                        s := string withoutSeparators.
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   944
                        (s startsWith:'#') ifTrue:[
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   945
                            s := s copyFrom:2.
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   946
                            (s startsWith:$') ifTrue:[
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   947
                                s := s copyFrom:2 to:(s size - 1)
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   948
                            ].
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   949
                        ].
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   950
                        value := s asSymbol
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   951
                    ]
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   952
                ].
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   953
                model value:value]
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   954
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   955
        updateBlock: [:m :a :p | true]
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   956
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   957
    "Modified: / 26.10.1997 / 13:50:32 / cg"
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   958
    "Created: / 29.10.1997 / 15:49:26 / cg"
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   959
!
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   960
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   961
numberToText
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   962
    "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
   963
     and vice versa."
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   964
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   965
    self
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   966
        getBlock:[:model |
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   967
                |numericValue|
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   968
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   969
                (numericValue := model value) isNumber ifFalse:[
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   970
                    String new
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   971
                ] ifTrue:[
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   972
                    numericValue printString
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   973
                ]]
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   974
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   975
        putBlock:
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   976
                [:model :string |
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   977
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   978
                |value|
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   979
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   980
                string isEmpty ifTrue:[
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   981
                    value := 0
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   982
                ] ifFalse:[
1000
70e95e4dca22 use #readFromString:onError: for string->number convertations
tz
parents: 997
diff changeset
   983
                    value := Number readFromString: string onError:[0]
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   984
                ].
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   985
                model value:value]
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   986
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   987
        updateBlock: [:m :a :p | true]
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   988
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   989
    "Created: / 21.2.1997 / 18:57:05 / cg"
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
   990
    "Modified: / 29.10.1997 / 15:49:21 / cg"
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   991
!
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   992
747
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   993
numberToText:numberOfPostDecimals
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   994
    "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
   995
     and vice versa."
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   996
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   997
    self
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   998
        getBlock:[:model |
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
   999
                |numericValue|
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1000
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1001
                (numericValue := model value) isNumber ifFalse:[
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1002
                    String new
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1003
                ] ifTrue:[
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1004
                    (numericValue asFixedPoint:numberOfPostDecimals) printString
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1005
                ]]
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1006
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1007
        putBlock:
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1008
                [:model :string |
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1009
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1010
                |value|
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1011
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1012
                string isEmpty ifTrue:[
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1013
                    value := 0
1000
70e95e4dca22 use #readFromString:onError: for string->number convertations
tz
parents: 997
diff changeset
  1014
                ] ifFalse:[     
70e95e4dca22 use #readFromString:onError: for string->number convertations
tz
parents: 997
diff changeset
  1015
                    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
  1016
                ].
1001
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
  1017
                self setNumberValue: value inModel: model fromInput: string.
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
  1018
                ]
747
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1019
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1020
        updateBlock: [:m :a :p | true]
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1021
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1022
    "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
  1023
    "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
  1024
!
fe0360fb81ee added typeConverter for decimals with n digits after point
Claus Gittinger <cg@exept.de>
parents: 726
diff changeset
  1025
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1026
numberToTextFormattedBy:formatString
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1027
    "setup the converter to convert from a string to a number
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1028
     and vice versa, using formatString.
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1029
     The formatString is currently ignored when numbers are converted
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1030
     from a string."
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1031
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1032
    self
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1033
        getBlock:[:model |
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1034
                |numericValue|
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1035
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1036
                (numericValue := model value) isNil ifTrue:[
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1037
                    String new
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1038
                ] ifFalse:[
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1039
                    PrintConverter print:numericValue formattedBy:formatString
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1040
                ]]
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1041
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1042
        putBlock:
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1043
                [:model :string |
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1044
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1045
                |value|
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1046
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1047
                string isEmpty ifTrue:[
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1048
                    value := 0
1000
70e95e4dca22 use #readFromString:onError: for string->number convertations
tz
parents: 997
diff changeset
  1049
                ] ifFalse:[          
70e95e4dca22 use #readFromString:onError: for string->number convertations
tz
parents: 997
diff changeset
  1050
                    value := Number readFromString: string onError:[0]. "asNumberFromFormatString:formatString"
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1051
                ].
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1052
                model value:value]
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1053
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1054
        updateBlock: [:m :a :p | true]
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1055
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1056
    "Modified: 21.2.1997 / 18:59:44 / cg"
446
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1057
!
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1058
1426
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1059
numberToTextLeftPaddedTo:aSize with:aCharacter
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1060
    "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
  1061
     and vice versa, using formatString.
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1062
     The formatString is currently ignored when numbers are converted
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1063
     from a string."
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1064
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1065
    self
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1066
        getBlock:[:model |
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1067
                |numericValue|
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1068
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1069
                (numericValue := model value) isNil ifTrue:[
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1070
                    String new
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1071
                ] ifFalse:[
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1072
                    numericValue printStringLeftPaddedTo:aSize with:aCharacter
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1073
                ]]
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1074
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1075
        putBlock:
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1076
                [:model :string |
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1077
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1078
                |value|
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1079
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1080
                string isEmpty ifTrue:[
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1081
                    value := 0
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1082
                ] ifFalse:[          
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1083
                    value := Number readFromString: string onError:[0]. "asNumberFromFormatString:formatString"
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1084
                ].
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1085
                model value:value]
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1086
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1087
        updateBlock: [:m :a :p | true]
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1088
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1089
    "Modified: 21.2.1997 / 18:59:44 / cg"
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1090
!
6a5f5372fcc4 added: a converter for number - string, string lwftpaddedTo: with:
tm
parents: 1407
diff changeset
  1091
941
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1092
numberToTextMinValue:minVal maxValue:maxVal
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1093
    "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
  1094
     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
  1095
1974
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1096
    self numberToTextMinValue:minVal maxValue:maxVal format:nil
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1097
!
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1098
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1099
numberToTextMinValue:minVal maxValue:maxVal format:formatStringOrNil
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1100
    "setup the converter to convert from a string to a number
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1101
     and vice versa, but clamping the number into the range."
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1102
941
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1103
    self
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1104
        getBlock:[:model |
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1105
                |numericValue|
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1106
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1107
                (numericValue := model value) isNil ifTrue:[
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1108
                    String new
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1109
                ] ifFalse:[
1974
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1110
                    formatStringOrNil isNil ifTrue:[    
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1111
                        numericValue printString
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1112
                    ] ifFalse:[
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1113
                        numericValue printfPrintString:formatStringOrNil
025c3119062b converters with format and integerToText added
werner
parents: 1832
diff changeset
  1114
                    ]
941
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1115
                ]]
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1116
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1117
        putBlock:
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1118
                [:model :string |
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1119
1001
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
  1120
                |value c|
941
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1121
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1122
                string isEmpty ifTrue:[
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1123
                    value := 0
1001
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
  1124
                ] ifFalse:[
997
9871b863dc3a it does invoke a debugger for wrong inputs
tz
parents: 947
diff changeset
  1125
                    value := Number readFromString: string onError:[0]. 
1000
70e95e4dca22 use #readFromString:onError: for string->number convertations
tz
parents: 997
diff changeset
  1126
                ].               
942
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
  1127
                minVal notNil ifTrue:[
1001
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
  1128
                    (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
  1129
                    value := value max:minVal.
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
  1130
                ].
54949af3f3c1 number-in-range may have nil-bounds
Claus Gittinger <cg@exept.de>
parents: 941
diff changeset
  1131
                maxVal notNil ifTrue:[
1001
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
  1132
                    (value > maxVal and: [string notEmpty]) ifTrue: [model setValue:nil].
944
4ef99f8da24f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 943
diff changeset
  1133
                    value := value min:maxVal.
1001
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
  1134
                ].
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
  1135
                self setNumberValue: value inModel: model fromInput: string.
b1517a7164a3 update dependents for not valid inputs
tz
parents: 1000
diff changeset
  1136
                ]
941
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1137
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1138
        updateBlock: [:m :a :p | true]
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1139
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1140
    "Modified: 21.2.1997 / 18:59:44 / cg"
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1141
!
ba196649eaec added converter for number-in-range
Claus Gittinger <cg@exept.de>
parents: 747
diff changeset
  1142
2372
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1143
objectOrNilOfType:timeOrDateClass
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1144
    "common code for timeOrNil, dateOrNil and timeStampOrNil"
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1145
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1146
    self
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1147
        getBlock:[:model |
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1148
                |timeOrDate|
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1149
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1150
                (timeOrDate := model value) isNil ifTrue:[
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1151
                    ''
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1152
                ] ifFalse:[
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1153
                    timeOrDate printString
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1154
                ]]
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1155
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1156
        putBlock:
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1157
                [:model :string |
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1158
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1159
                |value|
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1160
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1161
                string isEmpty ifTrue:[
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1162
                    value := nil
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1163
                ] ifFalse:[
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1164
                    value := timeOrDateClass readFrom:string onError:nil
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1165
                ].
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1166
                model value:value]
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1167
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1168
        updateBlock: [:m :a :p | true]
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1169
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1170
    "Created: / 12-01-2008 / 19:05:18 / cg"
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1171
!
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1172
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1173
smalltalkObject
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1174
    "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
  1175
     and vice versa. The string used is the objects storeString.
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1176
     Invalid strings (i.e. empty) are converted to nil.
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1177
     This is a very special converter (for the GUI builder) 
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1178
     - probably not belonging to here"
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1179
1786
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1180
    ^ self smalltalkObjectWithClass:Object
1407
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1181
!
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1182
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1183
smalltalkObjectOrNil
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1184
    "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
  1185
     and vice versa. The string used is the objects storeString.
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1186
     Invalid strings (i.e. empty) are converted to nil.
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1187
     This is a very special converter (for the GUI builder) 
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1188
     - probably not belonging to here"
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1189
1786
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1190
    ^ self smalltalkObjectOrNilWithClass:Object
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1191
!
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1192
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1193
smalltalkObjectOrNilWithClass:classOfObject
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1194
    "setup the converter to convert from a string to a smalltalk object
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1195
     and vice versa. The string used is the objects storeString.
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1196
     Invalid strings (i.e. empty) are converted to nil.
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1197
     This is a very special converter (for the GUI builder) 
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1198
     - probably not belonging to here"
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1199
1407
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1200
    self
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1201
        getBlock:[:model | |v s|
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1202
                     v := model value.
7b671df42e1a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1406
diff changeset
  1203
                     v isNil ifTrue:[
1406
7cd10ca1a425 smalltalkObject conversion fixed (allow nil)
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
  1204
                        s := 'nil'
1199
623c4cfe253d better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents: 1197
diff changeset
  1205
                     ] ifFalse:[
623c4cfe253d better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents: 1197
diff changeset
  1206
                            s := v storeString.
623c4cfe253d better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents: 1197
diff changeset
  1207
                            (v isString or:[v isNumber]) ifFalse:[
623c4cfe253d better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents: 1197
diff changeset
  1208
                                s := s , ' "' , v class name , '" '
623c4cfe253d better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents: 1197
diff changeset
  1209
                            ]
623c4cfe253d better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents: 1197
diff changeset
  1210
                     ].
623c4cfe253d better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents: 1197
diff changeset
  1211
                     s
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1212
                 ]
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1213
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1214
        putBlock:
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1215
                [:model :string |
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1216
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1217
                    |value|
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1218
1199
623c4cfe253d better smalltalkObject typeConverter
Claus Gittinger <cg@exept.de>
parents: 1197
diff changeset
  1219
                    string size > 0 ifTrue:[
2199
4ec7c01ed26a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1974
diff changeset
  1220
                        value := classOfObject readFrom:string onError:nil.
4ec7c01ed26a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1974
diff changeset
  1221
                        value := value ? string.
1192
6db390e6463e default: String in SmalltalkObject
Claus Gittinger <cg@exept.de>
parents: 1149
diff changeset
  1222
                    ].
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1223
                    model value:value
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1224
                ]
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1225
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1226
        updateBlock: [:m :a :p | true]
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1227
2199
4ec7c01ed26a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1974
diff changeset
  1228
    "Created: / 29-10-1997 / 15:50:16 / cg"
4ec7c01ed26a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1974
diff changeset
  1229
    "Modified: / 05-09-2006 / 17:57:53 / cg"
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1230
!
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1231
1786
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1232
smalltalkObjectWithClass:classOfObject
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1233
    "setup the converter to convert from a string to a smalltalk object
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1234
     and vice versa. The string used is the objects storeString.
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1235
     Invalid strings (i.e. empty) are converted to nil.
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1236
     This is a very special converter (for the GUI builder) 
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1237
     - probably not belonging to here"
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1238
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1239
    self
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1240
        getBlock:[:model | |v s|
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1241
                     v := model value.
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1242
                     v isNil ifTrue:[
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1243
                        s := ''
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1244
                     ] ifFalse:[
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1245
                            s := v storeString.
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1246
                            (v isString or:[v isNumber]) ifFalse:[
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1247
                                s := s , ' "' , v class name , '" '
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1248
                            ]
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1249
                     ].
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1250
                     s
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1251
                 ]
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1252
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1253
        putBlock:
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1254
                [:model :string |
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1255
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1256
                    |value|
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1257
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1258
                    string size > 0 ifTrue:[
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1259
                        value := classOfObject readFrom:string onError:nil.
2199
4ec7c01ed26a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1974
diff changeset
  1260
                        model value:value ? string
1786
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1261
                    ].
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1262
                ]
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1263
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1264
        updateBlock: [:m :a :p | true]
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1265
2199
4ec7c01ed26a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1974
diff changeset
  1266
    "Created: / 29-10-1997 / 15:50:16 / cg"
4ec7c01ed26a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1974
diff changeset
  1267
    "Modified: / 05-09-2006 / 17:57:37 / cg"
1786
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1268
!
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1269
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1270
smalltalkPoint
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1271
    "setup the converter to convert from a string to a point object
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1272
     and vice versa. The string used is the points storeString.
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1273
     Invalid strings (i.e. empty) are converted to nil.
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1274
     This is a very special converter (for the GUI builder) 
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1275
     - probably not belonging to here"
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1276
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1277
    ^ self smalltalkObjectWithClass:Point
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1278
!
3f1b68d26446 point converter
Claus Gittinger <cg@exept.de>
parents: 1697
diff changeset
  1279
1653
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1280
symbolOrBooleanOrNil
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1281
    "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
  1282
     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
  1283
     nil values are converted to an empty string.
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1284
     In addition, the strings true/false convert to/from booleans."
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1285
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1286
    self
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1287
        getBlock:[:model |
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1288
                |symbolValue|
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1289
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1290
                ((symbolValue := model value) isSymbol 
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1291
                or:[symbolValue isBoolean]) 
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1292
                ifFalse:[
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1293
                    ''
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1294
                ] ifTrue:[
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1295
                    symbolValue printString. "/ storeString
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1296
                ]]
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1297
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1298
        putBlock:
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1299
                [:model :string |
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1300
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1301
                |value s|
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1302
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1303
                string size == 0 ifTrue:[
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1304
                    value := nil
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1305
                ] ifFalse:[
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1306
                    s := string withoutSeparators.
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1307
                    (s startsWith:'#') ifTrue:[
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1308
                        s := s copyFrom:2.
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1309
                        (s startsWith:$') ifTrue:[
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1310
                            s := s copyFrom:2 to:(s size - 1)
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1311
                        ].
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1312
                        value := s asSymbol
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1313
                    ] ifFalse:[
2440
83ae5c86ce7a fixed #symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  1314
                        (#('true' 'false') includes:s) ifTrue:[
1653
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1315
                            value := Object readFromString:s.
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1316
                        ] ifFalse:[
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1317
                            value := s asSymbol
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1318
                        ]
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1319
                    ].
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1320
                ].
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1321
                model value:value]
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1322
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1323
        updateBlock: [:m :a :p | true]
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1324
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1325
    "Created: / 21.2.1997 / 18:58:38 / cg"
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1326
    "Modified: / 26.5.1998 / 15:06:06 / cg"
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1327
!
f086f72cc8fa new converter: symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 1465
diff changeset
  1328
446
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1329
symbolOrNil
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1330
    "setup the converter to convert from a string to a symbol
722
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
  1331
     and vice versa. Invalid symbols (i.e. empty) are converted to nil;
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
  1332
     nil values are converted to an empty string."
446
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1333
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1334
    self
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1335
        getBlock:[:model |
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1336
                |symbolValue|
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1337
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1338
                (symbolValue := model value) isSymbol ifFalse:[
446
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1339
                    String new
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1340
                ] ifTrue:[
946
94682a54c197 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 944
diff changeset
  1341
                    symbolValue printString. "/ storeString
446
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1342
                ]]
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1343
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1344
        putBlock:
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1345
                [:model :string |
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1346
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1347
                |value s|
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1348
1314
d81678f19c9d bug fix; test not for empty, test for size == 0
ca
parents: 1266
diff changeset
  1349
                string size == 0 ifTrue:[
446
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1350
                    value := nil
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1351
                ] ifFalse:[
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1352
                    s := string withoutSeparators.
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1353
                    (s startsWith:'#') ifTrue:[
726
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1354
                        s := s copyFrom:2.
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1355
                        (s startsWith:$') ifTrue:[
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1356
                            s := s copyFrom:2 to:(s size - 1)
cdab756aebe4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 722
diff changeset
  1357
                        ]
446
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1358
                    ].
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1359
                    value := s asSymbol
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1360
                ].
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1361
                model value:value]
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1362
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1363
        updateBlock: [:m :a :p | true]
e4a8087792d9 checkin from browser
ca
parents: 442
diff changeset
  1364
722
ea6d08251333 added #arrayLiteralOrSymbolOrNil
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
  1365
    "Created: / 21.2.1997 / 18:58:38 / cg"
946
94682a54c197 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 944
diff changeset
  1366
    "Modified: / 26.5.1998 / 15:06:06 / cg"
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1367
!
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1368
2401
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1369
time
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1370
     ^ self time24H
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1371
!
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1372
1047
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
  1373
time12H
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1374
    "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
  1375
     and vice versa."
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1376
1027
eb4d24dd7e43 printStringXXHourFormat selectors changed
tz
parents: 1026
diff changeset
  1377
    self timeToTextFormattedBy: #printString12HourFormat
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1378
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1379
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1380
!
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1381
1047
42201709a0bc converter names + hexidecimal converter added
tz
parents: 1027
diff changeset
  1382
time24H
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1383
    "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
  1384
     and vice versa."
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1385
1027
eb4d24dd7e43 printStringXXHourFormat selectors changed
tz
parents: 1026
diff changeset
  1386
    self timeToTextFormattedBy: #printString24HourFormat
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1387
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1388
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1389
!
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1390
2401
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1391
timeOfClass:timeClass withFormat:aFormatString orDefault:defaultValue
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1392
    "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
  1393
     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
  1394
     Invalid times are converted to defaultValue; likewise,
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1395
     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
  1396
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1397
    self
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1398
        getBlock:[:model |
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1399
                |time|
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1400
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1401
                (time := model value) isNil ifTrue:[
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1402
                    time := defaultValue
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1403
                ].
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1404
                time isNil ifTrue:[
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1405
                    ''
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1406
                ] ifFalse:[
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1407
                    aFormatString isNil ifTrue:[
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1408
                        time printString
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1409
                    ] ifFalse:[
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1410
                        time printStringFormat:aFormatString
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1411
                ]]]
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1412
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1413
        putBlock:
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1414
                [:model :string |
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1415
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1416
                |value|
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1417
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1418
                string isEmpty ifTrue:[
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1419
                    value := defaultValue
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1420
                ] ifFalse:[
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1421
"/                    aFormatString isNil ifTrue:[
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1422
                        value := timeClass readFrom:string onError:defaultValue
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1423
"/                    ] ifFalse:[
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1424
"/                        value := timeClass readFrom:string printFormat:aFormatString onError:defaultValue
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1425
"/                    ]
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1426
                ].
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1427
                model value:value]
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1428
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1429
        updateBlock: [:m :a :p | true]
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1430
!
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1431
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1432
timeOrNil
2372
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1433
    "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
  1434
2372
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1435
    self objectOrNilOfType:Time
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1436
2372
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1437
    "Created: / 04-03-1997 / 11:52:47 / cg"
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1438
    "Modified: / 12-01-2008 / 19:06:21 / cg"
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1439
!
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1440
2372
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1441
timeStampOrNil
2401
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1442
    <resource: #obsolete>
2372
abd41b275bee *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2366
diff changeset
  1443
    "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
  1444
2401
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1445
    self timestampOrNil
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1446
!
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1447
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1448
timeToText
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1449
    "setup the converter to convert from a string to a time
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1450
     and vice versa."
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1451
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1452
    self timeToTextFormattedBy: #printString
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1453
!
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1454
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1455
timeToTextFormattedBy: format
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1456
    "setup the converter to convert from a string to a time formatted by format
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1457
     and vice versa."
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1458
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1459
    self
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1460
        getBlock:[:model |
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1461
                |time|
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1462
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1463
                (time := model value) isNil ifTrue:[
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1464
                    Time now perform: format
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1465
                ] ifFalse:[
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1466
                    time perform: format
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1467
                ]]
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1468
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1469
        putBlock:
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1470
                [:model :string |
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1471
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1472
                |value|
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1473
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1474
                string isEmpty ifTrue:[
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1475
                    value := Time now
1026
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1476
                ] ifFalse:[              
6b18a2f8833f date + time converters added
tz
parents: 1002
diff changeset
  1477
                    value := Time readFrom:string onError:[Time now]
487
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1478
                ].
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1479
                model value:value]
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1480
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1481
        updateBlock: [:m :a :p | true]
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1482
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1483
    "Modified: 21.2.1997 / 18:59:06 / cg"
c7465591e41a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 486
diff changeset
  1484
    "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
  1485
!
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1486
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1487
timestamp
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1488
    "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
  1489
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1490
    ^ self timeOfClass:Timestamp withFormat:nil orDefault:Timestamp now
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1491
!
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1492
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1493
timestampOrNil
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1494
    "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
  1495
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1496
    self objectOrNilOfType:Timestamp
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1497
6ce0d64635e0 Typeconverters for #time #timeOrNil #timestamp #timestampOrNil
Stefan Vogel <sv@exept.de>
parents: 2379
diff changeset
  1498
    "Modified: / 12-01-2008 / 19:06:06 / cg"
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1499
! !
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1500
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1501
!TypeConverter class methodsFor:'documentation'!
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1502
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1503
version
2440
83ae5c86ce7a fixed #symbolOrBooleanOrNil
Claus Gittinger <cg@exept.de>
parents: 2407
diff changeset
  1504
    ^ '$Header: /cvs/stx/stx/libview2/TypeConverter.st,v 1.55 2008-04-23 10:00:27 cg Exp $'
442
2f5c72b7d46b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1505
! !