Solved

Dynamic setitem

Posted on 2011-02-14
2
537 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 500 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…

737 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