Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Dynamic setitem

Posted on 2011-02-14
2
Medium Priority
?
549 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’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

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

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…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand column That will then direct you to their download page. From that p…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
Suggested Courses

636 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