5 Replies Latest reply on Jun 15, 2010 12:16 AM by stige

    Including Text Formatting in a Script

    stige

      Title

      Including Text Formatting in a Script

      Post

      Hi There,

       

      Very new forum member here (I've mostly been lurking) and novice, self taught Filemaker user.  I've done what I feel is reasonable due diligence in searching for similar questions but havn't been able to find any answers that suit my particular goals.

       

      My Info: FM Pro 9.0v3, Win XP SP3, Shared, likely will be published with IWP or CWP

       

      The question: I would like to make a timestap/account name bold and the rest of the text plain.

       

      I have a text field  (Field #1) that is used to log activity.  It is only editable by Administraor and not the data entry people.  To log their activity in it they type their note in to a separate field (Field #2) and then activate a script that -

       

      'Cut' Field #2 > Insert Timestamp > Insert Account Name > 'Paste' text to Field #2 > 'Cut' Field #2 > 'Paste' to Field #1

       

       

      It runs with full admin provleges and works great.  It effectively adds a timestap and account name to the begining of their log entry.  However all the text that gets pasted in to Field #1 ends up looking like a long run-on sentence.  I'd like to add this visual indicator to differentiate individual entries.  Possibly add a slight color change, too.

       

      Simply adding a carriage return is my current solution, to space everything out, but space is at a premim on this page because I need to keep this layout compact by user request and this won't be tenable long-term.

       

      Thanks again for any help provided.

      -d

        • 1. Re: Including Text Formatting in a Script
          stige

          In case any one is interested/searches for the same problem, I've figured this out.

           

          I created a 2nd text field that does nothing but lurk behind the data entry field.

           

          When the script is activated I used ReplaceField w/ TextStyleAdd;bold + Get Timestamp & GetAccntName & " - " in to that 2nd field.

           

          Then I used Insert Calculated Result to get the text out of the data entry field and force a TextStyleAdd;plain on it before pasting in to the 2nd field, behind the time/name stamp.

           

          Then the whole shebang is copied from the hidden field and pasted in to my restricted access 'Log' field.  Lastly the field in which the note was entered is cleared and the cursor is returned to that field.

           

          I hope that makes some sense.

          • 2. Re: Including Text Formatting in a Script
            LaRetta_1

            Shebang is right ... and it need not be this complex; in fact, you don't need script at all.

             

            The real solution is to have fields for creation timestamp (set to auto-enter creation timestamp), account name (set to auto-enter creation account name) and note.  This will allow you flexibility such as sorting on any field, searching easily and other manipulations such as generating reports by Account Name. 

             

            You can then display the result on any layout as:

             

            Insert > Merge Field (select your creation timestamp )  then type a space then Insert > Merge Field (select your Account Name) then type a space dash space then Insert > Merge Field (then select your note field).   Now, you could just grab what you want and bold it.

             

            • 3. Re: Including Text Formatting in a Script
              stige

              Thank you for your input, LaRetta.

               

              Two points: I do have fields that capture the creation time and creator account name.  However, the person entering the notes may not be the same person who created it and the time will always be advancing.  The notes are not all entered at a single time.  They show a progression of activity on the dispatch.  Multiple dispatchers will have access to the record and be able to make entries throughout it's duration.

               

              And I'm not familiar with the mechanics of MergeField.  And when you say I could just grab what I want... would you mind edifying?

               

              Thanks again for your time!

              • 4. Re: Including Text Formatting in a Script
                LaRetta_1

                stige wrote:

                The notes are not all entered at a single time.  They show a progression of activity on the dispatch.  Multiple dispatchers will have access to the record and be able to make entries throughout it's duration.


                Ah.  It is not just one note per record; you are using one field to log multiple notes.  Then your notes really should be another table which holds creation timestamp, account name and note and be related back to your main table by the main table's ID.  Then display your list of notes in a portal on your main table. 

                 

                Merge fields allow you to create strings of information which eliminates the need for concatenated calculation fields (in many instances) and they expand as needed.  Go to FM Help and type merge field  in the search.  The second item "Placing merge fields on a layout" explains it more fully than I can here.

                 

                UPDATE:  What I mean by "you can grab what you want" is simply that you can select any of your fields to include in the merge field string and also type your own text.  Merge fields are a powerful tool and now (vs. 11) with ability to use variables in merge fields, they are even more powerful. :smileyhappy:

                • 5. Re: Including Text Formatting in a Script
                  stige

                  LaRetta wrote:

                  Ah.  It is not just one note per record; you are using one field to log multiple notes.  Then your notes really should be another table which holds creation timestamp, account name and note and be related back to your main table by the main table's ID.  Then display your list of notes in a portal on your main table. 

                   


                   

                  Oh, I like this idea!  But, I'm having a tough time picturing how the 2nd table would work with the 1st.  Would it have a record to mirror each dispatch record, created at the same time as the dispatch and related by ID#?  And the fields in T2... I think my brain is stuck picturing this working from the perspective of how I already have it which is why I'm having difficulty here.

                   

                  My comfort level of playing with Tables if pretty low.  I've managed to get the gist of conditional value lists, but that's about it.  However, I'll try this out.

                   

                  And in case anyone is curious I've greatly simplified my initial script (yes, I was feeling a mite self concious about my weight :smileyvery-happy: )

                   

                  It's now simply:

                  - Insert Calc Result (formatting (time) & " - " & (account name) & " - ")

                  - Insert Calc Result (formatting (GetField contents) )

                  - Insert Text (" carriage return ")

                  - Clear Field

                   

                  The first three point to my data capture field that is only editable by admin and the 'clear field' points to the field that the data entry is done in.  Script is run with admin privleges.