/* set the current module for symbol references, making sure current_module reflects the desired module and opening a new symfile if necessary %include 'symswitch.inc' for the proper entry declaration */ symswitch: procedure(newmodule); dcl newmodule fixed bin(23); /*fileaddr of module hash record*/ %include 'workdef.pli'; %include 'symdef.pli'; /*for symfile*/ %include 'moddef.pli'; %include 'cantopen.inc'; %include 'truefalse.inc'; dcl oldsymfilename char(31) varying, oncode builtin; /**************************************************************************************************************/ if any_symscan & (newmodule ^= current_module.hash_fileaddr) & (current_module.hash_fileaddr ^= null_fileaddr) then do; call workpos(current_module.data_fileaddr, scratch_workp); write file(workfile) from(current_module); end; if newmodule = null_fileaddr then do; call error('you must do a SET MODULE in order to access symbols in this procedure'); nullit: current_module.hash_fileaddr = null_fileaddr; return; end; if newmodule = current_module.hash_fileaddr then return; /*desired module is already current*/ if newmodule = setting_module then goto nullit; /*if doing a SET MODULE, we only write out current_module record, let set module code do the rest*/ oldsymfilename = symfilename; call workgrab(newmodule, scratch_workp); read file(workfile) into(current_module); any_symscan = false; if symfilename ^= oldsymfilename then do; on undefinedfile(symfile) begin; current_module.hash_fileaddr = null_fileaddr; call error(cantopen(symfilename, oncode)); end; close file(symfile); open file(symfile) title(symfilename); end; end;