5 Replies Latest reply on Mar 22, 2013 8:35 AM by PeterMontague

    A fresh pair of eyes to review a malfunctioning logical function

    PeterMontague

      Title

      A fresh pair of eyes to review a malfunctioning logical function

      Post

            

           I use this function to copy an image from a source code into a container field. I wanted it to not add the image if the field already has an image in it. But I'm finding that the script is replacing images. I can't see what is wrong with the function. I have the If ( not isEmpty) caveat included. I experimented with the data viewer putting "1" instead of Inventory::add image as the result if the field was full. It was returning 1 telling me the field was full. So why is the calculation replacing my images?
            
           If ( not IsEmpty ( Inventory::add image ) ; Inventory::add image ; 
           Case ( Inventory::image_live = "n" ; 
           Let ( [ T = Inventory::Child Source Code ;
                  end = Position ( T ; "id=\"original-main-image\"" ; 1 ; 1 ) ;
                  start = Position ( T ; "<img src=\"" ; end ; -1 )
                  ];
                  Trim ( Middle ( T ; start + 10 ; end - start - 25 ) )
                 ) & 
           Parse ( Inventory::Child Source Code ; "registerImage(\"original_image\", \"" ; "\",\"<a href=\"+'\"'+\"" ; 1 ) ; 
           IsEmpty ( Inventory::add image ) ; 
           Let ( [ T = Inventory::Child Source Code ;
                  end = Position ( T ; "id=\"original-main-image\"" ; 1 ; 1 ) ;
                  start = Position ( T ; "<img src=\"" ; end ; -1 )
                  ];
                  Trim ( Middle ( T ; start + 10 ; end - start - 25 ) )
                 ) & 
           Parse ( Inventory::Child Source Code ; "registerImage(\"original_image\", \"" ; "\",\"<a href=\"+'\"'+\"" ; 1 )  ; Inventory::add image ) )