Topic
  • 3 replies
  • Latest Post - ‏2019-05-24T17:55:46Z by llandale
Christopher Cote
Christopher Cote
67 Posts

Pinned topic Error: null Attribute Def do loop parameter was passed

‏2019-05-23T17:20:22Z |

I have a loop within another loop that is supposed to get all the non-system attributes of each module in a project.  However, I'm getting the error in the title of this post.  Here is the pared down version of the script I'm trying to run:

AttrDef ad;
Module currMod = current Module;        //Set just to initialize the variable

for itemRef in current Project do {
    if (type(itemRef) == "Formal") {
        modName = fullName(itemRef);
        skAttrs = create;   //skAttrs is defined as a skip list above this
        
        currMod = module(itemRef);
        
        for ad in currMod do {
            if (!ad.system) {
                put(skAttrs, ad.name"", 0);
            }
        }
    }
}

The error I'm getting is happening in line 10 (for ad in currMod do), but I think the problem is 2 lines above where I'm assigning the module to currMod.  I've never seen this error before, so I don't know how to fix it.  I'm hoping someone out there has seen this error and can help me out.  I'd REALLY appreciate it.

 

Chris

  • PekkaMakinen
    PekkaMakinen
    208 Posts
    ACCEPTED ANSWER

    Re: Error: null Attribute Def do loop parameter was passed

    ‏2019-05-23T17:35:16Z  

    Module has to be open to access the attributes if you are looping with AttrDef in Module loop.

    "currMod = module(itemRef);" does not open the module, it just gives you a module handle of ModName_ type

    "currMod = read(modName)" would open the module and give a a module handle of Module type which you need for that loop.

     

  • PekkaMakinen
    PekkaMakinen
    208 Posts

    Re: Error: null Attribute Def do loop parameter was passed

    ‏2019-05-23T17:35:16Z  

    Module has to be open to access the attributes if you are looping with AttrDef in Module loop.

    "currMod = module(itemRef);" does not open the module, it just gives you a module handle of ModName_ type

    "currMod = read(modName)" would open the module and give a a module handle of Module type which you need for that loop.

     

  • Christopher Cote
    Christopher Cote
    67 Posts

    Re: Error: null Attribute Def do loop parameter was passed

    ‏2019-05-23T19:13:13Z  

    Module has to be open to access the attributes if you are looping with AttrDef in Module loop.

    "currMod = module(itemRef);" does not open the module, it just gives you a module handle of ModName_ type

    "currMod = read(modName)" would open the module and give a a module handle of Module type which you need for that loop.

     

    Thank you very much Pekka.

  • llandale
    llandale
    3083 Posts

    Re: Error: null Attribute Def do loop parameter was passed

    ‏2019-05-24T17:55:46Z  

    Yes, open the module.  currMod is null at line 11.

    Nit-Picks:

    Line 2 is confusing as it implies this script works on a current module when it does not.  Initialize it to null

    Line7: I notice that at line 13 you "put" a string as KEY of the skip (the name of the attribute).  Therefore this line 7 should be "skpAttrs = createString()".  You can expect strange errors using this Skip if not.

    Line 7 creates the Skip; surely you want a corresponding delete(skpAttrs) above line 16.  That's good programming practice even it if doesn't matter for this small script.

    Line 13: probably better to put the "ad" as the DATA of the Skip.  Using it later (invisible code between lines 15 and 16) will often be easier.

    -Louie