Page 1 of 1

SET RANGE ERROR - RESOLVED!!!

Posted: Thu May 13, 2021 7:15 am
by Silvio.Falconi
I had made a small text in a dialog taking the example of Nages dtprang1.prg
as you can see on this topic viewtopic.php?f=3&t=40344&sid=096b78133ff43210636e86df0f01f042#p240896

I inserted the piece of the two controls above a ribbonbar as created by Nages (changing only the position coordinates of the controls)

always makes me the same ERROR SETRANGE()

AT THIS LINE

@ 20,100 DTPICKER oDtpFirst VAR dFirst SIZE 200,28 PIXEL OF oGrS1 ;
PICTURE "ddd dd mmm yyyy" ;
ON CHANGE ( oDtpLast:SetRange( dFirst ), oGrS1:Update() ) UPDATE

oGrS1 ia group tab of the ribbonbar

Code: Select all | Expand


 ::oRebar := TRibbonBar():New(::oWndMain, aRbPrompts,,,,nAltezzaRibbon,30,,,,,,,,,,.T.,)
...

ADD GROUP oGrS1 RIBBON ::oRebar TO OPTION 1  WIDTH 625 PROMPT "Periodo da visualizzare"


 @  20,69 SAY "Dal:"  SIZE 30,28 PIXEL OF oGrS1 FONT oFont TRANSPARENT
  @  20,310 SAY "al :"  SIZE 30,28 PIXEL OF oGrS1 FONT oFont TRANSPARENT


   @  20,100 DTPICKER oDtpFirst VAR dFirst SIZE 200,28 PIXEL OF oGrS1 ;
      PICTURE "ddd dd mmm yyyy" ;
       ON CHANGE ( oDtpLast:SetRange( dFirst ), oGrS1:Update() )  UPDATE  //

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


    @  55, 100 ADD BUTTON oBtnDdate[1]  ;
                  BITMAP aBtnfw[2] ;
                  GROUP oGrS1  SIZE 28,25;
                  ACTION ( dFirst--,oDtpFirst:refresh(), oDtpFirst:SetFocus() )

    @  55,275 ADD BUTTON oBtnDdate[2]  ;
                  BITMAP aBtnfw[1] ;
                  GROUP oGrS1  SIZE 28,25;
                  ACTION ( dFirst++,oDtpFirst:refresh(), oDtpFirst:SetFocus() )

        oBtnDdate[1]:ocursor :=oHand
        oBtnDdate[2]:ocursor :=oHand



    @  20,340 DTPICKER oDtpLast VAR dLast SIZE 200,28 PIXEL OF oDlg ;
      PICTURE "ddd dd mmm yyyy"  UPDATE //ON CHANGE ( oDlg:Update(),oBrowse:refresh())

   WITH OBJECT oDtpLast
      :lNoToday         := .t.
      :lNoTodayCircle   := .t.
      :SetRange( dFirst,dStagioneMax )
   END

   
      @  55,340 ADD BUTTON oBtnDdate[3]  ;
                  BITMAP aBtnfw[2] ;
                  GROUP oGrS1  SIZE 28,25;
                  ACTION ( dLast--,oDtpLast:refresh(), oDtpLast:SetFocus() )
   @  55,515 ADD BUTTON oBtnDdate[4]  ;
                  BITMAP aBtnfw[1] ;
                  GROUP oGrS1  SIZE 28,25;
                  ACTION ( dLast++,oDtpLast:refresh(), oDtpLast:SetFocus() )

       oDtpLast:bchange := { || SetDates(  dFirst,  dLast, lShowNumeri, lshowPagamenti )}


      oBtnDdate[3]:ocursor :=oHand
      oBtnDdate[4]:ocursor :=oHand

 




I also check if there is an error on dates and I insert on source

dFirst := {^ 2021/04/08 }
dLast := {^ 2021/04/08 }

now I don't understand why in the dialog function and in the ribbonbar it doesn't work as is possible ??????

it is as if first it cannot bchange oDtpFirst exiting with an error to SetRange ()

the error.log

Code: Select all | Expand

Application
===========
   Path and name: C:\Work\Prg\Prenotazioni\WinBeach.Exe (32 bits)
   Size: 7,182,848 bytes
   Compiler version: Harbour 3.2.0dev (r1904111533)
   FiveWin  version: FWH 21.02
   C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
   Windows version: 6.1, Build 7601 Service Pack 1

   Time from start: 0 hours 0 mins 5 secs
   Error occurred at: 13-05-2021, 09:03:18
   Error description: Error BASE/1004  Metodo non disponibile: SETRANGE
   Args:
     [   1] = U  
     [   2] = D   08-04-2021

Stack Calls
===========
   Called from:  => SETRANGE( 0 )
   Called from: source\sistema\main.prg => (b)TAPPLICATION_BUILDRIBBONBAR( 868 )
   Called from: .\source\classes\TDTPICKE.PRG => TDATEPICK:CHANGE( 454 )
   Called from: .\source\classes\TDTPICKE.PRG => TDATEPICK:_CTEXT( 396 )
   Called from: .\source\classes\TDTPICKE.PRG => TDATEPICK:NEW( 180 )
   Called from: source\sistema\main.prg => TAPPLICATION:BUILDRIBBONBAR( 868 )
   Called from: source\sistema\main.prg => TAPPLICATION:NEW( 413 )
   Called from: source\sistema\main.prg => MAIN( 64 )


If I rem that line I wrote above and insert this line

oDtpFirst:bchange := { ||( oDtpLast:SetRange( dFirst ), oGrS1:Update() ) }

at the end before of oDtpLast:bchange := { || SetDates( dFirst, dLast, lShowNumeri, lshowPagamenti )}



not make error , I's very very strange


a solution please

Re: SET RANGE ERROR

Posted: Thu May 13, 2021 11:36 pm
by James Bott
Silvio,

This is exactly the same problem we discussed a few days ago. The objects are invisible inside the codeblock.

Code: Select all | Expand

oDtpFirst:bchange := { ||( oDtpLast:SetRange( dFirst ), oGrS1:Update() ) }


You have to pass the objects, so rewrite the above line like this.

oDtpFirst:bchange := { | oDtplast, oGrs1 |( oDtpLast:SetRange( dFirst ), oGrS1:Update() ) }

Re: SET RANGE ERROR

Posted: Fri May 14, 2021 7:09 am
by Silvio.Falconi
James Bott wrote:Silvio,

This is exactly the same problem we discussed a few days ago. The objects are invisible inside the codeblock.

Code: Select all | Expand

oDtpFirst:bchange := { ||( oDtpLast:SetRange( dFirst ), oGrS1:Update() ) }


You have to pass the objects, so rewrite the above line like this.

oDtpFirst:bchange := { | oDtplast, oGrs1 |( oDtpLast:SetRange( dFirst ), oGrS1:Update() ) }



James,
NO, this is not the piece that didn't work

but the piece that didn't work is this:

Code: Select all | Expand


@  20,100 DTPICKER oDtpFirst VAR dFirst SIZE 200,28 PIXEL OF oGrS1 ;
      PICTURE "ddd dd mmm yyyy" ;
       ON CHANGE ( oDtpLast:SetRange( dFirst ), oGrS1:Update() )  UPDATE  
 


then now I converte this line (ON CHANGE) in
oDtpFirst:bchange := { ||( oDtpLast:SetRange( dFirst ), oGrS1:Update() ) } or oDtpFirst:bchange := { | oDtplast, oGrs1 |( oDtpLast:SetRange( dFirst ), oGrS1:Update() ) }

But if you insert this line before of the odtplast control not run

Re: SET RANGE ERROR

Posted: Fri May 14, 2021 9:07 am
by Enrico Maria Giordano
James Bott wrote:Silvio,

This is exactly the same problem we discussed a few days ago. The objects are invisible inside the codeblock.

Code: Select all | Expand

oDtpFirst:bchange := { ||( oDtpLast:SetRange( dFirst ), oGrS1:Update() ) }


You have to pass the objects, so rewrite the above line like this.

oDtpFirst:bchange := { | oDtplast, oGrs1 |( oDtpLast:SetRange( dFirst ), oGrS1:Update() ) }


No, you can't, as at the time of the evaluation of bChange only the object itself is passed to the codeblock:

Code: Select all | Expand

Eval( ::bChange, Self )


EMG

Re: SET RANGE ERROR

Posted: Fri May 14, 2021 9:21 am
by Silvio.Falconi
Enrico Maria Giordano wrote:
No, you can't, as at the time of the evaluation of bChange only the object itself is passed to the codeblock:

Code: Select all | Expand

Eval( ::bChange, Self )


EMG


I can't do what? Enrico did not understand
I have the example of nages look at the file dtprang1.prg you can found on samples folder
and I inserted the same code on a ribbonbar

because on the dialog it runs well and on the ribbonbar it makes an error setrange()?

this is the subject of the discussion
forget it as I tried to fix the code to load the bchange that's another thing

I find that this piece does not work on the ribbonbar

Code: Select all | Expand

@  20,100 DTPICKER oDtpFirst VAR dFirst SIZE 200,28 PIXEL OF oGrS1 ;
      PICTURE "ddd dd mmm yyyy" ;
       ON CHANGE ( oDtpLast:SetRange( dFirst ), oGrS1:Update() )  UPDATE


because odtplast is probably not created yet and make error on setrange()

Re: SET RANGE ERROR

Posted: Fri May 14, 2021 3:31 pm
by nageswaragunupudi
Please try:

Code: Select all | Expand

ON CHANGE If( oDtpLast == nil, nil, ( oDtpLast:SetRange( dFirst ), oGrS1:Update() ) )

Re: SET RANGE ERROR

Posted: Sat May 15, 2021 6:39 am
by Silvio.Falconi
nageswaragunupudi wrote:Please try:

Code: Select all | Expand

ON CHANGE If( oDtpLast == nil, nil, ( oDtpLast:SetRange( dFirst ), oGrS1:Update() ) )

Thanks Rao , you are a genius