6 Replies Latest reply on Jan 26, 2015 8:33 PM by erolst

    Field insertion point

    bry

      How do I define an insertion point in a field?  I need to create a script that can add text to an existing field.

        • 1. Re: Field insertion point
          jrenfrew

          At the end??

          • 2. Re: Field insertion point
            bry

            At the beginning of the existing data in the field.

            • 3. Re: Field insertion point

              Hi Bry,

               

              If you have a specific number of characters into the string that you want to insert text, you could do something like this with a Set Field:

               

              Left (test::Field ; 6 ) & "Big " & Middle (test::Field ; 7 ; Length ( test::Field ) )

               

              This takes the string that is in the database test and field name Field that contains the text "Hello World" and changes it to "Hello Big World".

               

              You could also use Substitute with Set Field or Pattern Count to find the occurrence of some text and use the result of that in Left, Middle, or Right.

              • 4. Re: Field insertion point
                bry

                I'll try that - thanks!

                • 5. Re: Field insertion point
                  jrenfrew

                  from the help

                   

                   

                  Set Selection

                  Purpose

                  Allows the user to specify the starting and ending position of a selection in a field.

                  Format

                  Set Selection [<table::field>; Start Position: <n>; End Position: <n>]

                   

                   

                  If the start position is valid and the end position out of range, everything from the start position to the end of the field is selected. If the end position only is valid, the cursor moves to the end position, and nothing is selected. If both start and end positions are invalid, the cursor moves to the end of the field contents.

                   

                   

                  use 1 and 1 for the start

                  use -1 and -1 for the end

                  • 6. Re: Field insertion point
                    erolst

                    dgullo wrote:

                    Left (test::Field ; 6 ) & "Big " & Middle (test::Field ; 7 ; Length ( test::Field ) )

                     

                    Note that Replace() can simulate a non-existing Insert() if you pass a numberOfCharacters argument of 0:

                     

                    Replace ( test::Field ; 6 ; 0 ; " Big" )