Subversion Repositories wimsdev

Rev

Rev 16167 | Rev 16169 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
10915 bpr 1
!if $wims_read_parm!=slib_header
13585 bpr 2
  !goto proc
10915 bpr 3
!endif
4
 
15639 bpr 5
slib_author=Bernadette, Perrin-Riou; Raoul, Hatterer; Eric, Reyssat
6
slib_parms=3\
15626 reyssat 7
,number\
8
,language (fr,en,it ; default=fr)\
16166 bpr 9
,space separated options in brackets (works in french): frrule (trad/1990, default=1990),type (card/ord, default=card), plural (yes/no, default=no), fracdenom (yes/no, default=yes), [variant=septante,huitante,nonante]
15626 reyssat 10
 
16165 bpr 11
slib_example=5678\
10915 bpr 12
[678,122]\
13
[295,180],fr\
11751 bpr 14
[295,180],en\
10915 bpr 15
[181,1008,1081,200,201,280]\
11751 bpr 16
[181,1008,1081,200,201,280],en\
14528 czzmrn 17
[181,1008,1081,200,201,280],it\
15626 reyssat 18
80080,fr\
11751 bpr 19
[9880,99120],fr\
14528 czzmrn 20
[9880,99120],en\
15626 reyssat 21
[9880,99120],it\
15639 bpr 22
371,fr,[type=ord plural=yes]\
23
371,fr,[type=ord plural=yes frrule=trad]\
24
4,fr,[type=ord]\
25
4,fr,[type=ord plural=yes fracdenom=no]\
15626 reyssat 26
[0,1,10,100,1000,10000,100000,1000000,10000000,1000000000], fr\
14528 czzmrn 27
[0,1,10,100,1000,10000,100000,1000000,10000000], en\
16161 bpr 28
[0,1,10,100,1000,10000,100000,1000000,10000000,1000000000], it\
16165 bpr 29
[678,9880,99120],fr,[variant=septante,huitante,nonante]\
30
[485,95,1881,91],fr,[variant=septante,huitante,nonante]
11751 bpr 31
 
10915 bpr 32
!exit
33
 
34
:proc
35
 
15626 reyssat 36
 
37
!! Extraction des paramètres et options
38
!distribute item $wims_read_parm into slib_data,slib_language,slib_options
15639 bpr 39
slib_options=!declosing $slib_options
15626 reyssat 40
 
41
slib_rule=!getopt frrule in $slib_options
42
!default slib_rule=1990
43
slib_type=!getopt type in $slib_options
44
!default slib_type=card
45
slib_plural=!getopt plural in $slib_options
46
!default slib_plural=no
47
slib_fden=!getopt fracdenom in $slib_options
48
!default slib_fden=yes
16161 bpr 49
slib_variant=!getopt variant in $slib_options
11751 bpr 50
slib_language= $(wims_read_parm[2])
15766 czzmrn 51
!if $slib_language notwordof it fr en
52
  slib_language=fr
53
!endif
10915 bpr 54
!reset slib_out
55
slib_data= $(wims_read_parm[1])
56
slib_data=!declosing $slib_data
11751 bpr 57
!if $slib_language=en
58
  !! english transcription
59
  !! author : Raoul HATTERER
60
  !! algorithm: http://www.blackwasp.co.uk/NumberToWords.aspx
10915 bpr 61
 
11751 bpr 62
  slib_smallNumbers = one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen
63
  slib_tyWords = , twenty, thirty, forty, fifty, sixty, seventy, eighty, ninety
64
  slib_scaleNumbers = ,thousand, million, billion
65
 
66
  !for slib_number in $slib_data
67
    !! Zero Rule.
68
    !! If the value is zero then the number in words is 'zero'
69
    !! and no other rules apply.
70
    !if $slib_number==0
71
      slib_combined=zero
72
    !else
73
      !! Three Digit Rule.
74
      !! The integer value is split into groups of three digits starting from the right-hand side.
75
      !! Once converted to text, the three-digit groups are recombined with the addition
15638 reyssat 76
      !! of the relevant scale number (thousand, million, billion).
11751 bpr 77
 
78
      !! The integer value is split into groups of three digits starting from the right-hand side.
15639 bpr 79
      !reset slib_3digitsGroups
80
      !for slib_scale= 1 to 4
81
        slib_3digits=!char -3 to -1 of $slib_number
82
        slib_3digitsGroups=!append item $slib_3digits to $slib_3digitsGroups
11751 bpr 83
        slib_number=!char 1 to -4 of $slib_number
15639 bpr 84
      !next
11751 bpr 85
 
86
      !! Each set of three digits is then processed individually as a number of hundreds, tens and units.
15639 bpr 87
      !reset slib_textGroups
88
      !for slib_scale= 1 to 4
89
        slib_3digits= !column $slib_scale of $slib_3digitsGroups
90
        !if $slib_3digits > 99
91
          slib_hundreds=!char -3 of $slib_3digits
92
        !else
93
          slib_hundreds=0
94
        !endif
95
        slib_tensUnits=!char -2 to -1 of $slib_3digits
96
        slib_tens=!char -2 of $slib_3digits
97
        slib_units=!char -1 of $slib_3digits
98
        !! Hundreds Rules.
99
        !! If the hundreds portion of a three-digit group is not zero,
100
        !! the number of hundreds is added as a word.
101
        !! If the three-digit group is exactly divisible by one hundred,
102
        !! the text 'hundred' is appended.
103
        !! If not, the text "hundred and" is appended.
104
        !! eg. 'two hundred' or 'one hundred and twelve'
105
        !reset slib_3digitsText
106
        !if $slib_hundreds!=0
107
          slib_3digitsText = !column $slib_hundreds of $slib_smallNumbers
11751 bpr 108
          slib_3digitsText = $slib_3digitsText hundred
15639 bpr 109
          !if $slib_tensUnits!=00
110
            slib_3digitsText = $slib_3digitsText and
111
          !endif
112
        !endif
11751 bpr 113
 
15639 bpr 114
        !! Tens Rules.
115
        !! If the tens section of a three-digit group is two or higher,
116
        !! the appropriate '-ty' word (twenty, thirty, etc.) is added
117
        !! to the text and followed by the name of the third digit
118
        !! (unless the third digit is a zero, which is ignored).
119
        !! If the tens and the units are both zero, no text is added.
120
        !! For any other value, the name of the one or two-digit number
121
        !! is added as a special case.
122
        !if $slib_tens >= 2
123
          slib_tyWord=!column $slib_tens of $slib_tyWords
124
          slib_3digitsText= $slib_3digitsText $slib_tyWord
125
          !if $slib_units!= 0
126
            slib_unitWord=!column $slib_units of $slib_smallNumbers
127
            slib_3digitsText=$slib_3digitsText-$slib_unitWord
128
          !endif
129
        !else
130
          !if $[$slib_tensUnits]!= 0
131
            slib_tenUnitWord=!column $slib_tensUnits of $slib_smallNumbers
132
            slib_3digitsText= $slib_3digitsText $slib_tenUnitWord
133
          !endif
134
        !endif
135
        !if $slib_3digits==000
136
          slib_3digitsText=zero
137
        !endif
138
        slib_textGroups=!append item $slib_3digitsText to $slib_textGroups
139
      !next
11751 bpr 140
 
15639 bpr 141
      !! Recombination Rules.
142
      !! When recombining the translated three-digit groups,
143
      !! each group except the last is followed by a large number name
144
      !! and a comma,
145
      !! unless the group is blank and therefore not included at all.
146
      !! One exception is when the final group does not include
147
      !! any hundreds and there is more than one non-blank group.
148
      !! In this case, the final comma is replaced with 'and'.
149
      !! eg. 'one billion, one million and twelve'.
11751 bpr 150
 
15639 bpr 151
      slib_combined = !column 1 of $slib_textGroups
152
      !if $slib_combined=zero
153
        slib_combined=
154
      !endif
155
      slib_3digits=!column 1 of $slib_3digitsGroups
156
      !if $[$slib_3digits]>0 and $[$slib_3digits]<100
157
        slib_appendAnd=true
158
      !else
159
        slib_appendAnd=false
160
      !endif
161
      !for slib_scale = 2 to 4
162
        slib_3digits=!column $slib_scale of $slib_3digitsGroups
163
        !if $[$slib_3digits]!=0
164
          slib_3digitsText=!column $slib_scale of $slib_textGroups
165
          slib_scaleNumber=!column $slib_scale of  $slib_scaleNumbers
166
          slib_prefix = $slib_3digitsText $slib_scaleNumber
167
          !if $slib_appendAnd==true
168
            slib_prefix=$slib_prefix and
169
            slib_appendAnd=false
170
          !else
171
            slib_empty=!charcnt $slib_combined
172
            !if $slib_empty!=0
173
              slib_prefix=$slib_prefix,
174
            !endif
175
          !endif
176
          slib_combined=$slib_prefix $slib_combined
177
        !endif
178
      !next
11751 bpr 179
    !endif
180
    slib_out=!append item $slib_combined to $slib_out
181
  !next
14528 czzmrn 182
  !goto end
15639 bpr 183
  !! todo: ten million should be ten millions etc.
184
!endif
14528 czzmrn 185
 
186
!if $slib_language=it
15639 bpr 187
  !! use adapted English algorithm (MC)
14528 czzmrn 188
  slib_smallNumbers = uno, due, tre, quattro, cinque, sei, sette, otto, nove, dieci, undici, dodici, tredici, quattordici, quindici, sedici, diciassette, diciotto, diciannove
189
  slib_tyWords = , venti, trenta, quaranta, cinquanta, sessanta, settanta, ottanta, novanta
190
  slib_scaleNumbers = ,mila, milioni, miliardi
191
 
192
  !for slib_number in $slib_data
193
    !! Zero Rule.
194
    !! If the value is zero then the number in words is 'zero'
195
    !! and no other rules apply.
196
    !if $slib_number==0
197
      slib_combined=zero
198
    !else
199
      !! Three Digit Rule.
200
      !! The integer value is split into groups of three digits starting from the right-hand side.
201
      !! Once converted to text, the three-digit groups are recombined with the addition
15639 bpr 202
      !! of the relevant scale number (thousand, million, billion).
14528 czzmrn 203
 
204
      !! The integer value is split into groups of three digits starting from the right-hand side.
15639 bpr 205
      !reset slib_3digitsGroups
206
      !for slib_scale= 1 to 4
207
        slib_3digits=!char -3 to -1 of $slib_number
208
        slib_3digitsGroups=!append item $slib_3digits to $slib_3digitsGroups
14528 czzmrn 209
        slib_number=!char 1 to -4 of $slib_number
15639 bpr 210
      !next
14528 czzmrn 211
 
212
      !! Each set of three digits is then processed individually as a number of hundreds, tens and units.
15639 bpr 213
      !reset slib_textGroups
214
      !for slib_scale= 1 to 4
215
        slib_3digits= !column $slib_scale of $slib_3digitsGroups
216
        !if $slib_3digits > 99
217
          slib_hundreds=!char -3 of $slib_3digits
218
        !else
219
          slib_hundreds=0
220
        !endif
221
        slib_tensUnits=!char -2 to -1 of $slib_3digits
222
        slib_tens=!char -2 of $slib_3digits
223
        slib_units=!char -1 of $slib_3digits
224
        !! Hundreds Rules.
225
        !! If the hundreds portion of a three-digit group is not zero
226
        !! if it is 1, the word "uno" is omitted,
227
        !! the number of hundreds is added as a word.
228
        !reset slib_3digitsText
229
        !if $slib_hundreds!=0
230
          slib_3digitsText = !column $slib_hundreds of $slib_smallNumbers
231
          !if $slib_hundreds==1
232
            slib_3digitsText = cento
233
          !else
234
            slib_3digitsText = $slib_3digitsText cento
235
          !endif
236
        !endif
14528 czzmrn 237
 
15639 bpr 238
        !! Tens Rules.
239
        !! If the tens section of a three-digit group is two or higher,
240
        !! the appropriate '-ty' word (twenty, thirty, etc.) is added
241
        !! to the text and followed by the name of the third digit
242
        !! (unless the third digit is a zero, which is ignored).
243
        !! If the tens and the units are both zero, no text is added.
244
        !! For any other value, the name of the one or two-digit number
245
        !! is added as a special case.
246
        !if $slib_tens >= 2
247
          slib_tyWord=!column $slib_tens of $slib_tyWords
248
          slib_3digitsText= $slib_3digitsText $slib_tyWord
249
          !if $slib_units!= 0
250
            slib_unitWord=!column $slib_units of $slib_smallNumbers
251
            slib_3digitsText=$slib_3digitsText $slib_unitWord
252
          !endif
253
        !else
254
          !if $[$slib_tensUnits]!= 0
255
            slib_tenUnitWord=!column $slib_tensUnits of $slib_smallNumbers
256
            slib_3digitsText= $slib_3digitsText $slib_tenUnitWord
257
          !endif
258
        !endif
259
        !if $slib_3digits==000
260
          slib_3digitsText=zero
261
        !endif
262
        slib_3digitsText=!nospace $slib_3digitsText
263
        slib_textGroups=!append item $slib_3digitsText to $slib_textGroups
264
      !next
14528 czzmrn 265
 
15639 bpr 266
      !! Recombination Rules.
267
      !! When recombining the translated three-digit groups,
268
      !! each group except the last is followed by a large number name
269
      !! unless the group is blank and therefore not included at all.
270
      !! One exception is when the final group does not include
271
      !! any hundreds and there is more than one non-blank group.
272
      !! In this case, the final comma is replaced with 'and'.
273
      !! eg. 'one billion, one million and twelve'.
14528 czzmrn 274
 
15639 bpr 275
      slib_combined = !column 1 of $slib_textGroups
276
      !if $slib_combined=zero
277
        slib_combined=
278
      !endif
279
      slib_3digits=!column 1 of $slib_3digitsGroups
280
      !if $[$slib_3digits]>0 and $[$slib_3digits]<100
281
        slib_appendAnd=true
282
      !else
283
        slib_appendAnd=false
284
      !endif
285
      !for slib_scale = 2 to 4
286
        slib_3digits=!column $slib_scale of $slib_3digitsGroups
287
        !if $[$slib_3digits]!=0
288
          slib_3digitsText=!column $slib_scale of $slib_textGroups
289
          slib_scaleNumber=!column $slib_scale of  $slib_scaleNumbers
290
          !if $[$slib_3digits]==1
291
            !if $slib_scale=2
292
              slib_prefix = mille
293
            !else
294
              !!      !if $slib_prefix==2
295
              slib_prefix = un $slib_scaleNumber
296
              !!      !else
297
              !!        slib_prefix = $slib_scaleNumber
298
              !!      !endif
299
            !endif
300
          !else
301
            !if $slib_scale=2
302
              slib_prefix = $slib_3digitsText$slib_scaleNumber
303
            !else
304
              slib_prefix = $slib_3digitsText $slib_scaleNumber
305
            !endif
306
          !endif
307
          !if $slib_appendAnd==true
308
            slib_prefix=$slib_prefix e
309
            slib_appendAnd=false
310
          !else
311
            slib_empty=!charcnt $slib_combined
312
            !if $slib_empty!=0
313
              slib_prefix=$slib_prefix
314
            !endif
315
          !endif
316
          slib_combined=$slib_prefix $slib_combined
317
        !endif
318
      !next
14528 czzmrn 319
    !endif
320
    slib_out=!append item $slib_combined to $slib_out
321
  !next
15639 bpr 322
  !! contrazioni eufoniche di vocali
14528 czzmrn 323
  slib_out=!replace internal oo by o in $slib_out
324
  slib_out=!replace internal antauno by antuno in $slib_out
14529 czzmrn 325
  slib_out=!replace internal antaotto by antotto in $slib_out
14528 czzmrn 326
  slib_out=!replace internal tiuno by tuno in $slib_out
14529 czzmrn 327
  slib_out=!replace internal tiotto by totto in $slib_out
15639 bpr 328
  !! need singular
14528 czzmrn 329
  slib_out=!replace internal un milioni by un milione in $slib_out
330
  slib_out=!replace internal un miliardi by un miliardo in $slib_out
15639 bpr 331
  !goto end
14528 czzmrn 332
!endif
333
 
15626 reyssat 334
!if $slib_language=fr
15638 reyssat 335
  !! use adapted English algorithm (E.R.)
336
  !! treats simultaneously cardinal and ordinal numbers
15639 bpr 337
 
15626 reyssat 338
  slib_smallNumbers = un, deux, trois, quatre, cinq, six, sept, huit, neuf, dix, onze, douze, treize, quatorze, quinze, seize, dix-sept, dix-huit, dix-neuf
15638 reyssat 339
  slib_tyWords = , vingt, trente, quarante, cinquante, soixante, soixante, quatre-vingt, quatre-vingt
16165 bpr 340
  !if septante isin $slib_variant
341
    slib_tyWords=!replace item number 7 by septante in $slib_tyWords
342
  !endif
343
  !if huitante isin $slib_variant
344
    slib_tyWords=!replace item number 8 by huitante in $slib_tyWords
345
  !endif
346
  !if huiptante isin $slib_variant
347
    slib_tyWords=!replace item number 8 by huiptante in $slib_tyWords
348
  !endif
349
  !if nonante isin $slib_variant
350
    slib_tyWords=!replace item number 9 by nonante in $slib_tyWords
351
  !endif
15626 reyssat 352
  slib_scaleNumbers = ,mille, million, milliard
353
  slib_smallNumbersOrd = unième, deuxième, troisième, quatrième, cinquième, sixième, septième, huitième, neuvième, dixième, onzième, douzième, treizième, quatorzième, quinzième, seizième, dix-septième, dix-huitième, dix-neuvième
15639 bpr 354
  slib_tyWordsOrd = , vingtième, trentième, quarantième, cinquantième, soixantième, , quatre-vingtième,
15626 reyssat 355
  slib_scaleNumbersOrd = ,millième, millionième, milliardième
16165 bpr 356
  slib_var1=7,9
357
  slib_var2=2,3,4,5,6,8
358
  slib_var3=8
15638 reyssat 359
 
16165 bpr 360
  !if septante isin $slib_variant
361
    slib_tyWordsOrd=!replace item number 7 by septantième in $slib_tyWordsOrd
362
    slib_var1=!listcomplement 7 in $slib_var1
363
    slib_var2=$slib_var2,7
364
  !endif
365
  !if huitante isin $slib_variant
366
    slib_tyWordsOrd=!replace item number 8 by huitantième in $slib_tyWordsOrd
367
    slib_var1=!listcomplement 8 in $slib_var1
368
    slib_var2=$slib_var2,8
369
    slib_var3=
370
  !endif
371
  !if huiptante isin $slib_variant
372
    slib_tyWordsOrd=!replace item number 8 by huiptantième in $slib_tyWordsOrd
373
    slib_var1=!listcomplement 8 in $slib_var1
374
    slib_var2=$slib_var2,8
375
    slib_var3=
376
  !endif
377
  !if nonante isin $slib_variant
378
    slib_tyWordsOrd=!replace item number 9 by nonantième in $slib_tyWordsOrd
379
    slib_var1=!listcomplement 9 in $slib_var1
380
    slib_var2=$slib_var2,9
381
  !endif
382
  slib_var2=!sort list $slib_var2
15638 reyssat 383
  !! mark for french plural (so we can use $s)
15626 reyssat 384
  s=s
15638 reyssat 385
 
15639 bpr 386
  !! join words with space character (traditional french rule) or - sign (1990 french "new spelling" rule)
15626 reyssat 387
  !if $slib_rule issamecase trad
15639 bpr 388
    tiret=$ $
15626 reyssat 389
  !else
390
    tiret=-
15639 bpr 391
  !endif
15638 reyssat 392
  et=$(tiret)et$tiret
15626 reyssat 393
 
394
  !for slib_number in $slib_data
15638 reyssat 395
    !! Zero and small ordinals (<=4) treated first separately.
396
    !! If the value is zero then the cardinal number in words is 'zero' (ordinal is 'zéro-ième')
15626 reyssat 397
    !! and no other rules apply.
398
    !if $slib_number==0
399
      !if $slib_type issamecase ord
15638 reyssat 400
        slib_combined=zéro-ième
15626 reyssat 401
      !else
15638 reyssat 402
        slib_combined=zéro
15626 reyssat 403
      !endif
404
    !else
405
      !if $[$slib_number]<5 and ($slib_type issamecase ord)
406
        !if $slib_fden issamecase no
15639 bpr 407
          slib_ordinals=premier,deuxième,troisième,quatrième
15626 reyssat 408
        !else
15639 bpr 409
          slib_ordinals=unième,demi,tiers,quart
15626 reyssat 410
        !endif
411
        slib_combined=!column $slib_number of $slib_ordinals
412
 
15638 reyssat 413
      !else     !! GENERAL CASE of slib_number, neither 0 nor small ordinal
15639 bpr 414
 
15638 reyssat 415
        !! Three Digit Rule.
416
        !! The integer value is split into groups of three digits starting from the right-hand side.
417
        !! Once converted to text, the three-digit groups are recombined with the addition
418
        !! of the relevant scale number (mille, million, milliard).
15639 bpr 419
 
15638 reyssat 420
        !! First, split in groups of 3 starting from right
421
        !reset slib_3digitsGroups
422
        !for slib_scale= 1 to 4
423
          slib_3digits=!char -3 to -1 of $slib_number
424
          slib_3digitsGroups=!append item $slib_3digits to $slib_3digitsGroups
425
          slib_number=!char 1 to -4 of $slib_number
426
        !next
15639 bpr 427
 
15638 reyssat 428
        !! Each set of three digits is then processed individually as a number of hundreds, tens and units.
429
        !! flag slib_endOfNb to mark if we the current digit is the last non zero one in the whole number
430
        !! (to know if we add 'ième' here to ordinal number)
431
        slib_endOfNb=yes
432
        !reset slib_textGroups
433
        !for slib_scale= 1 to 4
434
          slib_3digits=!column $slib_scale of $slib_3digitsGroups
435
          !if $slib_3digits > 99
436
            slib_hundreds=!char -3 of $slib_3digits
437
          !else
438
            slib_hundreds=0
439
          !endif
440
          slib_tensUnits=!char -2 to -1 of $slib_3digits
441
          slib_tens=!char -2 of $slib_3digits
15626 reyssat 442
 
15638 reyssat 443
          !! due to french oddity :   78 = 60 + 18  , 93 = 80 + 13
16165 bpr 444
          !if $[$slib_tens] isin $slib_var1
15638 reyssat 445
            slib_tU=$[$slib_tensUnits-10*($slib_tens-1)]
446
          !else
447
            slib_tU=$slib_tensUnits
448
          !endif
449
          slib_units=!char -1 of $slib_3digits
15639 bpr 450
 
15638 reyssat 451
          !! Hundreds Rules.
452
          !! If the hundreds portion of a three-digit group is not zero
453
          !! the number of hundreds is added as a word (except if it is 1)
454
          !! and then the word 'cent/cents/centième (depending on singular/plural/ordinal)
455
          !reset slib_3digitsText
15639 bpr 456
 
15638 reyssat 457
          !if ($slib_type issamecase ord) and ($slib_endOfNb  issamecase yes) and ($[$slib_tensUnits]==0)
458
            slib_centType=centième
459
            slib_centsType=centième
460
            slib_endOfNb=no
461
          !else
462
            slib_centType=cent
463
            slib_centsType=cents
464
          !endif
15639 bpr 465
 
15638 reyssat 466
          !if $slib_hundreds!=0
467
            slib_3digitsText = !column $slib_hundreds of $slib_smallNumbers
468
            !if $slib_hundreds==1
469
              !if $slib_tensUnits>0
470
                slib_3digitsText = cent$tiret
15639 bpr 471
              !else
15638 reyssat 472
                slib_3digitsText = $slib_centType
473
              !endif
474
            !else
475
              !if $slib_tensUnits>0
476
                slib_3digitsText = $slib_3digitsText$(tiret)cent$tiret
477
              !else
478
                slib_3digitsText = $slib_3digitsText$(tiret)$slib_centsType
479
              !endif
480
            !endif
481
          !endif
15639 bpr 482
 
15638 reyssat 483
          !! Tens Rules.
484
          !! If the tens section of a three-digit group is two or higher,
485
          !! the appropriate '-ty' word (vingt, trente, etc.) is added
486
          !! to the text and followed by the name of the third digit
487
          !! (unless the third digit is a zero, which is ignored, but for 70, 90, the 'third digit' is dix)).
15639 bpr 488
          !! French oddity : add 'et' between tens and units when units=1, except if tens=8 (vingt-et-un, quatre-vingt-un)
489
          !! Similar rule for 71
490
          !! French oddity : quatre-vingts with s iff nothing after.
15638 reyssat 491
          !! If the tens and the units are both zero, no text is added.
15639 bpr 492
          !! 7x and 9x are treated differently.
15638 reyssat 493
          !! For any other value, the name of the one or two-digit number
494
          !! is added as a special case.
15626 reyssat 495
 
15638 reyssat 496
          !! _tyWord ends differently if ordinal number without unit 'digit'
16168 bpr 497
          !if ($slib_type issamecase ord)  and ($slib_endOfNb issamecase yes) and ($slib_units==0) and ($slib_tens isin $slib_var2)
15638 reyssat 498
            slib_tyWordsType=$slib_tyWordsOrd
499
            slib_endOfNb=no
500
          !else
501
            slib_tyWordsType=$slib_tyWords
502
          !endif
15639 bpr 503
 
15638 reyssat 504
          !if ($slib_type issamecase ord) and ($slib_endOfNb issamecase yes)
505
            slib_smallNumbersType=$slib_smallNumbersOrd
506
            slib_endOfNb=no
507
          !else
508
            slib_smallNumbersType=$slib_smallNumbers
509
          !endif
15639 bpr 510
 
16165 bpr 511
          !if $slib_tens>=2
15638 reyssat 512
            slib_tyWord=!column $slib_tens of $slib_tyWordsType
513
            slib_3digitsText= $slib_3digitsText$slib_tyWord
16165 bpr 514
            !if $[$slib_tens] isin $slib_var2
15638 reyssat 515
              !if $slib_units!= 0
516
                slib_unitWord=!column $slib_units of $slib_smallNumbersType
16165 bpr 517
                !if $slib_units>1 or $slib_tens==$slib_var3
15638 reyssat 518
                  slib_3digitsText=$slib_3digitsText-$slib_unitWord
519
                !else
520
                  slib_3digitsText=$slib_3digitsText$et$slib_unitWord
521
                !endif
522
              !endif
16168 bpr 523
              !if ($slib_tensUnits==$[$slib_var3*10]) and ($slib_type==card) and ($slib_scale==1)
15638 reyssat 524
                slib_3digitsText=$slib_3digitsText$s
15639 bpr 525
              !endif
16165 bpr 526
            !else    !! donc slib_tens vaut 7 ou 9 en general
15638 reyssat 527
              !if $[$slib_tensUnits]!= 0
528
                slib_tenUnitWord=!column $slib_tU of $slib_smallNumbersType
529
                !if $[$slib_tensUnits]==71
530
                  slib_tenUnitWord=$et$slib_tenUnitWord
531
                  slib_3digitsText=$slib_3digitsText$slib_tenUnitWord
15639 bpr 532
                !else
15638 reyssat 533
                  slib_3digitsText=$slib_3digitsText-$slib_tenUnitWord
15639 bpr 534
                !endif
15638 reyssat 535
              !endif
536
            !endif
16165 bpr 537
          !else !! donc slib_tens vaut 0 ou 1
15638 reyssat 538
            slib_tenUnitWord=!column $slib_tU of $slib_smallNumbersType
539
            slib_3digitsText= $slib_3digitsText$slib_tenUnitWord
540
          !endif
541
          !if $slib_3digits==000
542
            slib_3digitsText=zero
543
          !endif
544
          slib_textGroups=!append item $slib_3digitsText to $slib_textGroups
15626 reyssat 545
 
15638 reyssat 546
          !! if this pack of 3 digits is non zero then next packs are not at end of number (useful for ordinals)
547
          !if $[$slib_3digits]!=0
548
            slib_endOfNb=no
549
          !endif
550
        !next
15639 bpr 551
 
15638 reyssat 552
        !! Recombination Rules.
553
        !! When recombining the translated three-digit groups,
554
        !! each group except the last is followed by a scale number name
555
        !! unless the group is blank and therefore not included at all.
15639 bpr 556
 
15638 reyssat 557
        slib_endOfNb=yes
558
        slib_combined = !column 1 of $slib_textGroups
559
        !if $slib_combined=zero
560
          slib_combined=
561
        !endif
562
        slib_3digits=!column 1 of $slib_3digitsGroups
563
        !if $[$slib_3digits]>0
564
          slib_endOfNb=no
565
        !endif
566
        !for slib_scale = 2 to 4
567
          slib_3digits=!column $slib_scale of $slib_3digitsGroups
568
          !if $[$slib_3digits]!=0
15639 bpr 569
            !! do we use cardinal or ordinal scale number name (mille/millième, ...) ?
570
            !if ($slib_endOfNb issamecase yes) and ($slib_type issamecase ord)
15638 reyssat 571
              slib_scaleNumbersType=$slib_scaleNumbersOrd
572
              slib_endOfNb=no
573
            !else
574
              slib_scaleNumbersType=$slib_scaleNumbers
575
            !endif
15626 reyssat 576
            slib_3digitsText=!column $slib_scale of $slib_textGroups
16165 bpr 577
            slib_scaleNumber=!column $slib_scale of $slib_scaleNumbersType
15638 reyssat 578
            !if $[$slib_3digits]==1
579
              !if $slib_scale=2
580
                slib_prefix = $slib_scaleNumber
581
              !else
582
                !if ($slib_type issamecase ord) and ($slib_scaleNumbersType issamecase $slib_scaleNumbersOrd)
583
                  slib_prefix = $slib_scaleNumber
584
                !else
585
                  slib_prefix = un$tiret$slib_scaleNumber
586
                !endif
587
              !endif
588
            !else
589
              slib_prefix = $slib_3digitsText$tiret$slib_scaleNumber
15639 bpr 590
              !! add plural mark to scale number
15638 reyssat 591
              !if ($slib_scale notsamecase 2) and ($slib_scaleNumbersType notsamecase $slib_scaleNumbersOrd)
592
                slib_prefix = $slib_prefix$s
593
              !endif
594
            !endif
595
            slib_empty=!charcnt $slib_combined
596
            !if $slib_empty!=0
597
              slib_prefix=$slib_prefix$tiret
598
            !endif
599
            slib_combined=$slib_prefix$slib_combined
600
          !endif
601
          !if $[$slib_3digits] > 0
602
            slib_endOfNb=no
603
          !endif
604
        !next slib_scale
605
      !endif
606
    !endif (slib_number==0?)
607
 
608
    !! if plural of ordinal, add s
609
    !if ($slib_plural issamecase yes) and ($slib_type issamecase ord)
610
      slib_dc=!char -1 of $slib_combined
611
      !if $slib_dc notsamecase s
612
        slib_combined=$slib_combined$s
613
      !endif
15626 reyssat 614
    !endif
615
    slib_out=!append item $slib_combined to $slib_out
15638 reyssat 616
  !next slib_number
16161 bpr 617
  !reset slib_variant
15638 reyssat 618
  !goto end
15626 reyssat 619
!endif
14529 czzmrn 620
:end