1. Roland Smith
  2. PowerBuilder
  3. Tuesday, 25 January 2022 22:09 PM UTC

I want to get column data from a DataWindow into a string array. This can be done with dot notation:

String ls_array[]

ls_array = dw_1.Object.emp_name.Current

 

The problem is that I need to do it generically. Is there a way to do this with the column name in a string variable?

 

John Fauss Accepted Answer Pending Moderation
  1. Tuesday, 25 January 2022 23:05 PM UTC
  2. PowerBuilder
  3. # 1

Hi, Roland -

Use Describe to obtain the desired column's ID. Get the row count.

Use the following dot notation to copy all values for that column in all rows:

ls_array = dw_1.Object.Data.Primary.Current[1,li_column_id,ll_rowcount,li_column_id]

Comment
  1. Miguel Leeuwe
  2. Tuesday, 25 January 2022 23:16 PM UTC
Oops! ... I hit ctrl+S to save and now my answer is GONE! anyway we have (had) the same answer. Wow, never use Ctrl+S ... your answer might be gone!
  1. Helpful
  1. Roland Smith
  2. Thursday, 27 January 2022 01:40 AM UTC
This requires assignment to a structure which must be created before hand.
  1. Helpful
  1. Miguel Leeuwe
  2. Thursday, 27 January 2022 02:41 AM UTC
Roland, also needs a structure if your only selecting one column? What about using an array of type any instead of string?
  1. Helpful
There are no comments made yet.
mike S Accepted Answer Pending Moderation
  1. Tuesday, 25 January 2022 22:33 PM UTC
  2. PowerBuilder
  3. # 2

this might work:

dwobject ldwo_object  

ldwo_object = dw.Object.__get_attribute(ls_columnname, True) //undocumented & unsupported

ls_array[] = ldwo_object.Current

Comment
  1. Miguel Leeuwe
  2. Thursday, 27 January 2022 02:30 AM UTC
yes, we did ask for it to become supported in 2017 https://community.appeon.com/index.php/qna/q-a/pb-internal-function-access

I can't remember what the second boolean parameter was for, but I always use FALSE and things work great.
  1. Helpful
  1. mike S
  2. Thursday, 27 January 2022 05:28 AM UTC
i have no idea what the 2nd parm is for. i always use TRUE! maybe if everyone keeps asking for it to be supported and documented it will be
  1. Helpful
  1. Miguel Leeuwe
  2. Thursday, 27 January 2022 07:33 AM UTC
yes, let me poke Julie on that same link :)

  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.