Link to home
Start Free TrialLog in
Avatar of Mehram
MehramFlag for Pakistan

asked on

Dynamic setitem

version 10.5

user last input values for a particular report are already present
in string variables
ls_column_1,ls_column_2, ls_column3.... upto ls_column_16
in integer variable
Li_column_1, Li_column_2 upto Li_column_8 etc

when the user call the report next time we set his last saved values like this

FOR J  = 1 to a_stParm.s_field_req
      choose case J
            case 1
                  dw_1.setitem(1,"s_column_1", ls_column_1)
            case 2
            case 3
               and case upto 16
end choose

I wanted to get rid of repeated dw_1.setitem and did this, which worked.

arr_scolumn[] = {ls_column_1, ls_column_2,ls_column_3,ls_column_4,ls_column_5,ls_column_6,ls_column_7,ls_column_8,ls_column_9,ls_column_10,ls_column_11,ls_column_12,ls_column_13,ls_column_14,ls_column_15,ls_column_16}
arr_icolumn[] = {li_column_1, li_column_2,li_column_3,li_column_4,li_column_5,li_column_6,li_column_7,li_column_8}

FOR J  = 1 to a_stParm.s_field_req
      dw_1.setitem(1,'s_column_' + string(J), arr_scolumn[J])

FOR J  = 1 to a_stParm.i_field_req
      dw_1.setitem(1,'i_column_' + string(I), arr_icolumn[J])

This is working correctly.
My question is , can we get rid of array.

Can we do someghint like this

      dw_1.setitem(1,'s_column_' + string(J), EVALUATE (or whatever it may be) 'ls_column' + string(J))
In foxpro we can evaluate something by the sign '&', can we do something similiar here.

Avatar of loks
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mehram



I am checking importstring.