Error with Tdatarow - only for test - RESOLVED

Error with Tdatarow - only for test - RESOLVED

Postby Silvio.Falconi » Fri Feb 01, 2019 10:51 am

I'm trying to create a dialog for edit a record with tdatabase

oBrw:bEdit := { |oRec| EditServizi( oRec ) }
@ 300,328 BUTTON "ADD" SIZE 100,40 PIXEL OF oDlg ACTION oBrw:EditSource()

Image


when I add these commands on dialog it make error

@ 66,120 XIMAGE oRec:Image SOURCE IF(empty(oRec:Image),cDefaImage,oRec:Image);
SIZE 50, 50 OF oDlg

the code
Code: Select all  Expand view  RUN



Function EditServizi( oRec )
   local lAdd  := ( oRec:RecNo == 0 )
   local lSave := .F.
   local oFont
   local oBtn
   local oDlg
   local oBtnImage
   local cFile :=""
   local cDefaImage:="noImage.png"


   DEFINE FONT oFont NAME "TAHOMA" SIZE 0, 15
   DEFINE DIALOG oDlg SIZE 422, 326 PIXEL ; //FROM 100, 100 TO 426,522;
   TITLE If( lAdd, "New Service", "Edit Service" ) FONT oFont

  @ 12, 10 SAY "Code:" OF oDlg SIZE 19, 8 PIXEL
  @ 10, 46 GET oRec:ID     OF oDlg SIZE 55, 12 PIXEL PICTURE "@!" UPDATE

  @ 26, 10 SAY "Name:" OF oDlg SIZE 15, 8 PIXEL
  @ 24, 46 GET oRec:Name    OF oDlg SIZE 105, 12 PIXEL UPDATE ;
   VALID !Empty( oRec:Name )

   @ 40, 10 SAY "Breve:" OF oDlg SIZE 15, 8 PIXEL
   @ 38, 46 GET oRec:Breve     OF oDlg SIZE 105, 12 PIXEL UPDATE

   @ 54, 10 SAY "Prezzo:" OF oDlg SIZE 31, 8 PIXEL
   @ 52, 46 GET oRec:Price OF oDlg SIZE 55, 12 PIXEL UPDATE  RIGHT

   @ 68, 10 SAY "Immagine:" OF oDlg SIZE 31, 8 PIXEL FONT oFont
   @ 66, 46 GET oRec:Image OF oDlg SIZE 155, 12 PIXEL UPDATE

   @ 68,10 BTNBMP oBtnImage PROMPT "Carica"  ;
   RESOURCE "BTN_PNG_IMAGE" FLAT ;
   SIZE 45,18 LEFT PIXEL OF oDlg ;
   ACTION ( oRec:Image:= GetImage( cFile ), oRec:Image:SetSource(  oRec:Image ))
   oBtnImage:ctooltip:="Carica un immagine"


  /*  @ 66,120 XIMAGE  oRec:Image SOURCE IF(empty(oRec:Image),cDefaImage,oRec:Image);
               SIZE 50, 50 OF oDlg
                           oRec:Image:bRClicked  := NIL
                           oRec:Image:ltransparent:=.t.
                           oRec:Image:nUserControl :=0

    */


   @ 82, 10 SAY "Unità disponibili:" OF oDlg SIZE 13, 8 PIXEL
   @ 80, 46 GET oRec:unit    OF oDlg SIZE 40, 12 PIXEL UPDATE

  * @ 96, 10 SAY "Print A4:" OF oDlg SIZE 28, 8 PIXEL
   @ 94, 46 CHECKBOX oRec:A4  PROMPT "Print A4" OF oDlg SIZE 105, 12 PIXEL UPDATE

  * @ 110, 10 SAY "Print Pos:" OF oDlg SIZE 23, 8 PIXEL
   @ 108, 46 CHECKBOX oRec:Pos PROMPT "Print Pos"   OF oDlg SIZE 105, 12 PIXEL UPDATE

 *  @ 124, 10 SAY "Email:" OF oDlg SIZE 19, 8 PIXEL
 *  @ 122, 46 GET oRec:Email    OF oDlg SIZE 105, 12 PIXEL UPDATE

  @ 144, 121 BTNBMP oBtn PROMPT "Save" OF oDlg SIZE 42, 14 PIXEL FLAT ACTION (oDlg:End(), lSave := .T.) ;
      WHEN oRec:Modified()

   @ 144, 165 BTNBMP oBtn PROMPT "Cancel" OF oDlg SIZE 42, 14 PIXEL FLAT ACTION (oDlg:End())
   oBtn:lCancel   := .t.

     ACTIVATE DIALOG oDlg CENTERED;
      ON PAINT ( oDlg:Box( 10, 10, 278, 412 ) )
    IF lSave
      oRec:Save( .T. )
   ENDIF

   RETURN NIL


Code: Select all  Expand view  RUN
Application
===========
   Path and name: C:\Work\Errori\Nages_ordine_tdatabase\test.Exe (32 bits)
   Size: 3,879,936 bytes
   Compiler version: Harbour 3.2.0dev (r1712141320)
   FiveWin  version: FWH 18.10
   C compiler version: Borland/Embarcadero C++ 7.3 (32-bit)
   Windows version: 6.1, Build 7601 Service Pack 1

   Time from start: 0 hours 0 mins 1 secs
   Error occurred at: 02/01/18, 11:43:54
   Error description: Error BASE/33  Data type error: TDATAROW:IMAGE
   Args:
     [   1] = O   TDATAROW

Stack Calls
===========
   Called from:  => __ERRRT_SBASE( 0 )
   Called from: ../../../tobject.prg => TDATAROW:ERROR( 0 )
   Called from: .\source\classes\DATAROW.PRG => TDATAROW:FIELDPUT( 491 )
   Called from: .\source\classes\DATAROW.PRG => TDATAROW:_IMAGE( 2089 )
   Called from: test.prg => EDITSERVIZI( 256 )
   Called from: test.prg => (b)MAIN( 64 )
   Called from: .\source\classes\DATAROW.PRG => TDATAROW:EDIT( 1606 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:EDIT( 10643 )
   Called from: .\source\classes\XBROWSE.PRG => (b)TXBROWSE( 748 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:EDITSOURCE( 0 )
   Called from: test.prg => (b)MAIN( 98 )
   Called from: .\source\classes\BUTTON.PRG => TBUTTON:CLICK( 179 )
   Called from: .\source\classes\CONTROL.PRG => TBUTTON:HANDLEEVENT( 1755 )
   Called from: .\source\classes\WINDOW.PRG => _FWH( 3541 )
   Called from:  => SENDMESSAGE( 0 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:COMMAND( 433 )
   Called from:  => TWINDOW:HANDLEEVENT( 0 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:HANDLEEVENT( 1136 )
   Called from:  => DIALOGBOXINDIRECT( 0 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 304 )
   Called from: test.prg => MAIN( 121 )




How I can make to incremental oRec:ID ( id is 4 Cr) sample "0001"
Last edited by Silvio.Falconi on Fri Feb 01, 2019 11:46 am, edited 1 time in total.
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7075
Joined: Thu Oct 18, 2012 7:17 pm

Re: Error with Tdatarow - only for test

Postby nageswaragunupudi » Fri Feb 01, 2019 10:56 am

Show the full structure of the DBF
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10655
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Error with Tdatarow - only for test

Postby Silvio.Falconi » Fri Feb 01, 2019 11:08 am

Rao is the same of oServizi
viewtopic.php?f=3&t=36678
Code: Select all  Expand view  RUN
Function BuildDbf()

   FIELD ID,NAME,ORDINE

   local oDbf
   local aCols       := { ;
                     { "id"    , "C",    4, 0 },;
                     { "name"  , "C",   30, 0 },;
                     { "breve"  , "C",  10, 0 },;
                     { "price" , "N",    9, 2 },;
                     { "image" , "C",   30, 0 },;
                     { "struttura","C", 30, 0 },;
                     { "unit"  , "N",    4, 0 },;
                     { "a4"    , "L",    1, 0 },;
                     { "pos"   , "L",    1, 0 },;
                     { "multiple", "L",  1, 0 },;
                     { "islock"  , "L",  1, 0 },;
                     { "ordine"  , "N",  2, 0 } }

 //sample data
   local aData       := { ;
{ "0001","Lettino","lettino",10,".\images\Lettino.png","",100,.t.,.t.,.f.,.t.,1 }, ;
{ "0002","Sdraio","sdraio",10,".\images\sdraio.png","",100,.t.,.t.,.f.,.t.,2 }, ;
{ "0003","Regista","regista",10,".\images\regista.png","",100,.t.,.t.,.f.,.t.,3 }, ;
{ "0004","Parcheggio","parcheggio",10,".\images\parcheggio.png","",100,.t.,.t.,.f.,.t.,4 }, ;
{ "0005","Lettino+sdrario+regista","ser5",18,".\images\5.png","[lettino][sdraio][regista]",0,.t.,.t.,.t.,.t.,5 }, ;
{ "0006","sdrario+lettino","ser6",12,".\images\6.png","[sdraio][lettino]",0,.t.,.t.,.t.,.t.,6 }, ;
{ "0007","regista+lettino","ser7",16,".\images\7.png","[regista][lettino]",0,.t.,.t.,.t.,.t.,7 } }


   oDbf  := TDatabase():Create( "SERVIZI.DBF", aCols, "DBFCDX", "*" )
   oDbf:ArrayToDbf( aData )
   oDbf:Close()

   RETURN NIL

 
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7075
Joined: Thu Oct 18, 2012 7:17 pm

Re: Error with Tdatarow - only for test

Postby nageswaragunupudi » Fri Feb 01, 2019 11:27 am

oRec:Image is character field
You can assign only a character value.
If you assign a different type you will get runtime error.

That is not error with tdatarow.
Error with your usage.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10655
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Error with Tdatarow - only for test

Postby Silvio.Falconi » Fri Feb 01, 2019 11:31 am

Image

Now I try with

Local cImage:= oRec:Image
Local oImage


@ 58,150 BTNBMP oBtnImage PROMPT "Carica" ;
RESOURCE "BTN_PNG_IMAGE" FLAT ;
SIZE 42, 14 LEFT PIXEL OF oDlg ;
ACTION ( cImage:= GetImage( cFile ), oImage:SetSource( cImage ),oImage:refresh())
oBtnImage:ctooltip:="Carica un immagine"


@ 78,150 XIMAGE oImage var cImage SOURCE IF(empty(cImage),cDefaImage,cImage);
SIZE 50, 50 OF oDlg
oImage:bRClicked := NIL
oImage:ltransparent:=.t.
oImage:nUserControl :=0



but on modify I not see the cimage
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7075
Joined: Thu Oct 18, 2012 7:17 pm

Re: Error with Tdatarow - only for test

Postby Silvio.Falconi » Fri Feb 01, 2019 11:39 am

trying with

@ 78,150 XIMAGE oImage var cImage SOURCE IF(empty(oRec:Image),cDefaImage,oRec:Image);
SIZE 50, 50 OF oDlg

run ok
but the when I make oRec:save it save al so the image ?

nooooo!!!
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7075
Joined: Thu Oct 18, 2012 7:17 pm

Re: Error with Tdatarow - only for test

Postby Silvio.Falconi » Fri Feb 01, 2019 11:45 am

ok resolved

local cFile :=""
local cDefaImage:="noImage.png"
Local cImage:= oRec:Image
Local oImage
local cImgPath:=".\images\"


@ 68, 10 SAY "Immagine:" OF oDlg SIZE 31, 8 PIXEL FONT oFont
@ 66, 46 GET oRec:Image OF oDlg SIZE 55, 12 PIXEL UPDATE

@ 58,150 BTNBMP oBtnImage PROMPT "Carica" ;
RESOURCE "BTN_PNG_IMAGE" FLAT ;
SIZE 42, 14 LEFT PIXEL OF oDlg ;
ACTION ( cImage:= GetImage( cFile ), oImage:SetSource( cImage ),oImage:=cImage)
oBtnImage:ctooltip:="Carica un immagine"


@ 78,150 XIMAGE oImage var cImage SOURCE IF(empty(oRec:Image),cDefaImage,oRec:Image);
SIZE 50, 50 OF oDlg
oImage:bRClicked := NIL
oImage:ltransparent:=.t.
oImage:nUserControl :=0


IF lSave
oRec:Image:= cImgPath+UrlImage(cImage)
oRec:Save( .T. )
ENDIF
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7075
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 35 guests