Skip to content
Snippets Groups Projects
Commit a44426cd authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Merge branch 'mlong/importcfg2' into 'master'

Make it possible to import xtrn and xtrnsec from another system (with different indexes)

See merge request !106
parents 076d6f05 88263e4a
No related branches found
No related tags found
2 merge requests!463MRC mods by Codefenix (2024-10-20),!106Make it possible to import xtrn and xtrnsec from another system (with different indexes)
......@@ -117,19 +117,52 @@ if(!cnf) {
alert("Failed to read " + cnf_fname);
exit(-1);
}
writeln("Backing up " + cnf_fname);
file_backup(cnf_fname,15);
if (cnf_obj == 'xtrn') {
var secs = {};
for (var i in cnf['xtrnsec']) {
secs[cnf['xtrnsec'][i]['code'].toUpperCase()] = i;
}
}
for(var i in list) {
var obj = list[i];
var j;
for(j = 0; j < cnf[cnf_obj].length; j++) {
if(cnf[cnf_obj][j].code !== undefined) {
if(cnf[cnf_obj][j].code == obj.code)
if(cnf[cnf_obj][j].code.toUpperCase() == obj.code.toUpperCase())
break;
} else {
if(cnf[cnf_obj][j].name == obj.name)
if(cnf[cnf_obj][j].name.toUpperCase() == obj.name.toUpperCase())
break;
}
}
obj.code = obj.code.toUpperCase();
switch (cnf_obj) {
case 'xtrnsec':
delete obj.number;
delete obj.index;
break;
case 'xtrn':
obj.sec_code = obj.sec_code.toUpperCase();
delete obj.number;
delete obj.index;
delete obj.sec_index;
delete obj.sec_number;
if (typeof secs[obj.sec_code] === "undefined") {
writeln("Could not find section " + obj.sec_code + " for program " + (obj.code || obj.name));
continue;
} else {
obj.sec = secs[obj.sec_code];
}
break;
default:
break;
}
if(j < cnf[cnf_obj].length) {
if(!options.overwrite) {
writeln("Already exists: " + (obj.name || obj.code));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment