conversione dal clipper 87

Moderator: Enrico Maria Giordano

conversione dal clipper 87

Postby Silvio.Falconi » Tue Apr 05, 2022 11:36 am

Come potrei tradurre questo codice in fwh, usando tdatabase ?
probabilmente in clipper 87 non si usavano ancora i cdx e quindi facevamo tutto in sequelziale
e quindi con il comando locate for, vi ricordate qualcosa ?

Code: Select all  Expand view

     anno1:= "1939"
      anno2:= "1999"
      set color to GR+/N
      @ 22, 15 say "ANNO INIZIALE:" get ANNO1 picture "9999"
      @ 22, 48 say "ANNO FINALE:" get ANNO2 picture "9999"
      read
      if (Val(anno1) > Val(anno2))
         break
      endif

 locate for SubStr(settimana, 10, 2) = SubStr(anno2, 3, 2)
      if (Found())
         locate for SubStr(settimana, 10, 2) != SubStr(anno2, 3, 2) ;
            next 60
      endif
      if (Found())
         ultimo:= RecNo() - 1
      else
         ultimo:= LastRec()
      endif
      locate for SubStr(settimana, 10, 2) = SubStr(anno1, 3, 2)
      if (!Found())
         __dbgotop()
      endif
      primo:= RecNo()



Adesso ho provato a non usare locate e fare un filtro
Code: Select all  Expand view

#include "FiveWin.ch"

REQUEST DBFCDX

Function test()
Local oDlg,oFont
local nYear1:= 1939,nYear2:= 2022
local aRecords:= {}

   DEFINE FONT oFont NAME "MS Sans Serif" SIZE 0, 8
   DEFINE DIALOG oDlg FROM 100, 100 TO 230,376;
                 TITLE "Selection year" PIXEL FONT oFont

   @ 12, 10 SAY "From year:" OF oDlg SIZE 17, 8 PIXEL FONT oFont
   @ 10, 47 GET nYear1     OF oDlg SIZE 44, 12 PIXEL FONT oFont picture "9999"
   @ 26, 10 SAY "to year" OF oDlg SIZE 32, 8 PIXEL FONT oFont
   @ 24, 47 GET nYear2   OF oDlg SIZE 44, 12 PIXEL FONT oFont picture "9999"


   @ 46, 48  BUTTON oBtn PROMPT "Conferma" OF oDlg SIZE 42, 12 PIXEL FONT oFont DEFAULT  ACTION ( oDlg:end( IDOK ) )
   @ 46, 92  BUTTON oBtn PROMPT "Annulla" OF oDlg SIZE 42, 12 PIXEL FONT oFont CANCEL   ACTION ( oDlg:end( IDCANCEL ) )


ACTIVATE DIALOG oDlg CENTERED

   IF oDlg:nresult == IDOK
      if ((nYear1) > (nYear2))
         return nil
      endif
          arecords:= Locate_Records(nYear1,nYear2)
          xbrowser aRecords
   Endif
return nil

//----------------------------------------------------//
Function Locate_Records(nYear1,nYear2)
   local oDbf,nFirst,nLast
   local aLocate:= {}
   local cFilter1,cFilter2
//---------------------------------------------------------//
   oDbf:= TDatabase():Open( ,"Lotto", "DBFCDX", .T. )
   oDbf:setorder(1)
   oDbf:gotop()
//---------------------------------------------------------//
   cFilter1    := "ltrim(str(year(data))) == '" + ltrim(str(nYear1)) +"'"
   cFilter2    := "ltrim(str(year(data))) == '" + ltrim(str(nYear2)) +"'"

            oDbf:setFilter(cFilter2)
            oDbf:gotop()
                 If year(odbf:data) = nYear2
                    nLast:= oDbf:recno() - 1
                 else
                   nLast:= LastRec()
                 endif
            oDbf:clearFilter()


            oDbf:setFilter(cFilter1)
            oDbf:gotop()
             If year(odbf:data) = nYear1
                    nFirst:= oDbf:recno() - 1
                 else
                   nFirst:= 1
                 endif

                 oDbf:close()

           AaDd( aLocate,{nFirst,nLast})
   return aLocate


 


secondo voi potrebbe girare bene ?
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: 7061
Joined: Thu Oct 18, 2012 7:17 pm

Return to All products support

Who is online

Users browsing this forum: No registered users and 16 guests