Subversion Repositories wimsdev

Rev

Rev 15772 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

$techvar=$[$techvar*1]
nblocalvar=!itemcnt $tv_listlocal
!if ($techvar<1 or $techvar>$nblocalvar)
  error=badtechvarnumber
  job=listvar
  !changeto $job.proc
  !exit
!endif

!if $stechvar=$empty
  stechvar=$techvar
  !reset tc_abandon,tc_set
  don=!record $stechvar of wimshome/log/classes/$wims_class/.techvar
  !distribute line $don into ol_name,ol_value
  tc_name=$ol_name
  tc_value=$ol_value
!endif

!if $tc_abandon!=$empty
  !reset tc_abandon,tc_value,tc_name,tc_set,stechvar
  job=listvar
  !changeto $job.proc
  !exit
!endif

!! -------- makelist of variable can be deleted (not in use in the structure by any participant
!if / isin $wims_class
  cls=$wims_superclass
!else
  cls=$wims_class
!endif
code=!item $stechvar of $tv_listlocalcode
nbol=!itemcnt $ol_value
flags=!values 0 for v=1 to $nbol
u=1
nbu=!recordcnt wimshome/log/classes/$cls/.userlist
flagcnt=0
!while $u<=$nbu and $flagcnt<$nbol
  l=!record $u of wimshome/log/classes/$cls/.userlist
  l=!item 3 of $l
  tmp=!defof user_techvar_$code in wimshome/log/classes/$cls/.users/$l
  !if $tmp!=$empty
    p=!positionof item $tmp in $ol_value
    !if $(flags[$p])=0
      flags=!replace item number $p by 1 in $flags
      !increase flagcnt
    !endif
  !endif
  !increase u
!endwhile
!reset del_values
!for k=1 to $nbol
  !if $(flags[$k])=0
    del_values=!append item $(ol_value[$k]) to $del_values
  !endif
!next k

!if $tc_set!=$empty
  !! check name validity
  tc_name=!text select 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ in $tc_name
  tc_name=!nospace $tc_name
  tc_name=!lower $tc_name
  n=!charcnt $tc_name
  !if $n>$MAXcharname or $n<1
    error=badnamelen
    !reset tc_set
    !exit
  !endif

  !! check list of name already in use
  !if $tc_name isitemof $tv_listallname and $tc_name!=$ol_name
    error=namealreadyuse
    !reset tc_set
    !exit
  !endif

  !! check list of value
  tc_value=!listuniq $tc_value
  tc_value=!listcomplement _EMPTY_,EMPTY,EMPTY_,_EMPTY in $tc_value
  n=!itemcnt $tc_value
  !if $n<1 or $n>$MAXnbvalue
    error=badvaluenb
    !reset tc_set
    !exit
  !endif

  !! old list must be include (or delete value not in use in the class TODO).
  !! il y a une amélioration à faire pour poster un message et effacer les valeurs qui ne sont plus disponibles.
  li=!listcomplement $tc_value in $ol_value
  li=!listcomplement $del_values in $li
  !if $li!=$empty
    error=valuedisappear
    tc_value=$ol_value
    !reset tc_set
    !exit
  !endif

!! --------- save new data
  donnees=$empty
  !for k=1 to $nblocalvar
    !if $k=$stechvar
      donnees=!append line :$tc_name\
$tc_value to $donnees
    !else
      tmp=!record $k of wimshome/log/classes/$wims_class/.techvar
      donnees=!append line :$tmp to $donnees
    !endif
  !next k
  !filewrite wimshome/log/classes/$wims_class/.techvar $donnees
  !if $ol_name!=$tc_name
    nb=!recordcnt wimshome/log/classes/$tv_Sclass/.indextechvar
    donnees=$empty
    !for k=1 to $nb
      tmp=!record $k of wimshome/log/classes/$tv_Sclass/.indextechvar
      !if $(tmp[2])=$wims_class and $(tmp[3])=$stechvar
        donnees=!append line :$tc_name,$wims_class,$stechvar to $donnees
      !else
        donnees=!append line :$tmp to $donnees
      !endif
    !next k
    !filewrite wimshome/log/classes/$tv_Sclass/.indextechvar $donnees
  !endif
  !restart module=adm/class/techvar
!endif