X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 27 Oct 2017 08:13 AM by  David Starbuck
Creating Series of parameter lists automatically
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

Alireza Taravat



New Member


Posts:1
New Member


--
27 Jun 2017 08:19 AM
    Creating Series of parameter lists automatically

    I would like to know if there is any way to create something like this automatically:
    untitled_0 = strarr(12)
    untitled_1 = strarr(30)
    untitled_2 = strarr(50)
    untitled_3 = strarr(40)
    untitled_4 = strarr(60)
    untitled_5 = strarr(80)
    The number of untitled is not fix and it depends on my input.
    So it is possible to create the names like this somehow:

    For k = 0, 5 do begin
    Untitled_(k) = ………………..
    Endfor

    David Starbuck



    Basic Member


    Posts:143
    Basic Member


    --
    27 Oct 2017 08:13 AM
    You can use the EXECUTE function to achieve this goal. An example is shown below:

    pro dj_forum_242017
    compile_opt idl2

    for ii = 1L, 5 do begin
    command = "untitled_" + STRTRIM(ii, 2) + " = strarr(" + STRTRIM(ii,2) + ")"
    output = EXECUTE(command)
    endfor

    help

    end

    I hope this helps.

    David Starbuck
    -Harris
    You are not authorized to post a reply.