7 Replies Latest reply on May 3, 2011 5:20 PM by LaRetta_1

    How do I combine the separate fields into one.

    marco96

      Title

      How do I combine the separate fields into one.

      Post

      Hello Everyone,

      I have the typical address fields... one for name, one for street address, city state, zip etc.

      I have a need to be able to copy all of the address all at once and paste it into an email or what ever. I made a field and called it "get address". I was going to make the script to open and copy each field and then have it paste into the get address field. Then set up a script to do all of that and open a new window with that field which I could just copy. I knew I would run into to a problem with having it in one long line instead of a carage return after each inserted line. This may not be the best way to do it. Any help with a script would be appreciated.

      Thank you 

      Marco

        • 1. Re: How do I combine the separate fields into one.
          philmodjunk

          No need for a script. Make it a field of type calculation set to return text. That way, if you edit an address field, this field will update automatically and you won't have to run this script again just to update it.

          There are two ways to get returns into the calculation field's expression:

          FullName & ¶ & Street & ¶ & City & ", " & State & "  " & Zip

          ¶ inserts the needed returns in this case.

          You can also use:

          List ( FullName ; Street ; City & ", " & State & "  " & Zip )

          The only difference in the results returned is that list will "close up" the lines if FullName or Street is empty. This might be useful if you have two fields for the street address where the second field is often empty.

          • 3. Re: How do I combine the separate fields into one.
            LaRetta_1

            You can also set a variable to save creating a calculation, such as $fulladdress ...  and then specify the variable in the body with simple $fulladdress

            You would use the List() method of:  List ( Name ; address1 ; address2 ; city & ", " & State & "  " & Zip )

            • 4. Re: How do I combine the separate fields into one.
              philmodjunk

              LaRetta, how would you recommend setting that variable? I've been playing around with several options and haven't always been pleased with the resutls, so I'm curious to see how you'd do it.

              • 5. Re: How do I combine the separate fields into one.
                LaRetta_1

                I would set it just as I would set any field.  At the moment of creating the email, it would be:

                Set Variable [ $fullAddress ; List ( Name ; address1 ; address2 ; city & ", " & State & "  " & Zip ) ] ... or whatever you wish
                Send Mail [ and set the Message with:  $fullAddress ]

                ... hmmmm, did I miss something in the requirements?  It is quite possible.  I had tooth pulled and I'm on heavy drugs today lol!

                How would I recommend setting the variable?  Uh, by script when creating the email?  This feels like a trick question! I simply MUST be missing something.  :^)

                • 6. Re: How do I combine the separate fields into one.
                  philmodjunk

                  Well, we were trying to avoid a script here--often the safer way to go when helping out a newbie Wink

                  And he wanted to copy and paste the text into other software which you can't do with a variable.

                  I've played with using the Let function to assign values to variables inside conditional format expressions as a way to reduce the number of interface specific calculation fields and also the use of script triggers.

                  The problems is that the expressions don't assign values to the variables in a timely fashion--I see the values from the previous record when I flip from record to record. I can fix that with a script, but then I was trying to avoid using scripts in the first place...

                  • 7. Re: How do I combine the separate fields into one.
                    LaRetta_1

                    I won't argue that but I didn't read it in his post but you helped me understand more so let's walk through it ...

                    Phil: Well, we were trying to avoid a script here-

                    Marco: I was going to make the script to open and copy each field and then have it paste into the get address field. Then set up a script to do all of that ...

                    Phil: And he wanted to copy and paste the text into other software which you can't do with a variable.

                    Marco: ... all at once and paste it into an email or what ever

                    I agree that the fewer calculations the better and I see your perception that the need may be to use it in other applications but I don't see that indicated.  I would worry about populating the clipboard with an address because, unless the action was specifically requested, it would mess up the User's clipboard when they may very likely be holding other information at the time.  A simple record switch would destroy it.

                    So since an action should fire the, um action, the User should take the action only when they want it.  Laughing

                    I would then have an icon on the top of the layout with 'copy full address' or have the icon next to the address itself with 'copy' tooltip.  When clicked, script would do the following sequence ...

                    Freeze Window
                    Set Field [ global text which resides anywhere in the file and need not be related ; Get ( ScriptParameter ) ]
                    ... I have globals which say g_script_text, g_script_date etc which I use for these purposes and I don't have to have globals through all my tables
                    Go to Layout [ globals table ]
                    Copy [ Select ]
                    Go to Layout [ original layout ]

                    But you are correct in that we should consider many things when providing solutions.  And this discussion shows that we simply don't have enough specific information to provide the best approach.  Hopefully this discussion has helped clarify ideas and pin down the requirements for marco96.