Previous: Getting resource data
Up: Object Resources
Previous Page: Getting resource data
Next Page: An Example
A resource block may be easily modified if the modification does not change it's length - one can simply get the pointer to a resource and overwrite the contents.
If the length of the resource has to be changed, then ids_get_res should be called to get the pointer to the resource and this is followed by a call to ids_rpl_res.
pnt = ids_rpl_res(pnt,nwords,data,ierr)
ids_rpl_res returns the new pointer to a resource. If nwords>0 then nwords words are copied from data, if nwords<0 then nothing is copied but the memory is allocated and the pointer is returned.
Access to resources - an example
subroutine ds_setcl(name,ivdsn,class,itype,ierr) * * ******************************************************************** * * * *$$ * subroutine ds_setcl Set object class and type. * * * Object must be defined already. * * * Input: * * * name - character - object name * * * ivdsn - integer - object handle * * * class - character - class ident (may be with parentage) * * * itype - integer - object type (lt 32000) * * * ierr - integer - error code: * * * 0 - OK * * * Output: * * * ivdsn - integer - correct handle * * * * * * Ryszard Zybert Apr 13 15:13:57 1994 * * ******************************************************************** * character*(*) name character*(*) class character*16 cls(10)structure /cl_typ/ union map integer*2 class integer*2 type end map map integer cl_type end map end union end structure record /cl_typ/ ct structure /cl_res/ integer class character*16 name end structure record /cl_res/ cl pointer ( cl_p,cl )
.... .... .... ! Now deal with ancestry
call dsfldc(class,cls,n,'.') ! parse class into cls array if( n.gt.0 ) then isk = 0 cl_p = ids_get_res(name,ivdsn,'PRTG',isk,nw,ierr) ! is there parentage resource? if( cl_p.eq.0 ) then cl_p = ids_add_res(name,ivdsn,'PRTG',-n*5,0,ierr) ! if not - make one else cl_p = ids_rpl_res(cl_p,-n*5,0,ierr) ! if yes - replace it endif if( cl_p.eq.0 ) go to 990 do i=n,1,-1 ! write ancestry into resource cl.class = ids_nclass(cls(i)) ! convert class to a number cl.name = cls(i) ! store the class name cl_p = cl_p + 20 enddo endif
990 continue call ds_error('DS_SETCL',name,ierr,idum)
999 end