Page History
...
The following sample program fragment illustrates the essentials of constructing and using a media map handle. The technique illustrated here works with media maps for ROS and Linear Hash files (RTP51 and RTP57), installing the MFS MYMFS.MFS on the TESTFILE table.
Code Block |
---|
declare subroutine fsmsg , attach_table, msg OPEN 'SYSTABLES' TO FILES.FILE ELSE fsmsg() return end OPEN 'SYSVOLUMES' TO VOLUMES.FILE ELSE fsmsg() return end FILENAME = 'TESTFILE' MFS.NAME = 'MYMFS.MFS' READ FILES.REC FROM FILES.FILE, FILENAME ELSE fsmsg() return END VOLUME.NAME = FILES.REC<1> ; * get the name of the volume READ VOLUME.REC FROM VOLUMES.FILE, VOLUME.NAME ELSE fsmsg() return END * construct the file handle for the REVMEDIA map in question MEDIA.HANDLE = VOLUME.REC<4> : @VM : VOLUME.REC<5> * construct the key (file.name*account.name) for the file. * this information is stored in the SYSTABLES file MEDIA.MAP.KEY = FILES.REC<2> :"*": FILES.REC<3> * update the media map entry with the MFS info. MFS lists are * stored as the 2nd attribute of the media map entry for a file READ MEDIA.MAP.REC FROM MEDIA.HANDLE, MEDIA.MAP.KEY THEN * put new MFS name on front of existing MFS list OLD.MFS.LIST = MEDIA.MAP.REC<2> NEW.MFS.LIST = MFS.NAME : @VM : OLD.MFS.LIST MEDIA.MAP.REC<2> = NEW.MFS.LIST WRITE MEDIA.MAP.REC TO MEDIA.HANDLE, MEDIA.MAP.KEY ELSE fsmsg() return END * reattach file to update SYSTABLES entry Attach_Table(FILES.REC<1>,FILES.REC<2>,'','') END ELSE MSG(@window, "Cannot read ":MEDIA.MAP.KEY,'') return END ; * read media.map rec RETURN 0 |