Das zugehörige Testprogramm.
Code: Alles auswählen
$.evalFile( File(File(findFile(null).path)+'/JavaScriptStringClassEnhancements.jsxbin') );
main()
function main()
{
alert("*!".fill(33));
alert("!" + " Walter ".trim()+"!");
alert("!" + " Walter ".lTrim()+"!");
alert("!" + " Walter ".rTrim()+"!");
alert("Walter".padLeft("-",30));
alert("Walter".padRight("-",30));
// string ausgabe mit Variablen
alert("Der {0} Test mit der {1} Erweiterung. Der {0} Versuch hat geklappt".format("erste", "siebten"));
}
function findFile(filePath)
{
var scriptFolder = File(getScriptPath()).path;
if (scriptFolder== null) filePath = File.openDialog(openFileDialogTitle);
else if(File(File(getScriptPath()).path + filePath).exists == false)
{
filePath = File.openDialog("Datei wählen");
}
return filePath;
}
function getScriptPath()
{
try
{
file = app.activeScript;
}
catch(error)
{
return null;
}
return file;
}