Im a complete noob at javascript...ive been reading some tutorials and stuff..but its not enough!
what im trying to accomplish here is to have a drop down menu for opening the selected file.
var myDialog = app.dialogs.add({name:"Iconos Travelplan", canCancel:true});
with(myDialog){
with(dialogColumns.add()){
with(borderPanels.add()){
with(dialogColumns.add()){
staticTexts.add({staticLabel:"Selecciona una biblioteca:"});
}
with(dialogColumns.add()){
var myIcons = dropdowns.add({stringList:
["Iberrail","Costas","Teletipos"], selectedIndex:0});
if(myDialog.show() == true){
var Iberrail = app.open(File("/c/iberrail.indl"), false);
var Costas = app.open(File("/c/costas.indl"), false);
var Teletipos = app.open(File("/c/teletipos.indl"), false);
}
}
}
}
}
myDialog.destroy();
Hey!
Here is my solution. Maybe there is some other ways too..
var myFiles = Array(
["Iberrail","Costas","Teletipos"], // names in list box
["/c/iberrail.indl","/c/costas.indl","/c/teletipos.indl"] // file names
);
var myDialog = app.dialogs.add({name:"Iconos Travelplan", canCancel:true});
with(myDialog){
with(dialogColumns.add()){
with(borderPanels.add()){
with(dialogColumns.add()){
staticTexts.add({staticLabel:"Selecciona una biblioteca:"});
}
with(dialogColumns.add()){
var myIcons = dropdowns.add({stringList:myFiles[0], selectedIndex:0});
}
}
}
}
if(myDialog.show() == true){
app.open(File(myFiles[1][myIcons.selectedIndex]),false);
}
myDialog.destroy();
tomaxxi
Hey!
It's me again
I've got good idea how to make it more user friendly...
You just have to insert path where you have your libraries,
and script will automatically fill drop down box with filenames.
You can adjust labels to your wish,
and you can show/hide working folder in dialog too.
var myWorkFolder = Folder("/d/!myWork"); // working folder
var showWorkFolder = Boolean(true); // shows(true)/hides(false) working folder in dialog
var strWinTitle = String("Library opener");
var strWorkFolder = String("Working folder:");
var strSelectLib = String("Select library:");
var strNoFiles = String("-- No libraries found --"); // shows if no libraries found
///////////////////////// SCRIPT /////////////////////////
var myFiles = myWorkFolder.getFiles("*.indl");
var myFilesNo = myFiles.length;
var myLibFiles = Array();
if(!myFilesNo){
myLibFiles[0] = strNoFiles;
}else{
for(var i=0; i < myFilesNo; i++){
myLibFiles.push(myFiles[i].displayName.substr(0,myFiles[i].displayName.lastIndexOf(".")));
}
}
var myDialog = app.dialogs.add({name:strWinTitle, canCancel:true});
with(myDialog){
with(dialogColumns.add()){
if(showWorkFolder){
with(dialogRows.add()){
with(borderPanels.add()){
with(dialogColumns.add()){
staticTexts.add({staticLabel:strWorkFolder});
}
with(dialogColumns.add()){
staticTexts.add({staticLabel:myPath.fsName});
}
}
}
}
with(dialogRows.add()){
with(borderPanels.add()){
with(dialogColumns.add()){
staticTexts.add({staticLabel:strSelectLib});
}
with(dialogColumns.add()){
var myLib = dropdowns.add({stringList:myLibFiles, selectedIndex:0});
}
}
}
}
}
if(myDialog.show() == true){
if(myFilesNo){
app.open(File(myFiles[myLib.selectedIndex]),false);
}
}
myDialog.destroy();
tomaxxi
Hey Kasyan!
Thanks for your reply!
I forgot to change that after variable name change! ![]()
So, here is corrected script:
var myWorkFolder = Folder("/d/!myWork"); // working folder
var showWorkFolder = Boolean(true); // shows(true)/hides(false) working folder in dialog
var strWinTitle = String("Library opener");
var strWorkFolder = String("Working folder:");
var strSelectLib = String("Select library:");
var strNoFiles = String("-- No libraries found --"); // shows if no libraries found
///////////////////////// SCRIPT /////////////////////////
var myFiles = myWorkFolder.getFiles("*.indl");
var myFilesNo = myFiles.length;
var myLibFiles = Array();
if(!myFilesNo){
myLibFiles[0] = strNoFiles;
}else{
for(var i=0; i < myFilesNo; i++){
myLibFiles.push(myFiles[i].displayName.substr(0,myFiles[i].displayName.lastIndexOf(".")));
}
}
var myDialog = app.dialogs.add({name:strWinTitle, canCancel:true});
with(myDialog){
with(dialogColumns.add()){
if(showWorkFolder){
with(dialogRows.add()){
with(borderPanels.add()){
with(dialogColumns.add()){
staticTexts.add({staticLabel:strWorkFolder});
}
with(dialogColumns.add()){
staticTexts.add({staticLabel:myWorkFolder.fsName});
}
}
}
}
with(dialogRows.add()){
with(borderPanels.add()){
with(dialogColumns.add()){
staticTexts.add({staticLabel:strSelectLib});
}
with(dialogColumns.add()){
var myLib = dropdowns.add({stringList:myLibFiles, selectedIndex:0});
}
}
}
}
}
if(myDialog.show() == true){
if(myFilesNo){
app.open(File(myFiles[myLib.selectedIndex]),false);
}
}
myDialog.destroy();
tomaxxi
North America
Europe, Middle East and Africa
Asia Pacific