Dear Experts,
Im very new to Scripting.
I'm creating a Validation tool which shows hyphenated words in a ListBox & i done it well in VB6.
Now all my need is i have to jump to the location in the document while clicking the ListBox Item.
Is there any options to do this?
Looking forward your comments.
Thanks in advance.
SaRaVaNaN.N
In this thread: http://forums.adobe.com/message/2933158#2933158 you find some references to scripts that do exactly that. They're in JS but you should be able to see how to handle this. But if as you say you're very new to scripting, then this is probably too difficult.
Peter
Hi Arivu,
Thanks for your suggestion.
Its not shows only Hyphenated words. It finds some more occorances also like, paragraph's last line contains less than 8 chrs, hyphen at end of page, etc.
I found everything. my actual need is i hav to set some mark to the founded text & while clicking on the listbox, i have to jump there.
So i have to do something more than this.
Can you help me on this?
Hi Try this code...
I created this for windows XP, Indesign CS4.
#targetengine "session";
var myDoc = app.activeDocument;
var stories = myDoc.stories.everyItem ().getElements ();
var myFind = new Array(); var myCounter = 0;
var times1, times2;
times1 = new Date().valueOf();
//-----------------------------For display---------------
var w = new Window ("palette", "Hyphenated words");
var list = w.add ("listbox", undefined, "", {numberOfColumns: 1, showHeaders: true,columnTitles: ["Hyphenated Word"], columnWidths: [185]});
list.maximumSize.height = $.screens[0].bottom-200;
var myStory_id = new Array(); var myitem_id = new Array();
//------------------------------------------------
main();
times2 = new Date().valueOf();
var timeTaken = ((times2-times1)/1000);
displayWindow();
if (myCounter > 0){
w.show();
}
else { alert("Double Hypehnation Not Found"); }
function main(){
var lineCount;
myResetFindChangeGrep ();
app.findGrepPreferences.findWhat = "(\\w+)([-~=])(\\w+)";
var myIndex = new Array();
for (i=0; i<stories.length; i++){
myFind[i] = stories[i].findGrep(true);
for (j=0; j<myFind[i].length; j++){
lineCount = myFind[i][j].lines.length;
if (lineCount>1){
var story_id = i; var myFind_id = j;
var myText = myFind[i][j].contents;
addItem(myFind[i][j], i, j);
myCounter++;
}//End if
}//End of Find Length
}//End Story length
//alert(myIndex.length);
}
//------------------------Function Declarations--------------
function displayWindow(){
//window declared as global variable here
var panel1 = w.add('panel');
panel1.minimumSize.width = 210;
var group1 = panel1.add('group');
group1.orientation ='row';
var close_ = group1.add ("button", undefined, "Close", {name: "ok"});
group1.add("statictext", undefined, "Fetched in "+timeTaken+" sec");
close_.maximumSize.width = 44;
list.onDoubleClick = function ()
{
if (this.selection != null ) {
var myIndex = this.selection.index;
var storyNum = myStory_id[myIndex];
var findNum = myitem_id[myIndex];
var selectText = myFind[storyNum][findNum];
app.select (selectText, SelectionOptions.replaceWith);
app.activeWindow.zoomPercentage = 200;
}
}
close_.onClick = function () {w.close ()}
}
function addItem(myItem, sto_id, item_id){
list.add ("item", myItem.contents);
myStory_id .push(sto_id);
myitem_id .push(item_id);
}
function myResetFindChangeGrep(){
app.findGrepPreferences = NothingEnum.nothing;
app.changeGrepPreferences = NothingEnum.nothing;
app.findTextPreferences = NothingEnum.nothing;
app.changeTextPreferences = NothingEnum.nothing;
}
--------
Green4ever
North America
Europe, Middle East and Africa
Asia Pacific