Skip to content

Instantly share code, notes, and snippets.

@cKlee
Created March 16, 2015 10:09
Show Gist options
  • Save cKlee/aefc406f0e02b7b4f874 to your computer and use it in GitHub Desktop.
Save cKlee/aefc406f0e02b7b4f874 to your computer and use it in GitHub Desktop.
WinIBW3 Skript Unterfeld ergängen $nElektronische Ressource
function setBearbeiten()
{
var csv = new CSV();
csv.__csvSetLogFilename("LOG_ergERessource.txt");
var setSize = application.activeWindow.getVariable("P3GSZ");
i = 1;
do {
__setBearbeitenUnterfeldErg(i,csv,"p","021A","$nElektronische Ressource");
i++;
} while (i <= setSize)
}
function __setBearbeitenUnterfeldErg(iterator,csv,format,feld,unterfeld)
{
// edit record
try
{
application.activeWindow.command("k " + iterator + " " + format,false);
var idn = application.activeWindow.getVariable("P3GPP");
}
catch(e)
{
csv.__csvLOG("\tDatensatz kann nicht geoeffnet werden.\nFehlermeldung: " + e);
return;
}
if (application.activeWindow.status != "ERROR")
{
var y = 0;
var cont;
var ind, ind2;
while((application.activeWindow.title.findTag2(feld, y, true, true, false) != "") ){
cont = application.activeWindow.title.currentField;
ind = cont.indexOf("$d");
ind2 = cont.indexOf("$f");
ind3 = cont.indexOf("$h");
if(ind != -1)
{
application.activeWindow.title.charRight(ind,false);
}
else if(ind2 != -1)
{
application.activeWindow.title.charRight(ind2,false);
}
else if(ind3 != -1)
{
application.activeWindow.title.charRight(ind3,false);
}
else
{
application.activeWindow.title.endOfField(false);
}
// inert new field content
application.activeWindow.title.insertText(unterfeld);
y++;
}
// save buffer
return csv.__csvSaveBuffer(true,"Ergaenzungen: " + y);
} else {
// return undone but write error to a log file
return csv.__csvSaveBuffer(false,"\tDatensatz kann nicht geoeffnet werden. Status = ERROR.");
}
} // end of method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment