FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour xBrowse - Add Array
Posts: 85
Joined: Mon Apr 18, 2011 02:32 AM
xBrowse - Add Array
Posted: Tue Oct 09, 2012 04:17 AM
Hi All,

I have a problem with xBrowse and array,
if I want to add record ( array ) in a xbrowse in the same times,
but the result is a blank record.....??

my code like this:
Code (fw): Select all Collapse
#include "FiveWin.ch"
#include "xbrowse.ch"

func main
  local oDlg

  local nWidth      := GetSysMetrics( 0 )
  local nHeight     := GetSysMetrics( 1 )
  local nLeft
  local oBrw, aData := {{"",ctod("00-00-0000"),0,""}}

  local oHeadfont := TFont():New("Segoe UI Light",,-32, .F.,.F.,,,,.F.)
  local oDatafont := TFont():New("Segoe UI Light",,-14, .F.,.F.,,,,.F.)

  fwNumFormat( 'E', .t. )

  nLeft   := nWidth/7/2.05
  nHeight := (((nHeight - 100)/ 3 ) * 2 ) // - 20

    DEFINE DIALOG oDlg ;
             FROM 100, -6 ;
               TO nHeight+200, nWidth + 6 ;
            PIXEL ;
            STYLE nOr( DS_MODALFRAME, WS_POPUP ) ;
            COLOR CLR_BLACK, CLR_CYAN ;
             FONT odatafont

      @  1,(nWidth/2)-100 say "Test Import" of oDlg size 100, 32 pixel font oHeadfont color CLR_WHITE, CLR_CYAN

      @ 5,10 BTNBMP prompt "&Import"  size 80, 12  font odatafont OF oDlg center 2007 noborder ;
          action (  aData := do_import_array( aData ), ;
                    oBrw:aArrayData := aData, ;
                    oBrw:refresh() )

                    // oBrw:SetArray( aData ) )

    @  2,1 XBROWSE oBrw ARRAY aData OF oDlg ;
          FIELDS  oBrw:aRow:cNo, oBrw:aRow:dDate, oBrw:aRow:nRow, oBrw:aRow:cDesc ;
          HEADERS "No","Date","Row","Desc." ;
          COLSIZES 100, 100, 100, 500 ;
          SIZE 600, 230 ;
          CELL LINES NOBORDER

          oBrw:lHScroll  = .T.
          oBrw:lVScroll  = .T.
          oBrw:lRecordSelector = .F.

          oBrw:CreateFromCode()
          oBrw:SetFocus()

  activate dialog oDlg

  odatafont:end()
  oheadfont:end()

return .F.

static func do_import_array( aData )
  local i := 0
  for i := 1 to 5
    aadd( aData, { str(i,5), dtoc( date() + 1 ), i + 100, "test i + 100" } )
  next i

  return aData


someone can help me..?

Mulyadi.
Posts: 2064
Joined: Fri Jan 06, 2006 09:28 PM
Re: xBrowse - Add Array
Posted: Tue Oct 09, 2012 04:46 AM

saludos intenta cambiando aData := {{"",ctod("00-00-0000"),0,""}}, por

aData := {"",ctod("00-00-0000"),0,""}

fijate que lo defines de una forma, y luego grabas de otra, bueno, creo ese es el detalle, intenta a ver...

aadd( aData, { str(i,5), dtoc( date() + 1 ), i + 100, "test i + 100" } )

saludos... :shock:

Dios no está muerto...



Gracias a mi Dios ante todo!
Posts: 85
Joined: Mon Apr 18, 2011 02:32 AM
Re: xBrowse - Add Array
Posted: Tue Oct 09, 2012 06:10 AM

Hi
Thanks for reply,
but I have Array in 2 dimensions.

any one can help me...?

Mulyadi

Posts: 117
Joined: Tue Jan 03, 2006 06:18 PM
Re: xBrowse - Add Array
Posted: Tue Oct 09, 2012 08:36 AM
Dear Mulyadi,

try this ,

Code (fw): Select all Collapse
#include "FiveWin.ch"
#include "xbrowse.ch"

func main
  local oDlg

  local nWidth      := GetSysMetrics( 0 )
  local nHeight     := GetSysMetrics( 1 )
  local nLeft
  local oBrw, aData := {{"",ctod("00-00-0000"),0,""}}

  local oHeadfont := TFont():New("Segoe UI Light",,-32, .F.,.F.,,,,.F.)
  local oDatafont := TFont():New("Segoe UI Light",,-14, .F.,.F.,,,,.F.)

  fwNumFormat( 'E', .t. )

  nLeft   := nWidth/7/2.05
  nHeight := (((nHeight - 100)/ 3 ) * 2 ) // - 20

    DEFINE DIALOG oDlg ;
             FROM 100, -6 ;
               TO nHeight+200, nWidth + 6 ;
            PIXEL ;
            STYLE nOr( DS_MODALFRAME, WS_POPUP ) ;
            COLOR CLR_BLACK, CLR_CYAN ;
             FONT odatafont

      @  1,(nWidth/2)-100 say "Test Import" of oDlg size 100, 32 pixel font oHeadfont color CLR_WHITE, CLR_CYAN

      @ 5,10 BTNBMP prompt "&Import"  size 80, 12  font odatafont OF oDlg center 2007 noborder ;
          action (  aData := do_import_array( aData ), ;
                    oBrw:aArrayData := aData, ;
                    oBrw:refresh() )

                    // oBrw:SetArray( aData ) )

    @  2,1 XBROWSE oBrw ARRAY aData OF oDlg ;
          HEADERS "No","Date","Row","Desc." ;
          COLSIZES 100, 100, 100, 500 ;
          SIZE 600, 230 ;
          CELL LINES NOBORDER ;
          AUTOCOLS
          

          oBrw:lHScroll  = .T.
          oBrw:lVScroll  = .T.
          oBrw:lRecordSelector = .F.

          oBrw:CreateFromCode()
          oBrw:SetFocus()

  activate dialog oDlg

  odatafont:end()
  oheadfont:end()

return .F.

static func do_import_array( aData )
  local i := 0
  for i := 1 to 5
    aadd( aData, { str(i,5), dtoc( date() + 1 ), i + 100, "test i + 100" } )
  next i

return aData


regards,

kok
Posts: 85
Joined: Mon Apr 18, 2011 02:32 AM
Re: xBrowse - Add Array
Posted: Tue Oct 09, 2012 08:53 AM

Hallo joek hoa... :)
Thanks for reply

the result is wrong, all record to display just in 1 colums..
if I define array at the top the result is okay.. but i want to create dinamic xbrowse with array..

Any idea...?

Mulyadi.

Posts: 117
Joined: Tue Jan 03, 2006 06:18 PM
Re: xBrowse - Add Array
Posted: Tue Oct 09, 2012 08:56 AM

Hi Mulyadi,

you must put AUTOCOLS.

here everything ok.

regards,

Kok

Posts: 117
Joined: Tue Jan 03, 2006 06:18 PM
Re: xBrowse - Add Array
Posted: Tue Oct 09, 2012 10:04 AM
Hi Mulyadi,

compile using fivewin version 12.07 + bcc63

http://dl.dropbox.com/u/55109320/pic.jpg

regards,

kok
Posts: 85
Joined: Mon Apr 18, 2011 02:32 AM
Re: xBrowse - Add Array
Posted: Tue Oct 09, 2012 05:37 PM

Oke. Thanks Kok Joek Hoa

now I using old version 11.12, xHarbour 121 rev 6406.
and If I compile with version 6.12, the result is okay. :)
or have a bugs in my library...

maybe I must be using a trick like: save and retrieve from RecordSet.

Mulyadi.

Continue the discussion