Using SetRemoteClipboard w/variable

I've gotten SetRemoteClipboard to work with a fixed string but I'd like to get it to work with items in a list. Is there a way I can loop through a list and pass each item through the clipboard to the SUT for evaluation?

SetRemoteClipboard "Charlie" //works

put ("Al","Bob","Charlie") into NAMES
put item 3 of NAMES into SetRemoteClipboard //doesn't work

Comments

  • EggplantMattEggplantMatt ForumAdmin admin
    What your code currently does is to put your variable into another local variable called SetRemoteClipboard. You need to use the same syntax you used when passing "Charlie" to the remote clipboard:
    setRemoteClipboard item 3 of NAMES
    
    So the complete code to iterate through your list and paste each name (followed by a return) would look like this:
    put ("Al","Bob","Charlie") into NAMES 
    repeat with each item of NAMES
    	setRemoteClipboard it
    	typeCommand "v"
    	typeText return
    end repeat
    
    Hope this helps.
  • Thank You!

    That did it, one more piece of the puzzle down. I had seen the "it" of "setRemoteClipboard it" somewhere but didn't know how "it" worked.

    Combine this with pulling X and Y coordinates from two ImageLocations and I'm going to be able to populate a grid with test data on the SUT.

    Many thanks for the timely and helpful information, Bruce
  • EggplantMattEggplantMatt ForumAdmin admin
    Glad we could help. Here's a little more information:

    "It" is a built-in SenseTalk variable that is automatically assigned the value of the current item in a repeat loop. So if you just use the "repeat with each item of" form of the repeat, then you can refer to "it" in the body of your loop to access the current item. You can also replace the word "item" with a variable name of your choosing and then refer to that variable in your loop instead of "it":
    put ("Al","Bob","Charlie") into NAMES 
    repeat with each name of NAMES
    	setRemoteClipboard name
    	typeCommand "v"
    	typeText return
    end repeat
    

    This can sometimes be a little clearer.
Sign In or Register to comment.