Rev 15640 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
14297 | guerimand | 1 | !!!### langage independant |
2 | !! |
||
3 | # wims_read_parm is file to update |
||
4 | # update_field is number of field to update (could be 0) |
||
5 | # update_content is the new content of the field |
||
6 | # update_nbline is the number of line of each field (format field to the good number of line : do nothing if empty) |
||
7 | |||
8 | scnt_=!recordcnt $wims_read_parm |
||
9 | !if $update_field<0 or $update_field>$scnt_+1 |
||
10 | error=badfile |
||
11 | !exit |
||
12 | !endif |
||
13 | |||
14 | !if $update_nbline!=$empty |
||
15 | blfield_=$empty |
||
16 | !for k_=1 to $update_nbline |
||
17 | blfield_=$blfield_\ |
||
18 | $empty |
||
19 | !next k_ |
||
20 | !else |
||
17665 | bpr | 21 | blfield_=$empty |
14297 | guerimand | 22 | !endif |
23 | |||
24 | !! ------------- add a field |
||
25 | !ifval $update_field=$scnt_+1 |
||
26 | !ifval $update_nbline!=$empty |
||
27 | data_=:$update_content\ |
||
28 | $blfield_ |
||
29 | data_=!line 1 to $update_nbline of $data_ |
||
30 | !else |
||
31 | data_=:$update_content |
||
32 | !endif |
||
33 | !appendfile $wims_read_parm $data_ |
||
34 | !exit |
||
35 | !endif |
||
36 | |||
37 | !! ------------- modify a field |
||
38 | !! ----- keep old field |
||
39 | !for s_=0 to $scnt_ |
||
40 | field$(s_)_=!record $s_ of $wims_read_parm |
||
41 | !if $update_nbline!=$empty |
||
42 | field$(s_)_=!line 1 to $(update_nbline) of $(field$(s_)_)\ |
||
43 | $blfield_ |
||
44 | !endif |
||
45 | !next s_ |
||
46 | !! ----- make new field |
||
47 | field$(update_field)_=$update_content |
||
15640 | guerimand | 48 | !if $update_nbline!=$empty |
49 | field$(update_field)_=!line 1 to $(update_nbline) of $(update_content)\ |
||
50 | $blfield_ |
||
51 | !else |
||
52 | field$(update_field)_=$update_content |
||
53 | !endif |
||
54 | |||
14297 | guerimand | 55 | !! ----- save to file |
56 | data_=$(field0_)\ |
||
57 | $empty |
||
58 | !for k_=1 to $[max($scnt_,$update_field)] |
||
59 | data_=$data_:$(field$(k_)_)\ |
||
60 | $empty |
||
61 | !next k_ |
||
62 | !writefile $wims_read_parm $data_ |
||
17665 | bpr | 63 | !reset update_field,update_content,update_nbline |