Subversion Repositories wimsdev

Rev

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

Rev Author Line No. Line
12569 bpr 1
!! updatefield of a record
2
!! wims_read_parm should be by line :
3
!! file
4
!! num of field
5
!! optionword
6
!! all other lines : new data for the field num
7
!!
8
!! option allow :
9
!! delete : in this case field num will be deleted
10
!! sort according the line num of each record
11
!! so the new data will be in this case at the end at the first step
12
 
13
file_=!line 1 of $wims_read_parm
14
num_=!line 2 of $wims_read_parm
15
option_=!line 3 of $wims_read_parm
16
data_=!line 4 to -1 of $wims_read_parm
17
nbrec_=!recordcnt $file_
18
newrecord_=$empty
19
!if $option_=sort
20
  !!list of items to sort
21
  !reset tmp_to_sort
22
  !for k_=1 to $nbrec_
23
    tmp_=!record $k_ of $file_
24
    tmp_=!line $num_ of $tmp_
25
    tmp_to_sort=!append line $tmp_ to $tmp_to_sort
26
  !next
27
  tmp_to_sort=!sort line $tmp_to_sort
28
  !for k_=1 to $nbrec_
14335 bpr 29
    tmp_=!record $(wims_sort_order[$k_]) of $file_
30
    newrecord_=!append line :$tmp_ to $newrecord_
12569 bpr 31
  !next k_
32
  !goto end
33
!endif
34
 
35
!if $num_>1
36
  !for k_=1 to $num_-1
14335 bpr 37
    tmp_=!record $k_ of $file_
38
    newrecord_=!append line :$tmp_ to $newrecord_
12569 bpr 39
  !next k_
40
!endif
41
!if delete notwordof $option_
42
  newrecord_=!append line :$data_ to $newrecord_
43
!endif
44
!if $num_<$nbrec_
45
  !for k_=$num_+1 to $nbrec_
14335 bpr 46
    tmp_=!record $k_ of $file_
47
    newrecord_=!append line :$tmp_ to $newrecord_
12569 bpr 48
  !next k_
49
!endif
50
:end
51
!writefile $file_ $newrecord_