Roger
As I understand you must pass your CC and Column. data to the dlg object, 
compare how I pass version and dialogname, in my dialog, maybe there is other 
ways I am not aware of or not understand. 
But You should really use an array of arrays to hold your column data it's 
easier to to fill the listview using that.
Somehow you need to rewrite the original code to take advantage of ooRexx and 
probably in this case to use an array of arrays as the result from the sql 
statement.
my 2 c
/hex

-------------------------
Ursprungligt Meddelande:
Från: Roger Bilau <s...@bilau.de>
Till: 'Open Object Rexx Users' <oorexx-users@lists.sourceforge.net>
Kopia: 
Datum: fredag, 06 juli 2012 21:51
Ämne: Re: [Oorexx-users] How to read a variable in a methode?
Hello Mark,
due to your response and the sample which Håkan (thanks a lot for this) has
sent to me, 
I have the impression that my idea to call the new code from the existing
code does
not work. Is it so?

I insert my current test source below. As you see, first I read the DB2 data
into the 
stem column.  and  count the number of result rows in the variable CC - then
I try to read column. and CC in the ::method initDialog - is this not
possible?

If I don't want to follow your suggestion - is there no way to get the
content from
the stem and CC without general changes of my script?

Btw.: thank you and Håkan for the immediate answers ;-)

Kind regards
Roger

....
....
Database = 'SCM'
SQLStmt  = "Select COLUMN_NAME,DATA_TYPE,ORDINAL_POSITION,COLUMN_DEFAULT,",
                 " IS_NULLABLE,CHARACTER_MAXIMUM_LENGTH,",
                 " NUMERIC_PRECISION,NUMERIC_SCALE,DATETIME_PRECISION", 
            " from SYSIBM.COLUMNS", 
            "where Table_Catalog = 'SCM'",
            "  and Table_Schema = '*******'",
            "  and Table_Name = '*******'",
            "order by Ordinal_Position"

CALL SQLEXEC  'CONNECT TO'  Database
CALL CHECKERR 'Connect to'  Database
SAY "Connected to Database" Database

Call SQLEXEC  'PREPARE S51 FROM :SQLSTMT'  
Call CHECKERR 'PREPARE S51'

Call SQLEXEC  'DECLARE C51 CURSOR WITH HOLD FOR S51'  
Call CHECKERR 'DECLARE C51'

Call SQLEXEC  'OPEN C51'
Call CHECKERR 'OPEN C51'

CC = 0
CL = ''
Do until SC <> 0
   Call SQLEXEC 'FETCH C51 INTO :COLUMN_NAME_R, :Data_Type_R'
   SC = SQLCA.SQLCODE
   If SC = 0 then 
      do
       CC = CC + 1
       Say Right(Time(),10) Column_Name_R Data_Type_R
       CL = CL Strip(Column_Name_R) ' '
       Column.CC.1 = CC
       Column.CC.2 = Column_Name_R
       Column.CC.3 = Data_Type_R 
       Select
        when Pos(Word(Data_Type_R,1),'BIGINT DECIMAL DOUBLE INTEGER REAL
SMALLINT') <> 0 then
             do
             end
        when Pos(Word(Data_Type_R,1),'CHARACTER TIME DATE TIMESTAMP') <> 0
then
             do
             end
        otherwise nop 
       end 
      end
end

call SQLEXEC  'CLOSE C51'   
call CHECKERR 'CLOSE C51'

call SQLEXEC  'CONNECT RESET'                      
call CHECKERR 'CONNECT RESET'

Call ShowColumnList

Trace i
Path = "D:\Rexx\Columns.txt"
file1=.stream~new(path)                         /* Create a stream object
for the file */
file1~open("both replace")
file1~lineout(CL)                               /* Write a line to the file
*/
file1~close    

Exit

ShowColumnList:
  trace ?I
  dlg = .SelectColumn~new
  if dlg~initCode = 0 then do
    -- Add a symbolic resource ID for the list view.
    dlg~constDir[IDC_LISTVIEW] = 200

    dlg~create(30, 30, 225, 200, "Selektieren Sie bitte die gewünschten
Columns", "VISIBLE")
    dlg~execute("SHOWTOP")
  end
Return 0

CHECKERR:
  ARG ERRLOC

  If  ( SQLCA.SQLCODE = 0 ) then
    return 0                                                      
  else do
    say '--- error report ---'
    say 'ERROR occurred :' errloc
    say 'SQLCODE :' SQLCA.SQLCODE

    /******************************\
    * GET ERROR MESSAGE API called *
    \******************************/
    call SQLDBS 'GET MESSAGE INTO :errmsg LINEWIDTH 80'
    say errmsg
    say '--- end error report ---'

    If (SQLCA.SQLCODE < 0 ) then
            do
                        Say 'Error' SQLCA.SQLCODE 
                        exit
                end
    else 
                do
                        say 'WARNING - CONTINUING PROGRAM WITH ERRORS'
                        return 0
                end
  end
return 0

::requires "hostemu" LIBRARY

-- End of entry point.

::requires "ooDialog.cls"

::class 'SelectColumn' subclass UserDialog

::method defineDialog

  self~createListView(IDC_LISTVIEW, 10, 20, 205, 145, "REPORT
SHOWSELALWAYS")
  self~createPushButton(IDOK, 140, 175, 35, 15, "", "Weiter")
  self~createPushButton(IDOK, 180, 175, 35, 15, "DEFAULT", "Abbruch")
  self~connectListViewEvent(IDC_LISTVIEW, "CHECKBOXCHANGED",
onCheckboxChanged)
  self~connectListViewEvent(IDC_LISTVIEW, "CLICK", onClick)


::method initDialog
  trace ?i
  -- Get a reference to the list view.
  list = self~newListView(IDC_LISTVIEW)

  list~addExtendedStyle("FULLROWSELECT GRIDLINES CHECKBOXES HEADERDRAGDROP")

  list~insertColumn(0, "Select", 25)
  list~insertColumn(1, "Column Name", 120)
 
  do i = 1 to CC
<<<<<<<<<<<<< Here I got the problem *******
    list~addRow(i, , , Column.i.2, Column.i.3)
  end

::method onClick
  use arg id, itemIndex, columnIndex, keyState

  -- Compensate for zero-based indexes ;-(
  itemIndex += 1
  columnIndex += 1

  say 'onClick() row:' itemIndex 'column:' columnIndex 'key state:' keyState
return 0
  
::method onCheckboxChanged unguarded
  use arg id, itemIndex, state
  say ID 'Checked row:' itemIndex 'state:' State
return 0

-----Ursprüngliche Nachricht-----
Von: Mark Miesfeld [mailto:miesf...@gmail.com] 
Gesendet: Freitag, 6. Juli 2012 17:18
An: Open Object Rexx Users
Betreff: Re: [Oorexx-users] How to read a variable in a methode?

On Fri, Jul 6, 2012 at 7:42 AM, Roger Bilau <s...@bilau.de> wrote:
>
> in the past I used ooRexx without the object oriented part. Now I make 
> my first step's with classes and methods because I want to integrate some
dialog functions in my scripts.
> My first try is to combine a routine that read column name from DB2 
> and I like to show it in a list view window. For this I take the
columnClickListView.rex sample and modified it.


Sounds like a good start.  But, I would suggest that you think of it as
taking a list view dialog and combining it with your routine.  It's a subtle
point, but I think you will have less trouble trying to add a routine to a
list view dialog than you will have trying to force a routine to use a
dialog.


>
>
> My problem is: the variables I filled with the data from DB2 I cannot 
> read in the ::method initDialog


Why not? ;-)  Post a little more information on what you routine that reads
the column names from DB2 looks like.

Here is a rough sketch of an approach.

Håkan

  -- Get a reference to the list view.
  list = self~newListView(IDC_LISTVIEW)

  list~addExtendedStyle("FULLROWSELECT GRIDLINES CHECKBOXES HEADERDRAGDROP")

  -- Call your routine to get the column names, but I don't have any idea
what you routine
  -- looks like so it is hard to do this part.

  col1Name = getDB2columnName(1)
  list~insertColumn(0, col1Name, 80)

  col2Name = getDB2columnName(2)
  list~insertColumn(1, col2Name, 80)

  col3Name = getDB2columnName(3)
  list~insertColumn(2, col3Name, 70)

  do i = 1 to 200
    data = getDB2rowData(i)
    list~addRow(i, data~col1, data~col2, data~col3)
  end

There is no reason you can not call your routine from the dialog code.

The above code's idea is this: call your routine to get the column names for
a table in DB2 that has 3 columns.  Set the column names in the list view to
those 3 column names.  Call your routine to get the row data for 200 rows
and fill in the list view with that data.

The other approach would be to assemble your data first using your DB2
routines and pass it into the dialog.  But, the approach above would be
better I think.

As is usual in trying to give help, the more information you provide the
better help you will get.  Without knowing anything about what your existing
routines are like, it is difficult to give you back specifics.

--
Mark Miesfeld

----------------------------------------------------------------------------
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and threat
landscape has changed and how IT managers can respond. Discussions will
include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Oorexx-users mailing list
Oorexx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-users


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Oorexx-users mailing list
Oorexx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-users

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Oorexx-users mailing list
Oorexx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-users

Reply via email to