1 2 Previous Next 26 Replies Latest reply on Oct 7, 2013 8:31 AM by philmodjunk

    Creating...links? I think..

    jackien

      Title

      Creating...links? I think..

      Post

           I have a rather large database, and I want to be able to link/click on a word that is in one entry, and have it take me to that data entry. Is this possible? Would I need to create each individual link? Or is there a way to stream line this?

           Let me know if that doesn't make sense, and I'll try to explain further what I want to do.

            

           Thanks!

        • 1. Re: Creating...links? I think..
          GuyStevens

               Is the data you want to link to in another table? Like for instance:

               If you have a list of sales. And every sale contains products. And you want to click a product and then be taken to the product layout that shows you the record of that product.

               That can be done very simply providing you have created a correct relationship between your products table and your sales table.

               You would use the "Go to related record" script step and enter the correct settings.

               This does not need to be done for every record. Just once.

               And I always make my text look blue and underlined so it looks like a link and people see they can click on it.

          • 2. Re: Creating...links? I think..
            philmodjunk

                 On the other hand, you may not want specific "link" text in your field. Clicking on a word in the field might just trigger a kind of "dictionary" look up. And that can be done as well. A script can extract the text of the word that was clicked and use it to perform a find on a table in your database using that clicked word as your find criteria. The OnObjectEnter script trigger can be used to perform such a script.

                 And this trick only works in FileMaker Pro. It does not work in FileMaker Go.

            • 3. Re: Creating...links? I think..
              jackien

                   @DaSaint - I only have one table. Is there a way to create relations inside of one table?

                    

                   A script to extract the text of a word would be amazing! It's just what a want,  a kinda of dictionary look up. Thank you Phil!

              • 4. Re: Creating...links? I think..
                philmodjunk

                     Yes, you can link tables to themselves in a self join relationship. This creates a new Tutorial: What are Table Occurrences? of the existing table.

                     OnObjectEnter can perform the following script. It starts from the position of the cursor as placed by the mouseclick then then "scans left", "scans right" to extract all the text of the clicked word.

                     Set Variable [$Cursor ; value: Get ( ActiveSelectionStart ) ]
                     Set Variable [$start ; value: $Cursor ]
                     Set Variable [$Text ; Get ( ActiveFieldContents ) ]
                     #Scan left
                     Loop
                        Exit Loop If [PatternCount ( " ¶.?"!&;,:" ; Middle ( $Text ; $start ; 1 ) // exit if character is a space, return or punctuation ]
                        Exit Loop If [ $Start = 1 ]
                        Set Variable [$Start ; value: $Start - 1 ]
                     End Loop
                     #Scan Right
                     Set Variable [$End ; value: $Cursor + 1 ]
                     Loop
                        Exit Loop If [PatternCount ( " ¶.?"!&;,:" ; Middle ( $Text ; $End ; 1 ) // exit if character is a space, return or punctuation ]
                        Exit Loop If [ $End =  Length ( $Text ) ]
                        Set Variable [$End ; value: $End + 1 ]
                     End Loop
                     Set Variable [$word ; value: Middle ( $Text ; $End - $Start ) ]
                     #Perform a Find
                     Go to Layout [Specify layout based on table to be searched here]
                     Enter Find Mode []
                     Set Field [YourTable::YourFIeld ; $Word]
                     Set Error Capture [on]
                     Perform Find []

                     This is the basic idea. Please test any implementations of it carefully as I have not tested it.

                • 5. Re: Creating...links? I think..
                  jackien

                       The pattern count isn't liking " ¶.?"!&;,:" that part of the variable. Is there any way to take it out? I keep getting an error saying the variable is too short or the table doesn't exist.

                  • 6. Re: Creating...links? I think..
                    philmodjunk

                         Hmmm, shame on me for leaving out a detail. It's complaining about the " character which should be "escaped" with a back slash:

                         Exit Loop If [PatternCount ( " ¶.?\"!&;,:" ; Middle ( $Text ; $End ; 1 ) // exit if character is a space, return or punctuation ]

                         You don't want to remove this unless your text is absolutely free of such punctuation characters. You may even need to add additional punctuation characters to what I have put in that string.

                    • 7. Re: Creating...links? I think..
                      jackien

                           Thanks!

                           Is there any way to add a space to those? Cause sometimes I'll have someones first and last name in the field, and i'll want it to search the whole thing.

                      • 8. Re: Creating...links? I think..
                        philmodjunk

                             There already is a space character in that quoted string. That's the most common word separator after all.

                        • 9. Re: Creating...links? I think..
                          jackien

                               Oh....thanks....Wow I'm dumb....Such a newbie at this. 

                          • 10. Re: Creating...links? I think..
                            jackien

                                 It worked!! I can't thank you enough!!

                                 I do have another question though! Is there a way to turn off/on scripts? with a keyboard shortcut or anything? Or does that require another script Lol

                            • 11. Re: Creating...links? I think..
                              philmodjunk

                                   Do you mean that you want to enable or disable a script trigger performed script?

                                   I frequently use this method:

                                   If [ Not $$TriggersOff ]
                                     //put rest of script here
                                   End IF

                                   Then other scripts can set $$TrigersOff--a global variable--to True to disable that script and back to False to re-enable it.

                              • 12. Re: Creating...links? I think..
                                jackien

                                     I've run into a bit of a bug, and I'm not sure how to fix it. This is the box where I have the script, but every time I click on the last word in the box, the search gets messed up. Instead of giving me the correct number of entries that have the word in it, it gives me thousands, that have nothing to do with the original word.

                                     any idea what might be causing this?

                                • 13. Re: Creating...links? I think..
                                  philmodjunk

                                       You might want to check and see what value is actually being captured in $Word. You can use Show Custom Dialog to display it or you can use FileMaker Advanced's Data Viewer and Script Debugger to check this variable's value.

                                       I'd guess that the parenthesis both ( and ) are a part of the problem as they aren't listed in my sample script as word separating punctuation. You may just need to add them to the quoted string used with Patterncount.

                                  • 14. Re: Creating...links? I think..
                                    jackien

                                         Parenthesis sadly didn't fix it. The only think I can think of is that sometimes this happens when I click on the last word in that box, the debugger comes up with OnObjectEnter: Links in the debugger while the other words have Script:Links.

                                         Does the OnObjectEnter have something to do with the last word giving me thousands of records in the search?

                                    1 2 Previous Next