K1200 Posted August 15, 2008 Posted August 15, 2008 I've been considering this problem for a while and just can't get a handle on a good approach -- so I'm looking for suggestions (I'm on Windows). Here's the situation: I have a text field that may or may not have a file path/name somewhere in the field. For example: "This is a remark entered by a user. The user might make note of an associated document with a comment like BTW, I put the notes in c:tempnotes.txt if anyone needs them." What I would like to have is an Auto Open function on a button associated with the field that could locate the file (if any) within the text field and use SendEvent to open it. Ideally, it could be made to work exactly the way FileMaker's right-click menu does when it recognizes an embedded URL -- but I'll certainly settle for a button beside the field. BTW, I have no control over where the contents of the text field comes from (some are imported) so I need to evaluate the field at runtime to see if it contains an "openable file" -- .txt, .doc. and .pdf are the main ones I'm concerned with. A simplistic approach would be to require the user (some user, maybe not the one who entered the remark) to delimit the file/path with brackets if they want to be able to open it with the button. But, as always, I'm trying to make it easy on the user. Any suggestions? Thanks in advance.
comment Posted August 15, 2008 Posted August 15, 2008 A simplistic approach would be to require the user ... to delimit the file/path with brackets The correct approach would be to require the user to enter the notes into one field, and the filepath/s into another. Anyway, I am not quite sure what your question is: are you looking for a way to extract a possible file path from the text? What would be the rules to classify a string as a file path? It's easy with URL's because they begin with http://xyz... (see how easy it is to fool the algorithm?). What if the user wrote "I cannot find anything.pdf"? the way FileMaker's right-click menu does when it recognizes an embedded URL AFAIK, FileMaker does not recognize an embedded URL - it's the user that needs to find it and select it first. This would be easy to implement with your button, using the Get(ActiveSelectionStart) and Get(ActiveSelectionSize) functions.
K1200 Posted August 15, 2008 Author Posted August 15, 2008 AFAIK, FileMaker does not recognize an embedded URL The feature I was referring to is the one shown by the example below. It's so convenient for the user that not having the same kind of thing for "c:tempnotes.txt" becomes an apparent oversight (to the user). What would be easy for the FileMaker program isn't so easy from a script -- which is why I mentioned having the user identify and highlight/bracket/delimit the name and path. But I'm still hoping there's a better way.
comment Posted August 15, 2008 Posted August 15, 2008 It only works for me when the cursor is somewhere inside the URL - and as I said, it will take http://anything and think it's an URL.
K1200 Posted August 16, 2008 Author Posted August 16, 2008 ... when the cursor is somewhere inside the URL I guess what I'll try for is a script that accomplishes the same thing. In other words, look forward and backward from the cursor's position and assemble the contiguous text into an "assumed path". If it passes a couple of basic checks, I'll use it in a SendEvent and see what happens. Thanks for taking a look at this.
comment Posted August 16, 2008 Posted August 16, 2008 That should be possible - although you need to look for a lot of gotcha's, such as path placed at the beginning or at the end of text, or punctuation marks surrounding the path.
Recommended Posts
This topic is 5942 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now