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