April 28, 200322 yr Hi all! I think I know the answer to this question, but I thought I would see if anyone as found a way to do this. Basically, I have a text field that I allow people to enter a short key(#123#) and then I replace that key with stored text from a related file based on the short key using a script. This is pretty simple using the Substitute function. The problem with using the Substitute function, much like using the SetField function, is that any formatting(bold, italics,etc) that was done to the stored text in the related file gets removed. The only way I know how to preserve the formatting is by using copy and paste. The problem with that is that to paste into a field you either have to select all contents of the field or you have to have an insertion point which requires the user to grab the mouse and click the button. This is a problem since the whole concept of my solution is to speed up data entry in this field. To my knowledge, there is no way to automatically go to a position in a string of text. If there was then my problems would be solved. I could automatically go to the insertion point and then paste. Anyone have a solution to my problem?
April 28, 200322 yr The only way to do it is by AppleScript: set x to cell "log text" of current record as styled text set y to myReplace("#123"", "Substitute Text", x) set cell "log text" of current record to y on myReplace(search, replace, theString) -- Parameters: search, replace, the String set olddelis to my text item delimiters set my text item delimiters to (search) tell me to set theList to (every text item of theString) set my text item delimiters to (replace) set theString to theList as string set my text item delimiters to olddelis return theString end myReplace
April 28, 200322 yr Author I appreciate your response, but I am not using MacOS. It's on a Windows computer.
April 28, 200322 yr then you will need a system wide macro recorder or a prog that intercepts text input. There are some that replace any occurrence of "###123###" with "hello there" . Maybe you will find one at tucows.com. Most utilities like this store their substitutions in a simple text fie. You could easily update that from within FileMaker by export script step.
Create an account or sign in to comment