2 Replies Latest reply on Oct 15, 2012 12:39 PM by ijontichy

    Can you create a script that can determine on its own what field it's supposed to be affecting?

    ijontichy

      Title

      Can you create a script that can determine on its own what field it's supposed to be affecting?

      Post

           I work with a type of data called timecode which is very similar to regular time, but very specifically formatted.

           So, 02:20:30:12 refers to Hour 2, Minute 20, second 30 and frame 12 of a motion picture clip. 

           I have several fields where this information has to be entered and I have a script that allows someone to enter the numbers without the required colons and then the script formats it with colons so that it reads the way we're used to reading timecode and exports timecode compatible values for other processes.

            The thing is, I have to build a specific triggered script for each timecode field to which I want this reformatting to apply and it strikes me I'm missing something basic.

            

           Is there a way to make the script more aware so that it first identifies the layout and field it needs to be affecting and then makes the change?

           Thanks in advance!

            

           e.

            

            

        • 1. Re: Can you create a script that can determine on its own what field it's supposed to be affecting?
          philmodjunk

               You should be able to use an auto-enter calculation that reformats this for you without needing any script. If you use "self" (without the quotes) to refer to the contents of the field, you can then copy and paste this same expression into multiple field definitions should this be needed. By making this happen at the data level, your field will be automatically self correcting whereever you place it on your layouts.

               Do do what you want with a script, you can pass the Table Occurrence (NOT the layout) name and field name as a script parameter. I recommend this expression, with your actual names inserted in place of "yourTable::YourField": GetFieldName ( YourTable::YourField ). This expression will automatically adjust should you use manage | Database to rename the field.

               In your script, you can then use GetField( Get ( ScriptParameter ) ) to reference the contents of the field and you can use Set Field By Name [ Get ( ScriptParameter ) ;....] to modify the contents of the same field.

          • 2. Re: Can you create a script that can determine on its own what field it's supposed to be affecting?
            ijontichy

                 Thank you, Phil! 

                  

                 A little "SELF" knowledge was just the ticket.