4 Replies Latest reply on Dec 11, 2013 10:24 AM by philmodjunk

    Calculation: Why can’t I not do this? And what should I try instead.

    JohnDee

      Title

      Calculation: Why can’t I not do this? And what should I try instead.

      Post

           Get(CurrentLayout)::FieldName

            

           Why can I not do this and what should I try instead?

        • 1. Re: Calculation: Why can’t I not do this? And what should I try instead.
          gcatnine

               Get(CurrentLayout)  does not exists.

               For what I understood, the calculation could be:

               Get ( LayoutName ) & "::FieldName           // in this case the layout name must be the same as the table name

               or better

               Get ( LayoutTableName ) & "::FieldName

          • 2. Re: Calculation: Why can’t I not do this? And what should I try instead.
            philmodjunk

                 It would help to explain the context in which you are trying to set up this reference. And since the layout name may not always be the same as the layout's specified table occurrence (the name selected in Show Records from in layout setup...), I'd use:

                 Get ( LayoutTableName ) & "::FieldName"

                 This can be used in expressions such as:

                 GetField ( Get ( LayoutTableName ) & "::FieldName" ) )

                 or

                 Set Field By Name [ Get ( LayoutTableName ) & "::FieldName" ) ; Some value goes here to set to the field ]

            • 3. Re: Calculation: Why can’t I not do this? And what should I try instead.
              JohnDee

                   @Gianandrea  Hi, and thanks for your reply!

                   Yes it is Get (LayoutName), I always get that wrong and it's CurrentLayout in my head, lol.

                   And thanks for this:

                   Get ( LayoutTableName ) & "::FieldName

                   That's what I was looking for, but why is the " used? It seems like a very unorthodox way to use it....ok, I get it, you meant to have another " at the end.

                   @ Phil, thanks again for another great reply. To be honest I do not recall my implementation or where I was trying to use this. I just noted down that I couldn't do it and couldn't understand why. Now I get the rationale.

                    

              • 4. Re: Calculation: Why can’t I not do this? And what should I try instead.
                philmodjunk

                     but why is the " used?

                     My example was:

                     Get ( LayoutTableName ) & "::FieldName"

                     Indirect references like this are text expressions. Thus the item to the right of & must be text. You can refer to a field name by putting it in quotes, or it can be a field, variable or calculation as long as what is used evaluates as text for the field name and with the :: to produce the correct syntax.

                     I try not to use quoted text for file, table occurrence or field names if this is at all possible (and it usually is possible). If you put such info in quotes like that, a change to the file name, table name, table occurrence name or field name can "break" the calculation as it then evaluates to the name of something that no longer exists.