X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 25 Feb 2023 04:31 AM by  Kathleen Finch
program routine arguments as lists and hashes
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

Evan Fishbein



New Member


Posts:1
New Member


--
07 Feb 2023 06:17 PM
    Does idl have a syntax like python when arguments and keywords can be accessed using lists (*arg) and dictionaries (**kwargs).?
    I'm trying to write code that cycles through the supplied arguments and it seems that builtins like print, string and create_struct have this capabilities, but user written routines do not.

    Ben Castellani



    Basic Member


    Posts:130
    Basic Member


    --
    17 Feb 2023 10:30 AM
    IDL does not have anything equivalent to that functionality you mention from Python. The dynamic handling of argument expressions in things like STRING and HELP are built directly into those specific (C code) sub-routines. There's nothing magic happening in IDL.

    IDL arguments are not tightly typed nor do they define what size the argument needs to be. So the argument provided can be anything and it is up to the function to parse it properly. Something like this:

    
    pro printValues, value
       foreach val, value do print,val
    end
    
    a = [1,2,3]
    printValues,a
    
    ;IDL print,
    ;1
    ;2
    ;3
    
    end 

    Kathleen Finch



    New Member


    Posts:1
    New Member


    --
    25 Feb 2023 04:31 AM
    Thanks for helping me as well :)
    You are not authorized to post a reply.