sashaosonia

Q: perhaps, simple question variable string in pop-up

Hi

I write a names who helped me in previous question but now list is very big and sorry, without personal nicks

Hi all

 

we have a string

 

set scany_col to {{15677, 5654, 7453}, {37008, 19532, 17733}, {32896, 15163, 14906}, {15934, 6939, 9509}, {16705, 6682, 9252}, {38293, 39064, 40092}, {19532, 6939, 8224}, {65535, 65535, 65535}, {17219, 6425, 8738}, {24158, 9509, 11051}, {14392, 5911, 8481}, {22873, 16448, 16191}, {30840, 14649, 14649}, {29041, 16191, 15934}, {12593, 5397, 8224}}


--(this is a RGB colors of the pixels)


choose from list scany_col with title "which color at the first position"

set listreturn to result

listreturn




...a-a-and this script returns a mistake "cant bla-bla with string"


Tell me please, what is wrong?



MacBook Pro, OS X El Capitan (10.11.2)

Posted on Jul 7, 2016 9:48 AM

Close

Q: perhaps, simple question variable string in pop-up

  • All replies
  • Helpful answers

  • by Niel,Solvedanswer

    Niel Niel Jul 7, 2016 9:57 AM in response to sashaosonia
    Level 10 (312,590 points)
    Mac OS X
    Jul 7, 2016 9:57 AM in response to sashaosonia

    The sublists aren't themselves strings or numbers.

     

    If you'd like to choose from one of the sublists, replace the choose from list command with:

     

    choose from list (item 1 of scany_col) with title "which color at the first position"

     

    If you'd like to pick a specific sublist out of all of them:

     

    set scany_col to {{15677, 5654, 7453}, {37008, 19532, 17733}, {32896, 15163, 14906}, {15934, 6939, 9509}, {16705, 6682, 9252}, {38293, 39064, 40092}, {19532, 6939, 8224}, {65535, 65535, 65535}, {17219, 6425, 8738}, {24158, 9509, 11051}, {14392, 5911, 8481}, {22873, 16448, 16191}, {30840, 14649, 14649}, {29041, 16191, 15934}, {12593, 5397, 8224}}

     

    set scany_strings to {}

    repeat with this_item in scany_col

    set scany_strings to scany_strings & ((item 1 of this_item as string) & ", " & (item 2 of this_item as string) & ", " & (item 3 of this_item as string))

    end repeat

    choose from list scany_strings with title "which color at the first position"

    set listreturn to result

    listreturn

     

    (143331)

  • by sashaosonia,

    sashaosonia sashaosonia Jul 7, 2016 10:34 AM in response to Niel
    Level 1 (8 points)
    Mac OS X
    Jul 7, 2016 10:34 AM in response to Niel

    Thanks again, Niel

  • by sashaosonia,

    sashaosonia sashaosonia Jul 7, 2016 10:38 AM in response to Niel
    Level 1 (8 points)
    Mac OS X
    Jul 7, 2016 10:38 AM in response to Niel

    but result returns as text like {"15934, 6939, 9509"}

    if I tell set listreturn to result as string


    it takes

    "15677, 5654, 7453"

  • by Camelot,

    Camelot Camelot Jul 7, 2016 7:32 PM in response to sashaosonia
    Level 8 (47,285 points)
    Mac OS X
    Jul 7, 2016 7:32 PM in response to sashaosonia

    Yes, but what it is you want?

     

    Since Niel's script starts off by converting the lists into a single string for you to choose, you'd need to coerce the result back to a list. Something like:

     

    set listreturn to choose from list scany_strings with title "which color at the first position"

    tell item 1 of listreturn

      set listreturn to {word 1, word 2, word 3}

    end tell

    --> {37008, 19532, 17733}