Hello everyone! I'm trying to run a script which should work like this: it loads a configuration file(the path and the name of all target modules that has to be checked), then it veirifies, going by like if an attribute exists in the target module(this module exist in the configuration list, if it doesn't, then it must be ignored) and after, it should bring its value in the current module. Right now, my script verifies all of the target modules, even if the modules doesn't exist in the conf. list. I tried to put the configuration list in a skiplist, and then to check: " for strModuleName in skiplist do( " and it runs, but it prints that: 0 attribute changed.
void callbackLoadCfg(DBE calledfrom) { }
Module GetModule(string strModName) {
void Copy(DBE calledfrom)
print "The number of changed attributes is " AttrChanged "\n"
It is really urgent and i don't have any idea how to solve this. Thank you! Anamaria/ System Requirement - Thu Oct 13 01:51:41 EDT 2016 |
Re: Verify if an attribute exists in all target modules using a configuration file That code seems buggy. Take this loop:
...
while(!end(inFile)) {
inFile >> strBuff
if(strBuff != "") {
PrintOut("Module: " strBuff)
strModules[intModulesCnt++] = strBuff
skipModulelist=create // will recreate the skip list every time?
put(skipModulelist,1,strBuff )
}
}
...
later it loops over the skip list, but it will find at most one module in there ..: for mod_name in skipModulelist do ... Are you the developer of the script? If not you should maybe contact the developer to fix it. Regards, Mathias
|
Re: Verify if an attribute exists in all target modules using a configuration file - the structure is a little unclear, I am not sure when GetModule is called and where your variables are declared and initialized. And there is a lot of code which has no effect at all, e.g. the code concerning variable "filename". You declare it and put some content in it - just for nothing. - then there are several problems with your loops. I suggest that you go back one step and draw a picture of what you want to do using pen and paper. Especially draw a square box for the variables and ask yourself what shall be stored, when the information is needed, what is the scope of the variable. Perhaps this will assist you. Then clean up your code or rewrite it. Add more prints to follow your code (or use a debugger). - One of the most obvious problems is your treatment of skipModuleList. You should create() it at the beginning of your script or at least before you open the config file..In the current code you create() it every time you find a new module name in your config file -> so you erase the previous content all the time you find a second module. And for the key of the skip entry you use 1 all the time. which also means that you store every entry for every module at the same place. use the name of the module as key, like this "put(skipModulelist,strBuff,strBuff )". Then in your Copy code, you will most likely not want to loop through your skip list but you just want to know whether the module is included in it. For this, you can use the "find" command. - o-> "path" does not look right. Are you sure that your link module name has the name "path"?
There are more problems, but I do not have the time to completely rewrite the code. Perhaps the suggestions above help a little bit.. |