X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 26 Mar 2010 04:03 AM by  anon
sending a string as a command in IDL
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
26 Mar 2010 04:03 AM
    Hi, I'm using IDL Version 7.1. I'm trying to run a short script that will attribute the different fields in a structure to respective array variables. The structure was created by the read_csv() function. Each array in the structure corresponds to a different column in the csv file I imported from. There are 16 fields in the structure I would like to do this with. Each of the fields is named as follows: Structure_name.fieldXX, where XX are the numbers 1 to 16 corresponding to a given array in the structure. Here is some code I wrote as a start to this task: for j=1,16 do begin a=string(format="(%'x.field%2.2i')", j) b=string(format="(%'x_%2.2i')", j) print, b, '=', a endfor This gives the output, x_01=x.field01 x_02=x.field02 x_03=x.field03 x_04=x.field04 x_05=x.field05 x_06=x.field06 x_07=x.field07 x_08=x.field08 x_09=x.field09 x_10=x.field10 x_11=x.field11 x_12=x.field12 x_13=x.field13 x_14=x.field14 x_15=x.field15 x_16=x.field16 which is exactly the set of expressions that I want to send to the IDL interpreter. So my question, after all, is: How do I send the tokens that make up these strings in the from of a command to the IDL interpreter? Thanks for your time Jeff

    Deleted User



    New Member


    Posts:
    New Member


    --
    14 Apr 2010 11:48 AM
    What you can do is use the EXECUTE() function to execute the string as a command.  For example, if you did this: st = "plot, findgen(10)" x = execute(st) it will execute the function.  So in your case you can do something like this: for j=1,16 do begin a=string(format="(%'x.field%2.2i')", j) b=string(format="(%'x_%2.2i')", j) x = execute(b+'='+a) endfor
    You are not authorized to post a reply.