www.Inmagic.com    Inmagic Forums    Inmagic Forums  Hop To Forum Categories  Scripting    Scripting for specific field entry
Go
New
Find
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Posted
I would like to set up a couple of scripts that appear to be dependent on the initial selection of a particular field entry. For example, I would like to set up a script for an edit screen that instead of swapping the entire contents of two fields (as in sample JavaScript 1) only moves (and appends) a single selected field. We have thesaurus terms in our index records as both major and minor descriptors and it would be nice to have buttons to move a term from major to minor and vice versa.

However I haven't been able to find any examples of scripts that manipulate only a single field entry. With Command.deleteEntry() you can delete a line solely on the basis of cursor position, but I can't work out how to use Command.selectEntry() to copy a field entry to a string.

Similarly, I would also like to set up buttons that move thesaurus entries up or down in an array (presumably using +1 and -1 relative to their position in an index), instead of just alphabetizing multiple entries in a field, as in the example in the script library.

It's a pity there aren't more sample scripts!

Thanks, Philip
 
Posts: 9 | Location: Canberra, Australia | Registered: Thu January 20 2005Reply With QuoteEdit or Delete MessageReport This Post
Posted Hide Post
Andrew Pentecost supplied a more complex version of the following script, which will move a selected entry (on the same line as the cursor) from our Major to Minor descriptor fields:

// Move to minor button
function buttonMinor_onClick()
{
Command.selectEntry();
Command.cut();
Form.boxes("boxMinor").setFocus();
Command.PasteEntry();
}

A corresponding "Move to major button", set up under the Minor descriptors box on our edit form, moves entries in the opposite “direction” (i.e. Minor to Major).

Rather than appending, the entry to be moved will be pasted wherever the cursor was last positioned in the target field. Unfortunately, depending on previous edits, a bug sometimes causes blank entry separators to be left at the original site of the moved entry. Unless somebody can suggest a fix, these extra entry separators will have to be individually deleted.

I haven't been able to work out how to set up buttons to move thesaurus entries up or down. MoveNext() and MovePrevious() are only applicable to record sets.

There is an example in the script library to alphabetize multiple entries, but it seems to me to move up an individual entry you need to first split your entries into at least four arrays. Counting from zero, they are: (0) any up to preceding entry, (1) preceding entry, (2) selected entry to be moved up, (3) any remaining entries. Then you need to split and rebuild with (arr.concat(arr0,arr2,arr1,arr3)). Similarly to move down, the selected entry has to be moved after the the one that follows it. A HTML example appears at http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_concat2. However selecting and splitting the entries seems to be the hard part!

Thanks, Philip
 
Posts: 9 | Location: Canberra, Australia | Registered: Thu January 20 2005Reply With QuoteEdit or Delete MessageReport This Post
  Powered by Eve Community  
 

www.Inmagic.com    Inmagic Forums    Inmagic Forums  Hop To Forum Categories  Scripting    Scripting for specific field entry