1 2 Previous Next 24 Replies Latest reply on May 5, 2013 5:09 PM by kaostika

    SELF in Custom Functions

    kaostika

      Hi,

       

      Is there a way to get the SELF command to work in a Custom Function?

       

      Oreste

        • 1. Re: SELF in Custom Functions
          Mike_Mitchell

          I expect not. Self can only be used where the context makes it unambiguous - where it's intrinsically obvious which object the function is referring to. Since a calculation can appear in a variety of contexts (field definition, Conditional Formatting, script step, etc., etc.), I don't believe this will work.

           

          However, there may be another way to accomplish a similar goal. What exactly are you trying to do? There may be another method for de-furring the feline.

           

          Mike

          • 2. Re: SELF in Custom Functions
            ch0c0halic

            What are you really trying to do?

             

             

            "Self" in a CF (Custom Function) is having the CF call itself. Which you can only do by calling it as a function "with parameters". This means "Self" is incomplete in the context of a CF.

             

            Self

            Purpose

            Returns the content of the object in which the calculation is defined.

            The Self function provides a way for a calculation to reference the object with which it is associated without having to explicitly reference the object.

             

            Self is a function that automatically refers to the 'object' in which it is defined. But it cannot refer to itself as a function as that creates a circular reference.

            • 3. Re: SELF in Custom Functions
              kaostika

              I am creating yet cooler way to make Inline labels

               

               

               

              Let

              (

              [

              $table="";

              $var.table=If (IsEmpty ($table) ;Get ( LayoutTableName );$table);

              $field = Substitute ( Substitute ( Self ; " " ; "" ) ; "_" ; "" )

               

               

              ];

              not IsEmpty

              (

              GetField

              (

              $var.table &"::"  & $field

              )

              )

              )

               

               

              You can apply the Conditional Formatting to make the Label 500 px and you only need to do this once for the labels on your main table

              If you have a portal then you just set the $table to the Table you are using for that.  I wanted to put it in a CF so I can not have to enter the Calculation engine to to this.  I almost go it to work with Enclosing objects to get the Portals TO but not quite. 

               

              The Self gets the text of the label and get the feild name for the Isempty.  It works well Fields have regular names or if your fields have a Space or _ instead of spaces.  If you have some stange Naming Convention then you need to modify the CF.

               

              Oreste

              • 4. Re: SELF in Custom Functions
                Mike_Mitchell

                What about passing the field name as a parameter using GetLayoutObjectAttribute?

                 

                Mike

                • 5. Re: SELF in Custom Functions
                  kaostika

                  I would need to have my fields with object names,  no?  I rarely give object names to fields unless I have to.  I want this to use the text of the label itself since FM makes the labels for me I can just drop this in on what it makes.

                  • 6. Re: SELF in Custom Functions
                    Mike_Mitchell

                    Well, I was suggesting giving your labels object names, but yes, you'd have to name the objects.

                     

                    You're probably best just leaving it as a Conditional Formatting calc and doing a copy-and-paste job in this case. Unless Jimmy has a better idea (which is entirely possible).

                    • 7. Re: SELF in Custom Functions

                      You can use self in a custom function since FM 10.

                      Self is a unique function because it is both a pointer to the field value and a pointer to the field itself.

                      GetFieldName is able to use the latter.

                       

                      So a function like Getfieldname ( self ) would return the full field name if used in a calc field like function ( self )

                      You would think that you're sending the field value only, but in fact you're also sending a reference to the field.

                       

                      Fabrice Nordmann

                       

                      Le 25 avr. 2013 à 19:49, kaostika <noreply@filemaker.com> a écrit :

                       

                       

                      créé par kaostika dans Advanced Discussion - Afficher l'intégralité du fil de discussion

                      I would need to have my fields with object names,  no?  I rarely give object names to fields unless I have to.  I want this to use the text of the label itself since FM makes the labels for me I can just drop this in on what it makes.

                       

                      Répondre à ce message en répondant à ce courriel -ou- aller au message sur FileMaker Technical Network

                      Démarrer un nouveau fil de discussion dans Advanced Discussion par courriel ou à l'adresse FileMaker Technical Network

                      Gérer vos préférences email.

                       

                      FileMaker Developer Conference 2013 • San Diego, California • 12-15 Août 2013 • www.filemaker.com/devcon

                       

                      • 8. Re: SELF in Custom Functions
                        BruceRobertson

                        Fabrice, can you expand on that a bit? "You would think that you're sending the field value only, but in fact you're also sending a reference to the field."

                         

                        I'm not sure how both values are passed; or how you choose which result you want and know for certain which result you've actually generated.

                         

                        (edit) Though maybe this illustrates your point.

                        • 9. Re: SELF in Custom Functions
                          kaostika

                          You cant use the SELF in the CF dialog box, you can use it in a function

                          Inlinelabel (_table ;_self)   = Inlinelabel ("",SELF)

                          "

                          Let

                          (

                          [

                          $table=_Table;

                          $var.table=If (IsEmpty ($table) ;Get ( LayoutTableName );$table);

                          $field = Substitute ( Substitute ( _self ; " " ; "" ) ; "_" ; "" )

                          ];

                          not IsEmpty

                          (

                          GetField

                          (

                          $var.table &"::"  & $field

                          )

                          )

                          )

                           

                          "

                          It seems to work this way, so I dont need to do much work to get these labels to work.  I will add the getlayoutobjectattribute to detect TO's automatcially in a bit

                           

                          Oreste

                          • 10. Re: SELF in Custom Functions
                            BruceRobertson

                            Modified file, added a repeating field.

                            • 11. Re: SELF in Custom Functions
                              kaostika

                              Those are Fields, I am using Test Labels.  My CF works if you Pass the SELF to the CF. 

                              • 12. Re: SELF in Custom Functions
                                BruceRobertson

                                Maybe you could post a file illustrating what you're doing/trying to do. I don't quite see it right now.

                                • 13. Re: SELF in Custom Functions
                                  DavidJondreau

                                  That's how I sometimes use it. Passing a Self() to a cutom function to parse the field name.

                                   

                                  I think this is a quality of how FileMaker evaluates calculations and GetFieldName() and not anything special about Self(). Try putting the field name in, instead of Self() and you get the same result.

                                  • 14. Re: SELF in Custom Functions
                                    kaostika

                                    Here is a demo of what I am doing. 

                                     

                                    Oreste

                                    1 2 Previous Next