【问题标题】:Null parameter passed to skip list传递给跳过列表的空参数
【发布时间】:2019-01-08 21:07:53
【问题描述】:

第 50 行和第 89 行出现“空跳过参数已传递到参数位置 1”错误,我想将目标/源模块名称放入跳过列表中。我知道循环只有在存在输出/输入链接(分别)时才会执行,那么它怎么会有一个空参数呢?我还检查模块名称是否为空,但检查不会弹出错误框。两个循环都针对一定数量的对象执行,然后在到达它不喜欢的特定点时停止。任何提示将不胜感激。

  /*
Counts the number of non-obsolete requirements in a module and generates a count of number of objects with in/out links, organized by module name. Output is to a CSV file.

*/

pragma runLim, 0        //turn off timeout dialog
filtering off
Module m = current

/***********************
    populateBuffer
************************/
void populateBuffer(Buffer &b)
{
    Object o = null
    Link l
    LinkRef lr
    ModName_ srcMod
    ModName_ tarMod
    string targetMod
    string sourcMod
    int count = 0
    int outTotal = 0
    int inTotal = 0 
    int i = 0
    int n = 0

Skip OinLinks = createString
Skip OoutLinks = createString
Skip MinLinks = createString
Skip MoutLinks = createString
Skip OutOrphans = create        //list of object abs nos which do not have any out links
Skip InOrphans = create     //list of object abs nos which do not have any in links

string s = ""

for o in m do   
{
    if ((o."URB Object Type" "" == "Requirement") && (o."TIS Status" "" != "Obsolete")) //always cast an attribute value as a string with empty quotes
    {
        for l in o->"*" do //for out links
        {
            tarMod = target(l)
            targetMod = name(tarMod)  //puts the target module of the current link into a string
            if (null targetMod) {errorBox "FAILURE FINDING TARGET MODULE!"; halt}
            print targetMod "\n"
            put(OoutLinks, targetMod, count + 1)        //puts all of the targetMods into the OoutLinks skip list
            n++ 
        }
            if (n > 0) //check if this object has outlinks
            {
                for count in OoutLinks do//for each unique outlink target module of the current object
                {
                    if (find(MoutLinks, targetMod, i)) //if there is already a matching entry
                    {
                        delete(MoutLinks, targetMod) //remove the entry for that particular module name
                        put(MoutLinks, targetMod, i+1) //and re-enter it with count+1 in module level skip list
                    }
                    else {put(MoutLinks, targetMod, 1)} //if it is a new entry, add it with count 1
                }
            }
            else //if there are no outlinks,
            {
                int absno = o."Absolute Number"
                put(OutOrphans, absno, 1)       //This adds the absno of the current object to 
                                                //our orphan list
            }
            n = 0

        for lr in o <-"*" do //for in links
        {
            sourcMod = name(source lr)  //puts the source module of the current link into a string
            if (null sourcMod) {errorBox "FAILURE FINDING SOURCE MODULE!"; halt}
            print sourcMod "\n"
            print "Source Modules \n"
            put(OinLinks, sourcMod, count + 1)      //puts all of the sourcMods into the OinLinks skip list
            n++ 
        }
            if (n > 0) //check if this object has inlinks
            {
                for count in OinLinks do//for each unique inlink target module of the current object
                {
                    if (find(MinLinks, sourcMod, i)) //if there is already a matching entry
                    {
                        delete(MinLinks, sourcMod) //remove the entry for that particular module name
                        put(MinLinks, sourcMod, i+1) //and re-enter it with count+1 in module level skip list
                    }
                    else {put(MinLinks, sourcMod, 1)} //if it is a new entry, add it with count 1
                }
            }
            else //if there are no inlinks,
            {
                int absno = o."Absolute Number"
                put(InOrphans, absno, 1)        //This adds the absno of the current object to 
                                                //our orphan list
            }           


        delete(OinLinks)        //reset the OinLinks list so we can start fresh for the next object     
        delete(OoutLinks)       //reset the OoutLinks list so we can start fresh for the next object        

        n = 0
    }

    else continue
}
} /************************************ MAIN *************************************/
string fName = "C:/Temp/LinkedObjectsInventory_Jan8.csv"
Stream outfile = write(fName)
Buffer b = create
populateBuffer(b)
outfile << b
close(outfile)
delete(b)
// notify the user that the script is complete
ack "Inventory Complete."

【问题讨论】:

    标签: ibm-doors


    【解决方案1】:

    这是一个非常简单的问题-

    我要做的改变——替换这个:

    delete(OinLinks)        //reset the OinLinks list so we can start fresh for the next object     
    delete(OoutLinks)       //reset the OoutLinks list so we can start fresh for the next object     
    

    用这个:

        for count in OinLinks do //reset the OinLinks list so we can start fresh for the next object     
        {
            delete ( OinLinks , ( string key OinLinks ) )
        }
    
        for count in OoutLinks do //reset the OoutLinks list so we can start fresh for the next object
        {
            delete ( OoutLinks , ( string key OoutLinks ) )
        }
    

    作为 for each object 循环的一部分,您删除了整个跳过列表,而不是清空它。这意味着在随后的循环中,程序找不到 Skip 列表并引发错误。重复使用跳过而不是每次都重新分配它们很好,但是您必须清空内容而不是在跳过句柄上调用 delete。

    祝你好运,如果您有其他问题,请告诉我!

    【讨论】:

    • 谢谢拉塞尔。我按照建议进行了更改,但现在对于每个包含 PUT 函数的 FOR 循环,我都得到了“(do) 的错误参数”。
    • 实际上我已经运行了它,因为我做了一个额外的更改,而不是循环通过每个输出/输入链接中的目标/源模块名称,我需要循环通过每个链接。你知道为什么一个有效而另一个无效吗?例如:` for l in o-> "" do { tarMod = target(l) put(OoutLinks, targetMod, count + 1) ` 有效,但无效:` for targetMod in o->"" do { put(OoutLinks, targetMod, count + 1) `
    • 您在上面发布的代码循环遍历对象中的每个链接。如果您尝试使用 'for targetMod in o' ,则您正尝试在寻找链接参数的 for 循环中使用字符串。注意:这是您对传入链接所做的事情 - run 'for string_mod_name in o
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多