4 Replies Latest reply on Mar 28, 2014 2:04 AM by bigtom

    Passing a Container as a script parameter

    bigtom

      Title

      Passing a Container as a script parameter

      Post

           I have a script that is taking an image from a container and setting fields with different sizes of the same image. I need to do this for 10 images and the structure is the same. I was hoping to pass in the source container and the destination containers as parameters.

           This way I can have just one script. The few ways I have tried this are pretty much telling me that I can only pass text as a parameter. Is there any way around this? I have not tried passing the field name as text yet, but I think that will not work.

           I did not want to have to do 10 scripts for this.

        • 1. Re: Passing a Container as a script parameter
          philmodjunk
               

                    ...and setting fields with different sizes of the same image.

               You do know that you can make multiple copies of the same field and size each one differently? I must assume that you want to use something like getThumbNail to assign different fields a copy of the same image with different resolutions.

               Never tried passing the contents of a container field as a script parameter, but you can use text as a way to pass the reference to a field. This will work at least for the target field, you may need to put the source image in a field with global storage at the start of your script if it changes layouts in order to put these copies in fields of a different record and/or table.

               GetFieldName ( Table::ContainerField )

               can be used in the script parameter box to pass the Table::FieldName reference to a field. Then Set Field By Name [ Get ( ScriptParameter ) ; ...

               can set the field named in the script parameter to a value. GetField ( Get ( ScriptParameter ) ) is a function that can "read" the contents of the field named in the script parameter.

               PS; You could use quoted text: "Table::containerField" and your script will work, but using GetFieldName makes sure that if you later rename the table occurrence or field in Manage | Database, you won't need to modify the script parameter to pass the correct text to your script.

          • 2. Re: Passing a Container as a script parameter
            bigtom

                 Phil,

                 This is about right. I am using GetThumbnail to set fields at different resolutions. I do not want to have a bunch of different resolutions of the same image because this is a copy and the database grows. However, mobile users need the images to be smaller in file size or the usage gets slow.

                 I will give the text a try in a bit and let you know how it goes.

            • 3. Re: Passing a Container as a script parameter
              bigtom

                   Seems like passing text is working. Thanks.

              • 4. Re: Passing a Container as a script parameter
                bigtom

                     Well it took a bit, but I got it working. GetField was the answer but GetField ( Get ( ScriptParameter ); 1 ) gave me an issue with the number of arguments so I wrapped in GetValue to make it happy. Here is what worked in the end. Thanks Phil.