Forum Discussion

raynjay's avatar
raynjay
Occasional Contributor
7 years ago
Solved

How to print image repository name as string in log message ?

 

HI,

 

My script function is like below.

input parameter, img is one of Image repository such as (ImageRepository.android_app_launcher.TextView_pooq)

but log message isn't printed. 

 

How can I print Image repository name as a string in Log Message ?

 

 

function ImageName(img)
  if (img.Exists())
  {
     img.Touch();
     Log.Message(img + "Touched");
  }
}

 

 

  • Actually, disregard my previous message... I was misreading the help file.  shankar_r's solution is also incorrect because we're not dealing with a mapped object but an item in the image repository.

     

    I'm not finding a property on those objects that corresponds to the name itself.  Suffice it to say, the parameter "img" that you're passing in is the image object itself so you can't use it to log as part of a message.  What I would suggest is something more like this:

     

    function imageTouch(imageSetName, imageName){ //Here I would pass in the string of the two parts of the image.
      var imageSet;
      var imageItem;
      imageSet = ImageRepository[imageSetName];
      imageItem = imageSet[imageName];
      if (imageItem.Exists())
      {
         imageItem .Touch();
         Log.Message("ImageRepository." + imageSetName + "." + imageName +" Touched");
      }
    }

4 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Actually, disregard my previous message... I was misreading the help file.  shankar_r's solution is also incorrect because we're not dealing with a mapped object but an item in the image repository.

     

    I'm not finding a property on those objects that corresponds to the name itself.  Suffice it to say, the parameter "img" that you're passing in is the image object itself so you can't use it to log as part of a message.  What I would suggest is something more like this:

     

    function imageTouch(imageSetName, imageName){ //Here I would pass in the string of the two parts of the image.
      var imageSet;
      var imageItem;
      imageSet = ImageRepository[imageSetName];
      imageItem = imageSet[imageName];
      if (imageItem.Exists())
      {
         imageItem .Touch();
         Log.Message("ImageRepository." + imageSetName + "." + imageName +" Touched");
      }
    }