Copy link to clipboard
Copied
Hi,
I didn't understand the following code in extendscript for framemaker. what is the purpose of findParams[0] and findParams[1]. And why we have to choose findParams[0].propIdent.num = Constants.FS_FindText; and findParams[1].propIdent.num = Constants.FS_FindCustomizationFlags; Difference between findParams[0] and findParams[1]. Please explain this individual code.
var findParams=new PropVals ();
findParams = AllocatePropVals(2);
findParams[0].propIdent.num = Constants.FS_FindText;
findParams[0].propVal.valType = Constants.FT_String;
findParams[0].propVal.sval = searchString;
findParams[1].propIdent.num = Constants.FS_FindCustomizationFlags;
findParams[1].propVal.valType = Constants.FT_Integer;
findParams[1].propVal.ival = Constants.FF_FIND_USE_WILDCARDS;
findParams[1].propVal.ival =16;
Thank you.
Copy link to clipboard
Copied
Hi,
These are just the options for the Find action, which correspond with the options you see in the UI dialog box. FM can find many things, not just text, so if you are just looking for text, you need to say so. Also, FM makes it optional whether traditional wildcard characters will actually be considered wildcards during the search, because you may just want to just find the actual characters (asterisk, etc.). So, if you want wildcards to be wildcards, you have to say so in your script, just like you have to say so in the UI.
In scripting, there is no UI, so there has to be some mechanism to collect a group of parameters or options. The most common method is what you see... an array of parameter objects. These are custom objects; that is, invented by the Adobe team, not part of the standard Javascript language. It takes a little time to get used to them, but once you do, they are not that complicated and usually work about the same way in each application.
Here is a little more:
var findParams=new PropVals (); //Allocate a new parameter array. Since these are custom objects, this is just how you do it.
findParams = AllocatePropVals(2); //More allocation, to specify two objects. Might have been able to just do "new PropVals(2)", not sure.
findParams[0].propIdent.num = Constants.FS_FindText; //First parameter identifier... type of search
findParams[0].propVal.valType = Constants.FT_String; //First parameter value type... will be a string. Just have to do this part. Reasons are legacy.
findParams[0].propVal.sval = searchString; //The actual string to search for.
findParams[1].propIdent.num = Constants.FS_FindCustomizationFlags; //Second parameter identifier... specify any special flags. There are multiple.
findParams[1].propVal.valType = Constants.FT_Integer; //Have to say that the parameter value is an integer. Just have to do this part.
findParams[1].propVal.ival = Constants.FF_FIND_USE_WILDCARDS; //The special flag(s) to implement, in this case just the wildcards flag.
For any available parameter that you do not explicitly set, the script will use some default value. The documentation provides all default values, which often correspond to the default setup of the associated UI widget.
Hope this helps.
Russ