?
Solved

Dynamic setitem

Posted on 2011-02-14
2
Medium Priority
?
546 Views
Last Modified: 2013-12-26
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
                  dw_1.setitem(1,"s_column_2",ls_column_2)
            case 3
                  dw_1.setitem(1,"s_column_3",ls_column_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])
next

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

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.


0
Comment
Question by:Mehram
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
loks earned 2000 total points
ID: 34886570
Hi,

Another way to eliminate the SetItem is by using ImportString function.

i.e you could build up a string using Tab as delimiter between the column values and calling ImportString to import the string into DW.

This is quicker than using setitem for 16 times.

Note: Need to be careful when preparing the string if data mismatch happens between the data & the column data type in the DW then an warning would be issued and might import only upto that point.

Regards,
Loks
0
 

Author Comment

by:Mehram
ID: 34886645
Ok.

I am checking importstring.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question