Вопрос

I'm trying to get to the attributes in the inlinks and outlinks of multiple objects and my goal is to not re-reading the same module again by storing the read module in a skip list and checking the skip list before reading the module next time around.

So my question is how do I get to the data of a module name I've stored in the skip list if it's already opened previously? Will the line m2 = module item str2 be sufficient to replace the read function if that module was opened previously?

Below is my attempt to get the attributes of the inlinks of an object:

Skip sInlink = create()

void get_object_inlinks (Object obj)
{
   string str, str2
   LinkRef lk = null
   Object o = null

   for lk in all (obj <- "*") do
   {
     ModName_ mn = source(lk)
     str = fullName(mn)
     if (!find(sInlink, str, str2))
     {
        m2 = read(str, false)
        put(sInlink, str, str)
     }
     else
        m2 = module item str2

     if (m2 != null)
     {
        o = gotoObject(sourceAbsNo(lk), m2)
        // get object o attributes
        ...
     }
   }
}
Это было полезно?

Решение

Is there a reason you don't want to re-read the module? Once the module is open, reading it again doesn't re-open the module unless you are closing it each time.

However an alternative is to store the module handle in the skip list instead of the module name.

put(sInlink, str, m2)

Then instead of:

if(!find(sInlink, str, str2))

use:

if(!find(sInlink, str, m2))

If str is found it will put the module handle in m2, if not you can continue with your read as you are doing.

And just in case you don't already have this, you should loop through the skip list and close all the modules at the end of your code.

for m2 in sInlink do
{
  if(!null m2) close m2
}

Good luck!

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top