Hi, everyone,
Please help me to change my script aim to let the dropdown list recall the last selected.
I want to:
let the script do as same as last thing
I have a script as below:
var myDialog = app.dialogs.add({name:"add continueds",canCancel:true});
with(myDialog){
with(dialogColumns.add()){
with(dialogRows.add()){
var mySelection = dropdowns.add({stringList:["Continued", "continued", "Cont'd","cont'd"], selectedIndex:0});
}
}
}
if (myDialog.show() == true)
main();
function main(){
var myObject;
var myCheckSelection = false;
if(app.documents.length > 0){
if(app.selection.length > 0){
switch(app.selection[0].constructor.name){
case "InsertionPoint":
case "Character":
case "Word":
case "TextStyleRange":
case "Line":
case "Paragraph":
case "TextColumn":
case "Text":
case "Cell":
case "Column":
case "Row":
case "Table":
myObject = app.selection[0];
if(app.selection && app.selection[0].hasOwnProperty ("contents") );
addContinueds();
}
}
}
else{
alert("No documents are open or wrong selection. Please try again.");
}
}
function addContinueds() {
if (mySelection.selectedIndex == 0){
app.findGrepPreferences.findWhat = "(.)\\r";
app.changeGrepPreferences.changeTo = "$1 (Continued)\\r";
app.selection[0].changeGrep();
app.findGrepPreferences = app.changeGrepPreferences = null;
}
if (mySelection.selectedIndex == 1){
app.findGrepPreferences.findWhat = "(.)\\r";
app.changeGrepPreferences.changeTo = "$1 (continued)\\r";
app.selection[0].changeGrep();
app.findGrepPreferences = app.changeGrepPreferences = null;
}
if (mySelection.selectedIndex == 2){
app.findGrepPreferences.findWhat = "(.)\\r";
app.changeGrepPreferences.changeTo = "$1 (Cont'd)\\r";
app.selection[0].changeGrep();
app.findGrepPreferences = app.changeGrepPreferences = null;
}
if (mySelection.selectedIndex == 3){
app.findGrepPreferences.findWhat = "(.)\\r";
app.changeGrepPreferences.changeTo = "$1 (cont'd)\\r";
app.selection[0].changeGrep();
app.findGrepPreferences = app.changeGrepPreferences = null;
}
}
for do some tedious works, but it has some options, how can I add something to it aim to tell the script I want to do something as previous choice?
I expected it can remember the last what I do. and then do as same as previous jobs.
like I want to repeat one job again and again
I add a recall template into it, but I don't know how can I make it happen?
var myDialog = app.dialogs.add({name:"add continueds",canCancel:true});
with(myDialog){
with(dialogColumns.add()){
with(dialogRows.add()){
var mySelection = dropdowns.add({stringList:["Continued", "continued", "Cont'd","cont'd"], selectedIndex:0});
//---------------------------------------------------------------------------------------- -------------------------------------------------------------
// I add (a template) into here, but how can make it happen?
my $menu=$q->popup_menu(
-name=>"templates",
-id=>"templates",
-values=>["",23,36],
-labels=>{""=>"Select . . .",23=>"Text One",36=>"Text Two"
+}
//---------------------------------------------------------------------------------------- -------------------------------------------------------------
);
}
}
}
if (myDialog.show() == true)
main();
function main(){
var myObject;
var myCheckSelection = false;
if(app.documents.length > 0){
if(app.selection.length > 0){
switch(app.selection[0].constructor.name){
case "InsertionPoint":
case "Character":
case "Word":
case "TextStyleRange":
case "Line":
case "Paragraph":
case "TextColumn":
case "Text":
case "Cell":
case "Column":
case "Row":
case "Table":
myObject = app.selection[0];
if(app.selection && app.selection[0].hasOwnProperty ("contents") );
addContinueds();
}
}
}
else{
alert("No documents are open or wrong selection. Please try again.");
}
}
function addContinueds() {
if (mySelection.selectedIndex == 0){
app.findGrepPreferences.findWhat = "(.)\\r";
app.changeGrepPreferences.changeTo = "$1 (Continued)\\r";
app.selection[0].changeGrep();
app.findGrepPreferences = app.changeGrepPreferences = null;
}
if (mySelection.selectedIndex == 1){
app.findGrepPreferences.findWhat = "(.)\\r";
app.changeGrepPreferences.changeTo = "$1 (continued)\\r";
app.selection[0].changeGrep();
app.findGrepPreferences = app.changeGrepPreferences = null;
}
if (mySelection.selectedIndex == 2){
app.findGrepPreferences.findWhat = "(.)\\r";
app.changeGrepPreferences.changeTo = "$1 (Cont'd)\\r";
app.selection[0].changeGrep();
app.findGrepPreferences = app.changeGrepPreferences = null;
}
if (mySelection.selectedIndex == 3){
app.findGrepPreferences.findWhat = "(.)\\r";
app.changeGrepPreferences.changeTo = "$1 (cont'd)\\r";
app.selection[0].changeGrep();
app.findGrepPreferences = app.changeGrepPreferences = null;
}
}
guys help me please!
John