To Nages Problem with Tdatabase and new DAtepick

To Nages Problem with Tdatabase and new DAtepick

Postby Silvio.Falconi » Mon May 03, 2021 8:29 am

On a Edit dialog I have

Code: Select all  Expand view


@ 6,120 SAY "Dal :"  SIZE 20,11 PIXEL OF oFolder:aDialogs[1]  TRANSPARENT FONT oBold
      @  3, 140 DTPICKER aGet[3] VAR ddcheckin SIZE 80,12 PIXEL OF oFolder:aDialogs[1] ;
      PICTURE "ddd dd mmm yyyy"

   WITH OBJECT aGet[3]
      :lNoToday         := .t.
      :lNoTodayCircle   := .t.
      :SetRange( dStagioneMin,dStagioneMax )
   END

      @ 23,120 SAY "al :"  SIZE 20,11 PIXEL OF oFolder:aDialogs[1]   TRANSPARENT FONT oBold

          @  22,140 DTPICKER aGet[4] VAR ddcheckout SIZE 80,12 PIXEL OF oFolder:aDialogs[1] ;
      PICTURE "ddd dd mmm yyyy"  UPDATE

    WITH OBJECT aGet[4]
      :lNoToday         := .t.
      :lNoTodayCircle   := .t.
      :SetRange( ddcheckin, dStagioneMax  )
   END

 


If I use directly oPrenotazione:check_in instead of aGet[3] VAR ddcheckin

or oPrenotazione:chek_out instead of aGet[4] VAR ddcheckout

Code: Select all  Expand view

@ 6,120 SAY "Dal :"  SIZE 20,11 PIXEL OF oFolder:aDialogs[1]  TRANSPARENT FONT oBold
      @  3, 140 DTPICKER oPrenotazione:check_in SIZE 80,12 PIXEL OF oFolder:aDialogs[1] ;
      PICTURE "ddd dd mmm yyyy"

   WITH OBJECT oPrenotazione:check_in
      :lNoToday         := .t.
      :lNoTodayCircle   := .t.
      :SetRange( dStagioneMin,dStagioneMax )
   END

      @ 23,120 SAY "al :"  SIZE 20,11 PIXEL OF oFolder:aDialogs[1]   TRANSPARENT FONT oBold

          @  22,140 DTPICKER oPrenotazione:check_out  SIZE 80,12 PIXEL OF oFolder:aDialogs[1] ;
      PICTURE "ddd dd mmm yyyy"  UPDATE

    WITH OBJECT oPrenotazione:check_out
      :lNoToday         := .t.
      :lNoTodayCircle   := .t.
      :SetRange(oPrenotazione:check_in, dStagioneMax  )
   END




 




the dialog make this error

Error description: Error BASE/1005 Variabile non disponibile: LNOTODAY
Args:
[ 1] = D - -
[ 2] = L .T.

Stack Calls
===========
Called from: => _LNOTODAY( 0 )
Called from: test.prg => PRENOTAZIONE( 778 )

at line 778 there is

WITH OBJECT oPrenotazione:check_in
:lNoToday := .t.



obviously oPrenotazione is oPrenotazione: = oReservations: record (.t.) or record()


How I can resolve it ?
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: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: To Nages Problem with Tdatabase and new DAtepick

Postby James Bott » Wed May 05, 2021 6:01 pm

Silvio,

Code: Select all  Expand view
  WITH OBJECT oPrenotazione:check_in
      :lNoToday         := .t.
      :lNoTodayCircle   := .t.
      :SetRange( dStagioneMin,dStagioneMax )
   END


You are still using a variable here, not an object. Check_in is a variable of the object oPrenotazone. oPprenotazone is the object.

WITH OBJECT oPrenotazione:check_in

You have to use the object name only:

WITH OBJECT oPrentazione

The above line is just shorthand so you don't have to specify the object for each line. Otherwise it would have to be:

oPrentazione:lNoToday := .t.
oPrentazione:lNoTodayCircle := .t.
oPrentazione:setRange :=( dStagioneMin,dStagioneMax )
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: To Nages Problem with Tdatabase and new DAtepick

Postby Silvio.Falconi » Wed May 05, 2021 7:12 pm

james,

if you call datepick control you make

@x,y DATEPICK oPrenotazione:check_in .....

so the field is oPrenotazione:check_in on tdatabase because
oPrenotazione is the single record

oPrenotazione:= oReservations:record(.t.)

as (exlusive) RESERVA->CHECK_IN
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: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: To Nages Problem with Tdatabase and new DAtepick

Postby James Bott » Thu May 06, 2021 12:22 am

Silvio,

Code: Select all  Expand view
WITH OBJECT oPrenotazione:check_in
:lNoToday := .t.
 

Well, it still seems to me that this is incorrect syntax. The ":check_in" signifies a variable of the object oPrenotazione, When I try to run it, I get an error with a logical, so it seems to me the program thinks this is incorrect too.

It would make more sense if you named it oPrentazonieCheckIn instead. Try it.

obviously oPrenotazione is oPrenotazione: = oReservations: record (.t.) or record()

I can't test that because my older version of Fivewin doesn't support the TDatabase Record method.
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: To Nages Problem with Tdatabase and new DAtepick

Postby nageswaragunupudi » Thu May 06, 2021 4:34 am

Please revise this code
Code: Select all  Expand view

@  3, 140 DTPICKER oPrenotazione:check_in SIZE 80,12 PIXEL OF oFolder:aDialogs[1] ;
   PICTURE "ddd dd mmm yyyy"

WITH OBJECT oPrenotazione:check_in
   :lNoToday         := .t.
   :lNoTodayCircle   := .t.
   :SetRange( dStagioneMin,dStagioneMax )
END
 


as
Code: Select all  Expand view

@  3, 140 DTPICKER oDtpIn VAR oPrenotazione:check_in SIZE 80,12 PIXEL OF oFolder:aDialogs[1] ;
   PICTURE "ddd dd mmm yyyy"

WITH OBJECT oDtpIn
   :lNoToday         := .t.
   :lNoTodayCircle   := .t.
   :SetRange( dStagioneMin,dStagioneMax )
END
 
Regards

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

Re: To Nages Problem with Tdatabase and new DAtepick

Postby Silvio.Falconi » Thu May 06, 2021 7:03 am

nageswaragunupudi wrote:Please revise this code
Code: Select all  Expand view

@  3, 140 DTPICKER oPrenotazione:check_in SIZE 80,12 PIXEL OF oFolder:aDialogs[1] ;
   PICTURE "ddd dd mmm yyyy"

WITH OBJECT oPrenotazione:check_in
   :lNoToday         := .t.
   :lNoTodayCircle   := .t.
   :SetRange( dStagioneMin,dStagioneMax )
END
 


as
Code: Select all  Expand view

@  3, 140 DTPICKER oDtpIn VAR oPrenotazione:check_in SIZE 80,12 PIXEL OF oFolder:aDialogs[1] ;
   PICTURE "ddd dd mmm yyyy"

WITH OBJECT oDtpIn
   :lNoToday         := .t.
   :lNoTodayCircle   := .t.
   :SetRange( dStagioneMin,dStagioneMax )
END
 




Nages, the problem is this :
the oReservation object is actually the single record

With Tdatabase(tdatarow)


oReservation := Tdatabase():New(.....)
oPrenotazione:= oReservations:Record(.t.) /record()

With tdata

CLASS TReservatios from Tdata
METHOD New()
ENDCLASS
CLASS TReserva from Trecord
METHOD New()
ENDCLASS


oReservas := TReservations():New(.....)
oOne_Reserva:=TReserva():New(...)


and Mr James sad me allway to not to use type variables

@ 3, 140 DTPICKER oDtp var oPrenotazione:check_in SIZE ...

but directly

@ 3, 140 DTPICKER oPrenotazione:check_in SIZE ...

Nages,

I Know I must use

@ 3, 140 DTPICKER oDtpIn VAR oPrenotazione:check_in SIZE 80,12 PIXEL OF oFolder:aDialogs[1] ;
PICTURE "ddd dd mmm yyyy"

because then I have problems with :lNoToday

but James doesn't want to understand this passage

doing in this way I must first transfer the single record in variables:

cFirst: = oCust: first
cLast: = oCust: Last
cAddress: = oCust: address


as I did before when I used the exclusive way
and then when I have to save I can't just use oCust:Save ()

but I must save all fields with

oCust: first := cFirst
oCust: Last:= cLast

and then

oCust:save()


I hope to make James understand what my concern is
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: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: To Nages Problem with Tdatabase and new DAtepick

Postby James Bott » Thu May 06, 2021 4:36 pm

Silvio,

Code: Select all  Expand view
@  3, 140 DTPICKER oPrenotazione:check_in SIZE 80,12 PIXEL OF oFolder:aDialogs[1] ;
   PICTURE "ddd dd mmm yyyy"

WITH OBJECT oPrenotazione:check_in
   :lNoToday         := .t.
   :lNoTodayCircle   := .t.
   :SetRange( dStagioneMin,dStagioneMax )
END


In the above code you were trying to make the variable (oPrenoTazoine:check_in) into the dtPicker control object. Then you were trying to assign values to the data of the DTPicker object, which of course you can't do.

You need to do it as Nages showed. Make up an object name (oDtpin) for the TDpicker object and then assign the record data (oPrenotazione:check_in) to be the VAR of the DTPICKER object as Nages showed.

Code: Select all  Expand view
@  3, 140 DTPICKER oDtpIn VAR oPrenotazione:check_in SIZE 80,12 PIXEL OF oFolder:aDialogs[1] ;
   PICTURE "ddd dd mmm yyyy"

WITH OBJECT oDtpIn         // the datepicker control object name, NOT the variable name
   :lNoToday         := .t.      // The next three are data of the datepicker object oDtpin
   :lNoTodayCircle   := .t.
   :SetRange( dStagioneMin,dStagioneMax )
END
 


as I did before when I used the exclusive way
and then when I have to save I can't just use oCust:Save ()

but I must save all fields with

oCust: first := cFirst
oCust: Last:= cLast


I don't see why you would need to do that if you are using the code Nages showed. Just call oPrenotazione:Save().

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: To Nages Problem with Tdatabase and new DAtepick

Postby Silvio.Falconi » Fri May 07, 2021 9:21 am

>n the above code you were trying to make the variable (oPrenoTazoine:check_in) into the dtPicker control object. Then you were trying to assign values to the data of the DTPicker object, which of course you can't do.
>You need to do it as Nages showed. Make up an object name (oDtpin) for the TDpicker object and then assign the record data (oPrenotazione:check_in) to be the VAR of the DTPICKER object as Nages showed

Right I made as Nages sad


>I don't see why you would need to do that if you are using the code Nages showed. Just call oPrenotazione:Save().


Here I don't understand, that is, if I have to use a command like

@ 3, 140 DTPICKER oDtpIn VAR oPrenotazione:check_in

I have to use the same rule for the other fields that I need for editing or for a new record

Example

@ x, y GET aGet [1] VAR oPrenotazione:First

or should I just use the object only for the Datepick?

I ask you because you always told me not to put the objects ( Type ie. @x,y GET aGET[x] VAR field ....)
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: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: To Nages Problem with Tdatabase and new DAtepick

Postby James Bott » Fri May 07, 2021 3:56 pm

Silvio,

>or should I just use the object only for the Datepick? -No

>I ask you because you always told me not to put the objects ( Type ie. @x,y GET aGET[x] VAR field ....)

You should use it for everything. Because the record object has it's own set of field variables, you don't need to code scatter/gather routines. Just use the object syntax for any field you want to edit, then call the save method when you are done.

Here is an example using a record object (not a table object):

oReservation:StartDate:= date()
oReservation:EndDate:= date() + nDays
oReservation:save()

It doesn't get any easier than that.
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: To Nages Problem with Tdatabase and new DAtepick

Postby Silvio.Falconi » Mon May 10, 2021 9:37 am

James
Every day I found problem to found a solution with (tdata)base

for a sample today I cannot execute a bchange of a Get


@ 96, 145 Say "Sconto :" SIZE 90,10 PIXEL OF oDlgMod
@ 94, 175 GET aGet[8] VAR oTariffa:sconto OF oDlgMod SIZE 60, 12 ;
PIXEL PICTURE '@ €99,999.99' RIGHT FONT oFont UPDATE ;
ON CHANGE ((nTotale:= oTariffa:costo-oTariffa:sconto),oTariffa:totale:=ntotale ,aGet[9]:refresh())


@ 116, 10 Say "Totale :" SIZE 90,10 PIXEL OF oDlgMod
@ 114, 75 GET aGet[9] VAR oTariffa:totale OF oDlgMod SIZE 60, 12 ;
PIXEL PICTURE '@ €99,999.99' RIGHT FONT oFont UPDATE

how I must make it ?

If I made

nCosto:=otariffa:costo
nSconto:=otariffa:sconto
nTotale:=otariffa:totale

@ 96, 10 Say "Costo :" SIZE 90,10 PIXEL OF oDlgMod
@ 94, 75 GET aGet[7] VAR ncosto OF oDlgMod SIZE 60, 12 ;
PIXEL PICTURE '@ €99,999.99' RIGHT FONT oFont UPDATE


@ 96, 145 Say "Sconto :" SIZE 90,10 PIXEL OF oDlgMod
@ 94, 175 GET aGet[8] VAR nsconto OF oDlgMod SIZE 60, 12 ;
PIXEL PICTURE '@ €99,999.99' RIGHT FONT oFont UPDATE ;
ON CHANGE ((nTotale:= nCosto-nsconto) ,aGet[9]:refresh())


@ 116, 10 Say "Totale :" SIZE 90,10 PIXEL OF oDlgMod
@ 114, 75 GET aGet[9] VAR nTotale OF oDlgMod SIZE 60, 12 ;
PIXEL PICTURE '@ €99,999.99' RIGHT FONT oFont UPDATE

then I must make

otariffa:costo := ncosto
otariffa:sconto:=nSconto
otariffa:totale:=ntotale
otariffa:save()
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: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: To Nages Problem with Tdatabase and new DAtepick

Postby James Bott » Tue May 11, 2021 4:40 pm

Silvio,

@ 94, 175 GET aGet[8] VAR oTariffa:sconto OF oDlgMod SIZE 60, 12 ;
PIXEL PICTURE '@ €99,999.99' RIGHT FONT oFont UPDATE ;
ON CHANGE ((nTotale:= oTariffa:costo-oTariffa:sconto),oTariffa:totale:=ntotale ,aGet[9]:refresh())

The problem exists because the object, oTariffa, is not visible inside the get object. There are ways to solve this, but since your solution only requires 6 lines of code it is probably less work than figuring out the syntax that will work.

Otherwise you might try:

aGet[8]:bChange := {| oTariffa | (nTotale:= oTariffa:costo-oTariffa:sconto),oTariffa:totale:=ntotale ,aGet[9]:refresh() }

This passes the object (oTariffa) to the bChange codeblock so it is visible inside the codeblock.

To make it even shorter you could add a method Total to the TTeriffa class. Then bChange would look like this:

aGet[8]:bChange := {| oTariffa | oTariffa:totale:= oTariffa:Total(), aGet[9]:refresh() }

You might also have to pass aGet[9].

If you add the Method Total to the TTariffa class, then you should probably add these lines to the TTariffa class, then you should also create a new Save() method:

Method Save() Class TTariffa
::totale:= ::Total()
Return ::Save()

This insures that the totale field will always be correct.

Looking at the preprossor output will help understanding how to solve problems like this.

There are lots of things to try if you are so inclined. Otherwise just use what you already have.

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: To Nages Problem with Tdatabase and new DAtepick

Postby Silvio.Falconi » Tue May 11, 2021 10:04 pm

James Bott wrote:Silvio,

@ 94, 175 GET aGet[8] VAR oTariffa:sconto OF oDlgMod SIZE 60, 12 ;
PIXEL PICTURE '@ €99,999.99' RIGHT FONT oFont UPDATE ;
ON CHANGE ((nTotale:= oTariffa:costo-oTariffa:sconto),oTariffa:totale:=ntotale ,aGet[9]:refresh())

The problem exists because the object, oTariffa, is not visible inside the get object. There are ways to solve this, but since your solution only requires 6 lines of code it is probably less work than figuring out the syntax that will work.

Otherwise you might try:

aGet[8]:bChange := {| oTariffa | (nTotale:= oTariffa:costo-oTariffa:sconto),oTariffa:totale:=ntotale ,aGet[9]:refresh() }

This passes the object (oTariffa) to the bChange codeblock so it is visible inside the codeblock.

To make it even shorter you could add a method Total to the TTeriffa class. Then bChange would look like this:

aGet[8]:bChange := {| oTariffa | oTariffa:totale:= oTariffa:Total(), aGet[9]:refresh() }

You might also have to pass aGet[9].

If you add the Method Total to the TTariffa class, then you should probably add these lines to the TTariffa class, then you should also create a new Save() method:

Method Save() Class TTariffa
::totale:= ::Total()
Return ::Save()

This insures that the totale field will always be correct.

Looking at the preprossor output will help understanding how to solve problems like this.

There are lots of things to try if you are so inclined. Otherwise just use what you already have.

James






Sorry James but I make a test

nCosto := oTariffa:costo
nSconto := oTariffa:sconto
nTotale := oTariffa:totale




@ 96, 10 Say "Costo :" SIZE 90,10 PIXEL OF oDlgMod
@ 94, 75 GET aGet[7] VAR nCosto OF oDlgMod SIZE 60, 12 ;
PIXEL PICTURE '@ €99,999.99' RIGHT FONT oFont UPDATE

@ 96, 145 Say "Sconto :" SIZE 90,10 PIXEL OF oDlgMod
@ 94, 175 GET aGet[8] VAR nsconto OF oDlgMod SIZE 60, 12 ;
PIXEL PICTURE '@ €99,999.99' RIGHT FONT oFont UPDATE ;
ON CHANGE ((aGet[8]:assign(),ntotale:= ncosto-nsconto),aGet[9]:assign(),aGet[9]:refresh())

@ 116, 10 Say "Totale :" SIZE 90,10 PIXEL OF oDlgMod
@ 114, 75 GET aGet[9] VAR ntotale OF oDlgMod SIZE 60, 12 ;
PIXEL PICTURE '@ €99,999.99' RIGHT FONT oFont UPDATE

...

ACTIVATE DIALOG oDlgMod ;
ON INIT (DlgCenter( oDlgMod, oGrid ), aGet[5]:aItems[2]:disable())


If oDlgMod:nresult == IDOK
if msgYesNo( i18n("¿ save ?") )

oTariffa:costo := nCosto
oTariffa:sconto := nSconto
oTariffa:totale := nTotale
oTariffa:save()


endif
Endif

and it seems to run ok

even if you tell me it's wrong to do it this way
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: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: To Nages Problem with Tdatabase and new DAtepick

Postby James Bott » Wed May 12, 2021 12:35 am

Silvio,

even if you tell me it's wrong to do it this way


I did not tell you it was wrong. You asked me why it wasn't working for you initally, and I explained why.

The problem exists because the object, oTariffa, is not visible inside the get object. There are ways to solve this, but since your solution only requires 6 lines of code it is probably less work than figuring out the syntax that will work.

Then I gave some options you could try if you wanted to. Then I said:

There are lots of things to try if you are so inclined. Otherwise just use what you already have.
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: To Nages Problem with Tdatabase and new DAtepick

Postby Silvio.Falconi » Wed May 12, 2021 10:50 am

ok ok ok received the message
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: 7033
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 52 guests

cron