How can I access an item of a list within a list

I pass as a parameter to a function a list, making parameterList a list of lists within said function.

How can I access the items in the inner lists? So far I have tried things like:

set host to item 1 of item 1 of parameterList()
set host to item 1 of param(1)
set host to param(1)(1)

--but none of these give me the first item in the first list within the enclosing parameter list

I looked in the sensetalk reference that testplant provides and came up empty handed (i imagine it belongs around page 105?). TIA4AH (got that? ^_^)

Comments

  • SenseTalkDougSenseTalkDoug ForumAdmin admin
    Your first two examples should both have worked, so perhaps you're not really passing what you think you are? If you post more of your code, including the call to the function, we may be able to tell more.

    Another option that might also simplify things would be to provide named parameters in the function to receive the incoming values.
  • The problem ended up being that I was calling my function using named variables and parsing them as though they would be in a format like:

    (("abc", "def"), ("hij", "klm", "n"), ... )

    but they were actually in a format like:

    (variable1name:("abc", "def"), variable2name:("hij", "klm", "n"), ... )

    I didn't realize it made a difference--but now that I think about it, using the named variables would probably allow for both ways of function calling. Thanks!
  • SenseTalkDougSenseTalkDoug ForumAdmin admin
    Yes, when you use names like that you are creating what we call a "property list" which, despite the similar name, is distinctly different from a "list". You can't access the "items" of a property list (by number) but must access its properties (by name) instead.

    I'm glad you figured out what was happening.
Sign In or Register to comment.