File: uprecord

package info (click to toggle)
wims 2%3A4.29a%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 185,704 kB
  • sloc: xml: 366,687; javascript: 120,570; ansic: 62,341; java: 62,170; sh: 7,744; perl: 3,937; yacc: 3,217; cpp: 1,915; lex: 1,805; makefile: 1,084; lisp: 914; pascal: 601; python: 520; php: 318; asm: 7
file content (63 lines) | stat: -rw-r--r-- 1,506 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
!!!### langage independant
!!
# wims_read_parm is file to update
# update_field is number of field to update (could be 0)
# update_content is the new content of the field
# update_nbline is the number of line of each field (format field to the good number of line : do nothing if empty)

scnt_=!recordcnt $wims_read_parm
!if $update_field<0 or $update_field>$scnt_+1
  error=badfile
  !exit
!endif

!if $update_nbline!=$empty
  blfield_=$empty
  !for k_=1 to $update_nbline
   blfield_=$blfield_\
$empty
  !next k_
!else
  blfield_=$empty
!endif

!! ------------- add a field
!ifval $update_field=$scnt_+1
  !ifval $update_nbline!=$empty
    data_=:$update_content\
$blfield_
    data_=!line 1 to $update_nbline of $data_
  !else
    data_=:$update_content
  !endif
  !appendfile $wims_read_parm $data_
  !exit
!endif

!! ------------- modify a field
!! ----- keep old field
!for s_=0 to $scnt_
  field$(s_)_=!record $s_ of $wims_read_parm
  !if $update_nbline!=$empty
    field$(s_)_=!line 1 to $(update_nbline) of $(field$(s_)_)\
$blfield_
  !endif
!next s_
!! ----- make new field
field$(update_field)_=$update_content
!if $update_nbline!=$empty
  field$(update_field)_=!line 1 to $(update_nbline) of $(update_content)\
$blfield_
!else
  field$(update_field)_=$update_content
!endif

!! ----- save to file
data_=$(field0_)\
$empty
!for k_=1 to $[max($scnt_,$update_field)]
  data_=$data_:$(field$(k_)_)\
$empty
!next k_
!writefile $wims_read_parm $data_
!reset update_field,update_content,update_nbline