2 of 2 people found this helpful
Do I have to define a global or calculated field to make this happen?
Yes. But you could simply define a generic global scratch field, use Set Field  to set it to the calculated result, then copy its contents.
No. ErikWegweiser had the right idea …
Not the greatest of titles, IMO …
Hi. Perhaps what you need to do is use the "Set Selection" script step to select the first two words of the Address field, then use the Copy command (without selecting all contents) to copy to the Address field selection clipboard.
1 of 1 people found this helpful
The answer to this questions depends if the Address1 field is on the current layout. If it is use Erik's suggestion. If not, use eroist striked out suggestion since the copy command will not work.
@Erik... Tried this. Script =
SET Selection [Maillist::ADDRESS1; Start Position:1; End Position: Position(Maillist::Address1;" ";1;2) ]
COPY [Maillist:ADDRESS1] (with "entire contents" unchecked).
This works! Thanks.
Ahah.... that might have been the braincramp.... I forgot that the Copy command doesn't work unless the copied field is actually present on the layout.
That seems an unfortunate requirement. What if you want to just copy something to the clipboard....anything?
I actually tried @erolst's, ideas, trying it a couple ways, both by just adding a calculated field to the table, and then trying a global field (but the global field wasn't getting updated consistently...which probably could have been fixed with a script or form trigger.) Maybe...
Thanks everyone for helping me thing this through.
Place the address1 field in the gray area to the right of the active layout. The copy should still work.
If you're on OS X:
This calculated applescript can copy anything you'd like to the clipboard without globals, fields needing to be on a layout, etc...
"set the clipboard to " & Quote ( $TruncAddress )
Just curious about why you are using the clipboard in FMP. Whenever asked to help bring old files up to "best practices", one of the things I "fix" is any scripts which rely on Copy/Paste steps. The only time I would script a Copy in FMP is to ease selecting info to be manually pasted into a different application. Maybe that's what you are doing?
[Because of the layout requirement for both Copy and Paste, I have found the Copy and Paste script steps to be unreliable when compared to Set Variable and Set Field, neither of which require layout objects, and both can be controlled using the full power of FMP's calculation functions to manipulate the content being transfered within FM files.]
The only time I would script a Copy in FMP is to ease selecting info to be manually pasted into a different application.
That's almost exactly what I'm doing.... actually, I'm copying/pasting between two different FM layouts, that are both open at the same time on a different screen.
I'm taking the contents of a field on screen1 and pasting it into the Quickssearch box on screeen 2. It started out as a quick and dirty solution to see if records appear in our invoice file that were sent a catalog using our mailing address file. Since I'm only processing a fifteen hundred records or so, I wasn't going to
It would be nice if there was a more graceful way to do this. I tried a script that grabbed the field value in a variable, then Goto Layout and then QuickView....however, the Goto Layout took my first layout and simply switched it to the second layout within the same window r rather than use the instance of the second layout that i have already open in a second window.
If there is a nicer way to accomplish this, I'm all ears.
I recall that in Windows (especially) the clipboard is not to be relied upon. At one point I think I entered a bug report to that effect for FM 12.
There is another way; name your windows if they don't have distinct names, using the script step
Set Window Title
and use the script step
Select Window (name: xxxxx; filename or current file).
This lets you move between windows via script. [If you have set your variable, it should be either a global variable ($$var) or be passed to another script/file via a script variable when using the perform script elsewhere.]
This returns the full power of the calc engine to you for setting the info in the variable.
It will even let you script a quickfind without requiring a quickfind search field, using the script step:
Perform Quick Find ($$var)
Hi, Stephen, This works... Seems to be convoluted setting up the Window names, but once they are set up the QuickFind works fine.
And I've learned about moving between Windows... never had used the Windows commands before.
Thanks much foryou help.
Glad that's working for you.
Once one learns how to navigate among multiple windows or files during scripts, a lot of new options open up. Keep in mind that a script will keep working on the "currently selected" window until you select another, or close the one you're in. This complicates scripting compared to some fairly old version where a script could only act on a single file/window, but that control is now in the developer's hands.