Pages: 1
Print
Author Topic: Macro to search through attribute value  (Read 66 times)
jshick
Member

Posts: 1


« on: June 09, 2017, 11:01:23 AM »

I'm using Xmetal Author Enterprise 11. I need to fix a form that works in PlainTextView to work in TagsOnView. Basically, the user enters a reference number (e.g.: 101) and the form cycles through all <ref-callout> elements that have an href of "r101". I need to reprogram the script so that it will work in NormalView.

I have the following macro which calls a form:

<MACRO name="find-ref-callout" key="" lang="JScript" hide="true"><![CDATA[
var dlg = Application.CreateFormDlg(Application.Path + "\\Forms\\find-ref-callout.xft");
dlg.DoModal();
dlg = null;
]]></MACRO>

The form has an EditBox and a Search button. The onClick event for the search button is associated with this function:

Sub Button1_OnClick()
   findText = "<ref-callout href=""r" + EditBox1.Text + """"
   Selection.Find.Execute findText,"","",,,,boolForward=False
End Sub

Thanks!
Jeff

Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2469



WWW
« Reply #1 on: June 09, 2017, 12:04:25 PM »

You might be able to use Find.Execute (the third option in that method, that you have set to be an empty string "", allows you to limit search to within certain elements -- check the Programmers Guide for its full syntax), but I don't think that's what you want.

If your form just needs to move the active selection to the next occurrence of an element then you probably want to use:
Selection.MoveToElement("ref-callout")

If that doesn't point you in the right direction what is the exact goal of your script (in Tags On or Normal views)?
« Last Edit: June 09, 2017, 12:25:31 PM by Derek Read » Logged
Pages: 1
Print
Jump to: