Automated Solutions for FrameMaker..

Hello everyone:

I was going through a query on the Adobe FrameMaker user to user forums, found this interesting problem statement:

And I thought, why not try and solve this problem statement. Had fun solving it.
Sharing it for the benefit of the FrameMaker Extendscript community.
var doc = app.ActiveDoc
var variable = doc.FirstVarInDoc

while(variable.ObjectValid())
{
var tr1 = variable.TextRange; //text range of the variable

	/*text range for next possible char*/
    var tl1 = new TextLoc(tr1.end.obj, tr1.end.offset + 1);	
    var tl2 = new TextLoc(tr1.end.obj, tr1.end.offset + 2);	
    var tr2  = new TextRange (tl1, tl2)

	var textitems = doc.GetTextForRange (tr2, Constants.FTI_String);

	if (textitems.length > 0)
	{
		var str = textitems[0].sdata;
		if(str != " ") //if space then add text
		{
			 doc.AddText (tr2.beg, " ");        
		}        
	}
	variable = variable.NextVarInDoc;
}

Hope this solution nails the problem statement. It might also lead you to attack similar problems under different contexts.

Best Wishes:
framegurus
email:framegurus@gmail.com
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: