Subversion Repositories wimsdev

Rev

Rev 15402 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
20 reyssat 1
!if $wims_read_parm!=slib_header
13585 bpr 2
  !goto proc
20 reyssat 3
!endif
4
 
4701 bpr 5
slib_author=Fabrice, Guerimand
18396 bpr 6
!!201904: rajout option tex (par Gilles Marbeuf)
7
!!202007: change space by   in html mode (by FG)
8
!!202408: treate some cases with input of the form e+6
4701 bpr 9
slib_example=4345678\
13902 bpr 10
4345678,tex\
4701 bpr 11
5678\
13902 bpr 12
5678,tex\
4701 bpr 13
5 234\
13902 bpr 14
5 234,tex\
4701 bpr 15
456.789567\
13902 bpr 16
456.789567,tex\
4701 bpr 17
456.789567,comma\
13902 bpr 18
456.789567,comma tex\
19
[897456,789],comma\
18396 bpr 20
[897456,789],comma tex\
21
8.1e+09\
22
8.1E+09\
23
8.1897667e+05\
24
8.1e-05
20 reyssat 25
!exit
26
 
27
:proc
4701 bpr 28
slib_input=$(wims_read_parm[1])
29
slib_input=!declosing $slib_input
30
slib_input=!replace internal , by . in $slib_input
31
!if comma isin $wims_read_parm
13902 bpr 32
  slib_point=,
4701 bpr 33
!endif
34
!default slib_point=.
20 reyssat 35
 
15402 bpr 36
slib_sep=$ $
13902 bpr 37
!if tex isin $wims_read_parm
38
  slib_sep=\:
39
!else
15402 bpr 40
  !if html isin $wims_read_parm
41
    slib_sep= 
42
  !endif
13902 bpr 43
!endif
4701 bpr 44
slib_test=$[$slib_input]
45
!if NaN isin $slib_test
13585 bpr 46
  slib_out=NaN
47
  !exit
20 reyssat 48
!endif
18396 bpr 49
!if e isin $slib_input or E isin $slib_input
50
  !set slib_input=!exec pari $slib_input
51
!endif
52
!!does not work always !!
20 reyssat 53
!if e isin $slib_input
13585 bpr 54
  slib_out=$slib_input
55
  !exit
20 reyssat 56
!endif
4701 bpr 57
slib_input=!nospace $slib_input
58
slib_decomp=!replace internal . by , in $slib_input
59
slib_part=!item 1 of $slib_decomp
60
slib_nbchi=!charcnt $slib_part
61
slib_nbgrp=$[floor($slib_nbchi/3)]
20 reyssat 62
slib_out=$empty
4701 bpr 63
!ifval $slib_nbgrp*3!=$slib_nbchi
13585 bpr 64
  slib_out=!char 1 to $[$slib_nbchi-3*$slib_nbgrp] of $slib_part
20 reyssat 65
!endif
7692 bpr 66
!for slib_i=0 to $slib_nbgrp-1
13585 bpr 67
  slib_tmp=!char $[$slib_nbchi-3*($slib_nbgrp-$slib_i)+1] to $[$slib_nbchi-3*($slib_nbgrp-$slib_i-1)] of $slib_part
13902 bpr 68
  slib_out=$slib_out$slib_sep$slib_tmp
4701 bpr 69
!next slib_i
20 reyssat 70
 
4701 bpr 71
slib_tst=!itemcnt $slib_decomp
18396 bpr 72
!if $slib_tst=1 or $(slib_decomp[2])=0
13585 bpr 73
  slib_out=!singlespace $slib_out
74
  !exit
20 reyssat 75
!endif
4701 bpr 76
slib_part=!item 2 of $slib_decomp
77
slib_nbchi=!charcnt $slib_part
78
slib_nbgrp=$[ceil($slib_nbchi/3)]
79
slib_tmp=!char 1 to 3 of $slib_part
80
slib_out=$(slib_out)$slib_point$slib_tmp
7692 bpr 81
!for slib_i=1 to $slib_nbgrp
13585 bpr 82
  slib_tmp=!char $[1+3*($slib_i)] to $[3+3*$slib_i] of $slib_part
13902 bpr 83
  slib_out=$slib_out$slib_sep$slib_tmp
4701 bpr 84
!next slib_i
85
 
7692 bpr 86
slib_out=!singlespace $slib_out
13902 bpr 87
 
88
!reset slib_input slib_point slib_decomp slib_sep slib_test slib_part slib_nbchi slib_nbgrp slib_tmp