I'm not asking for the moon... Resolved!!

I'm not asking for the moon... Resolved!!

Postby Silvio.Falconi » Wed Jan 17, 2024 5:48 pm

I'm going crazy and no one is helping me... I have a series of numeric get controls for a little program, I would like only a zero to be displayed at the beginning but the user can type 12345 and the procedure must automatically convert to 123.45 and if the user presses another digit for example 7 this must change the last digit 123.47 and at the same time if the user presses 0.75 the procedure must leave 0.75 left.

I didn't understand which picture I should put in it, I tried with "@Z 999.99" but it doesn't work, that is, at the beginning I see 0.00 in the get instead of just a zero.


@ 60,20 GET aGet[2] VAR nVar SIZE 100,24 PIXEL PICTURE "@Z 999.99" OF oDlg RIGHT

it run ok but I see 0.00 on the get but I wish see only a zero at right
Last edited by Silvio.Falconi on Fri Jan 19, 2024 7:30 pm, 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: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: I'm not asking for the moon...

Postby Silvio.Falconi » Thu Jan 18, 2024 8:32 am

I need it to determine the Kg of materials and I need have 7 digit with a comma
sample 123,45
at init I need to have on Tget only a Zero at right and not 0.00 or 0,00



Code: Select all  Expand view
@ 60,20 GET aGet[2] VAR nVar   SIZE 100,24 PIXEL OF oDlg RIGHT;
         VALID   ChangePic( oDlg, aGet )

static function ChangePic( oDlg, aGet )
    WITH OBJECT aGet[ 2 ]
      if !( "@Z 999.99" $ :cPicture )
         :cPicture := ;
         :oGet:picture := "@Z 999.99"
         :Refresh()
      endif
   END
return .t.


why it make error ?
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: I'm not asking for the moon...

Postby Otto » Thu Jan 18, 2024 11:40 am

Do you mean something like this?

Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6312
Joined: Fri Oct 07, 2005 7:07 pm

Re: I'm not asking for the moon...

Postby Silvio.Falconi » Thu Jan 18, 2024 11:44 am

Otto wrote:Do you mean something like this?

Image


No, you not understood
the values are numeric ( 6 digit , 2 decimals)

1. at init see only a zero "0" at Right, so I not must see 0.00
2. when digit 12345 the get must transform to 123,45, not with dot "." but with "," comma
3. if the user digit another number sample 7 the get must write 123,47 and the cursor must stay on the last digit
4 the user can press tab to go to another get

If for sample there is allready a value sample 0,75
the get must not transform to 1
or if there is 3,60 the get must not transform to 4
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: I'm not asking for the moon...

Postby Silvio.Falconi » Thu Jan 18, 2024 12:09 pm

I tried to make a mini class but not run
just to make it clear what I wanted, I understood that tget doesn't work well and a subclass is needed

Code: Select all  Expand view
// TGetNumeric class
 #include "fivewin.ch"

function Main()

   local oDlg, oGet
   local nVar :=0
   local nVar1:=0.75
   local aGet:= array(2)
   local cGetNumeric

   SetGetColorFocus()

   DEFINE DIALOG oDlg SIZE 400,150 PIXEL TRUEPIXEL TITLE FWVERSION

    cGetNumeric := TGetNumeric ():New(20,20,, oDlg)

 ACTIVATE DIALOG oDlg CENTERED

   return nil




CLASS TGetNumeric FROM TGet
   data nDecimals,nValue

   METHOD Init
   METHOD keyPress( nKey )
   METHOD SetValue( nNewValue )
   METHOD GetNumericValue()
   METHOD SetNumericValue( nNewValue )
   METHOD SetDecimals( nDecimals )
END CLASS


   METHOD Init       CLASS TGetNumeric
      ::nDecimals := 2  // Set the number of decimal places
      ::SetValue(0)     // Initialize the value to 0
      return self

   METHOD keyPress( nKey ) CLASS TGetNumeric
      LOCAL nLen, cValue, nCursorPos

      ::keyPress( nKey )  // Call base class method

      IF nKey >= K_0 .AND. nKey <= K_9  // Check if the pressed key is a digit
         cValue := STR(::nValue, 7, ::nDecimals)  // Convert numeric value to string
         nCursorPos := MAX( 0, RAt( ".", cValue ) - 1 )  // Get cursor position
         ::SetText( cValue )  // Update control with formatted value
         ::setSel( nCursorPos + 1, nCursorPos + 1 )  // Set cursor position
      ENDIF
      return nil

   METHOD SetValue( nNewValue )  CLASS TGetNumeric
      LOCAL cFormattedValue

      cFormattedValue := STR(nNewValue, 7, ::nDecimals)  // Format the numeric value
      ::SetText( cFormattedValue )  // Update control with formatted value
      ::setSel( 7 - ::nDecimals, 7 - ::nDecimals )  // Set cursor position
      RETURN NIL

   METHOD GetNumericValue()    CLASS TGetNumeric
      RETURN VAL( ::GetText() )

   METHOD SetNumericValue( nNewValue ) CLASS TGetNumeric
      ::SetValue( nNewValue )
      RETURN NIL

   METHOD SetDecimals( nDecimals )    CLASS TGetNumeric
      ::nDecimals := nDecimals
     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: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: I'm not asking for the moon...

Postby Silvio.Falconi » Thu Jan 18, 2024 1:10 pm

Code: Select all  Expand view
#include "fivewin.ch"

FUNCTION Main()
   LOCAL oDlg, aGet := array(2)
   LOCAL nVar1 := 0.75
   LOCAL nVar := 0

    SetGetColorFocus()

   DEFINE DIALOG oDlg SIZE 400,150 PIXEL TRUEPIXEL TITLE FWVERSION

   @ 20,20 GET aGet[1] VAR nVar1 SIZE 100,24 PIXEL picture "@E999.99" OF oDlg RIGHT ;

   @ 60,20 GET aGet[2] VAR nVar SIZE 100,24 PIXEL picture "@E999.99"  OF oDlg RIGHT;

   ACTIVATE DIALOG oDlg CENTERED

   RETURN NIL



on second tget if I digit 12345 it must write 123,45 How I can make ?
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: I'm not asking for the moon...

Postby cmsoft » Thu Jan 18, 2024 3:51 pm

Silvio:
Algo asi te puede servir?
O al menos que te de un inicio
Tengo que
Code: Select all  Expand view

#include "Fivewin.ch"
#include "xbrowse.ch"
FUNCTION Main()
LOCAL oDlg1, oGet := array(4), nVar := {'     0','     0','     0','     0'}, oBot1
SET CONFIRM ON      
DEFINE DIALOG oDlg1 TITLE "Ingreso de datos" SIZE 300,100 PIXEL  RESIZABLE
@ 05,25 GET oGet[1] var nVar[1] PICTURE "@9" OF oDlg1 PIXEL right
@ 05,55 GET oGet[2] var nVar[2] PICTURE "@9" OF oDlg1 PIXEL right
@ 05,85 GET oGet[3] var nVar[3] PICTURE "@9" OF oDlg1 PIXEL right
@ 05,115 GET oGet[4] var nVar[4] PICTURE "@9" OF oDlg1 PIXEL right  
@ 25,20 BUTTON oBot1 PROMPT "&Ok" OF oDlg1 SIZE 30,10 ACTION oDlg1:End()  PIXEL  
oGet[1]:bLostFocus := {|| (oGet[1]:Assign(),oGet[1]:cText := STR(VAL(oGet[1]:cText) /100,6,2), oGet[1]:Refresh()) }
oGet[2]:bLostFocus := {|| (oGet[2]:Assign(),oGet[2]:cText := STR(VAL(oGet[2]:cText) /100,6,2), oGet[2]:Refresh()) }
oGet[3]:bLostFocus := {|| (oGet[3]:Assign(),oGet[3]:cText := STR(VAL(oGet[3]:cText) /100,6,2), oGet[3]:Refresh()) }
oGet[4]:bLostFocus := {|| (oGet[4]:Assign(),oGet[4]:cText := STR(VAL(oGet[4]:cText) /100,6,2), oGet[4]:Refresh()) }
oGet[1]:bGotFocus := {|| (oGet[1]:cText := STR(VAL(oGet[1]:cText) *100,6), oGet[1]:Refresh(),oGet[1]:SelectAll()) }
oGet[2]:bGotFocus := {|| (oGet[2]:cText := STR(VAL(oGet[2]:cText) *100,6), oGet[2]:Refresh(),oGet[2]:SelectAll()) }
oGet[3]:bGotFocus := {|| (oGet[3]:cText := STR(VAL(oGet[3]:cText) *100,6), oGet[3]:Refresh(),oGet[3]:SelectAll()) }
oGet[4]:bGotFocus := {|| (oGet[4]:cText := STR(VAL(oGet[4]:cText) *100,6), oGet[4]:Refresh(),oGet[4]:SelectAll()) }

ACTIVATE DIALOG oDlg1 CENTERED
xbrowse(nVar)
RETURN nil
 

Claro que es muy mejorable, pero al menos para comenzar
User avatar
cmsoft
 
Posts: 1285
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: I'm not asking for the moon...

Postby Silvio.Falconi » Thu Jan 18, 2024 7:23 pm

cmsoft wrote:Silvio:
Algo asi te puede servir?
O al menos que te de un inicio
Tengo que
Code: Select all  Expand view

#include "Fivewin.ch"
#include "xbrowse.ch"
FUNCTION Main()
LOCAL oDlg1, oGet := array(4), nVar := {'     0','     0','     0','     0'}, oBot1
SET CONFIRM ON      
DEFINE DIALOG oDlg1 TITLE "Ingreso de datos" SIZE 300,100 PIXEL  RESIZABLE
@ 05,25 GET oGet[1] var nVar[1] PICTURE "@9" OF oDlg1 PIXEL right
@ 05,55 GET oGet[2] var nVar[2] PICTURE "@9" OF oDlg1 PIXEL right
@ 05,85 GET oGet[3] var nVar[3] PICTURE "@9" OF oDlg1 PIXEL right
@ 05,115 GET oGet[4] var nVar[4] PICTURE "@9" OF oDlg1 PIXEL right  
@ 25,20 BUTTON oBot1 PROMPT "&Ok" OF oDlg1 SIZE 30,10 ACTION oDlg1:End()  PIXEL  
oGet[1]:bLostFocus := {|| (oGet[1]:Assign(),oGet[1]:cText := STR(VAL(oGet[1]:cText) /100,6,2), oGet[1]:Refresh()) }
oGet[2]:bLostFocus := {|| (oGet[2]:Assign(),oGet[2]:cText := STR(VAL(oGet[2]:cText) /100,6,2), oGet[2]:Refresh()) }
oGet[3]:bLostFocus := {|| (oGet[3]:Assign(),oGet[3]:cText := STR(VAL(oGet[3]:cText) /100,6,2), oGet[3]:Refresh()) }
oGet[4]:bLostFocus := {|| (oGet[4]:Assign(),oGet[4]:cText := STR(VAL(oGet[4]:cText) /100,6,2), oGet[4]:Refresh()) }
oGet[1]:bGotFocus := {|| (oGet[1]:cText := STR(VAL(oGet[1]:cText) *100,6), oGet[1]:Refresh(),oGet[1]:SelectAll()) }
oGet[2]:bGotFocus := {|| (oGet[2]:cText := STR(VAL(oGet[2]:cText) *100,6), oGet[2]:Refresh(),oGet[2]:SelectAll()) }
oGet[3]:bGotFocus := {|| (oGet[3]:cText := STR(VAL(oGet[3]:cText) *100,6), oGet[3]:Refresh(),oGet[3]:SelectAll()) }
oGet[4]:bGotFocus := {|| (oGet[4]:cText := STR(VAL(oGet[4]:cText) *100,6), oGet[4]:Refresh(),oGet[4]:SelectAll()) }

ACTIVATE DIALOG oDlg1 CENTERED
xbrowse(nVar)
RETURN nil
 

Claro que es muy mejorable, pero al menos para comenzar


Cesar,
the values ( nVar1,2,3,4) must be numeric and then not wish "." ( dot separation) but "," (comma separation)
then it run if the nvar are all zero if we have the values allready on dbf ? not run
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: I'm not asking for the moon...

Postby Otto » Thu Jan 18, 2024 8:45 pm

Use STRTRAN()
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6312
Joined: Fri Oct 07, 2005 7:07 pm

Re: I'm not asking for the moon...

Postby Silvio.Falconi » Thu Jan 18, 2024 9:08 pm

Otto wrote:Use STRTRAN()

Perhaps we not understading the problem...
in the xbrowse table I have the numerical digits with the comma separator, then when I go to make the change I find the digits with the dot separator, do you think this is normal?
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: I'm not asking for the moon...

Postby Otto » Thu Jan 18, 2024 9:30 pm

Yes, see this line.

oGet[1]:bGotFocus := {|| (oGet[1]:cText := STR(VAL(oGet[1]:cText) *100,6), oGet[1]:Refresh(),oGet[1]:SelectAll()) }
Cesar, changed the GETs to character that you get the inputstyle you wanted.
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6312
Joined: Fri Oct 07, 2005 7:07 pm

Re: I'm not asking for the moon...

Postby Silvio.Falconi » Thu Jan 18, 2024 9:40 pm

Otto wrote:Yes, see this line.

oGet[1]:bGotFocus := {|| (oGet[1]:cText := STR(VAL(oGet[1]:cText) *100,6), oGet[1]:Refresh(),oGet[1]:SelectAll()) }
Cesar, changed the GETs to character that you get the inputstyle you wanted.

Yes but nvar Is text array but i have numbers no texts
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: I'm not asking for the moon...

Postby Otto » Thu Jan 18, 2024 10:00 pm

Before saving, use VAL()
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6312
Joined: Fri Oct 07, 2005 7:07 pm

Re: I'm not asking for the moon...

Postby Silvio.Falconi » Fri Jan 19, 2024 7:36 am

Otto wrote:Before saving, use VAL()


unlike you I try my programs over and over again and don't hand the client something that doesn't work well.
It's not easy at all, as I told you in the Xbrowse table I have the numeric figures with commas, then when I go to make the change I find them with the separation point also because I used the picture "@Z999.99"
Cesar's test could work but I tried and tried several times and often the asterisks "***.**" were formed instead of numbers and this is a waste of time if we imagine that if the operator enters in a fast way where you always have to go back with the mouse.

Please test this small test
Image

On Modify I not understood how convert the fields numeric to use cesar test
this test create a demo dbf to try ( please not change the structure of dbf I must use it)
there is only modify procedure
Code: Select all  Expand view

#include "Fivewin.ch"
#include "xbrowse.ch"

  REQUEST DBFCDX


Function main()
local     nWd  := GetSysMetrics(0) * .58
local     nHt  := GetSysMetrics(1) / 2.5
local oDlg,oFont,oBold
local oBrw,oBar
local oBtn:=array(3)
local aData:= {}
local cCod_temp:= "00001" // to demo
local oDbf
local cDir:= cFilePath(GetModuleFileName( GetInstance() ))  + "Data\"



 RddSetDefault( "
DBFCDX" )

       SetHandleCount( 100 )
       FWNumFormat( "
E", .t. )

       SET DATE FORMAT "
dd-mm-yyyy"
       SET DELETED     ON
       SET CENTURY     ON
       SET EPOCH TO    year( date() ) - 20
       SET MULTIPLE    OFF



 oFont := TFont():New( "
Tahoma", 0, 18,, )
 oBold  := TFont():New( "
Tahoma", 0, 16,,.t. )


        // Creation Dbf for Demo test
           Build_Dbf(cDir) // create dbf

        // Open dDbf
      oDbf:=TSample():New()
       oDbf:setorder(1)
       oDbf:Gotop()

  // take the records for cCod_temp
  aData := oDbf:DbfToArray( , { ||FIELD->cod == cCod_temp  } )





DEFINE DIALOG oDlg SIZE nWd, nHt PIXEL ;   //TRUEPIXEL
       TITLE "
test numeric" ;
       FONT oFont   COLOR CLR_BLACK, CLR_WHITE ;
       STYLE nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU, ;
                  WS_MINIMIZEBOX)
//---------------------------------------------------------------------//
DEFINE BUTTONBAR oBar OF oDlg  SIZE 80,70  BOTTOM NOBORDER  2015
DEFINE BUTTON oBtn[1] OF oBar  ;
      FILENAME "
DLG_NO";
      PROMPT "
Add" TOOLTIP "Esci" ;
      ACTION   Modify(oBrw,1,oFont)

      DEFINE BUTTON oBtn[2] OF oBar  ;
      FILENAME "
HLP_DLG";
      PROMPT "
Modify" TOOLTIP "Aiuto" ;
      ACTION Modify(oBrw,2,oFont)   GROUP

      DEFINE BUTTON oBtn[3] OF oBar  BTNRIGHT  ;
      FILENAME "
DLG_OK";
      PROMPT "
Exit" ;
      TOOLTIP "
Conferma i dati" ;
      ACTION   ( oDlg:end( IDOK ) )
//--------------------------------------------------------------------------//

   @  2, 5 XBROWSE  oBrw OF oDlg ;
              COLUMNS  2,3,4,5;
              HEADERS "
Peso1","Peso2","Peso3","Peso4" ;
              COLSIZES 90,90,90,90 ;
              ARRAY aData      ;
              SIZE -5,-60 PIXEL   STYLE FLAT NOBORDER

        WITH OBJECT oBrw
            :lHScroll  := .f.
            :CreateFromCode()
         END

 ACTIVATE DIALOG oDlg CENTERED ;
       ON INIT (  oDlg:resize(),   ChangeButtons( oBar ) )


 return nil
//------------------------------------------------------------------//

 function ChangeButtons( oBar )
   AEval( oBar:aControls, { | oCtrl | oCtrl:nTop += 4, oCtrl:nHeight -= 4 } )
return .T.







FUNCTION Modify(oBrowse,nMode,oFont)  // cesar test
   LOCAL oDlg1, oGet := array(4)
   local nVar := {'     0','     0','     0','     0'}, oBot1

   local nRecord:= oBrowse:nArrayAt
   local ntest1,ntest2,ntest3,ntest4
   local cPicture:="
@Z 999.99"
   local aGet:= array(4)
   local     nWd  := GetSysMetrics(0) * .58
   local     nHt  := GetSysMetrics(1) / 4
   local oBtn1,oBtn2,oBar


IF nMode==2 //modify
     ntest1    := Str(oBrowse:aArraydata[nRecord][2])
     ntest2    := Str(oBrowse:aArraydata[nRecord][3])
     ntest3    := Str(oBrowse:aArraydata[nRecord][4])
     ntest4    := Str(oBrowse:aArraydata[nRecord][5])
  Endif




SET CONFIRM ON
DEFINE DIALOG oDlg1 SIZE nWd, nHt PIXEL ;
       TITLE "
test numeric" ;
       FONT oFont   COLOR CLR_BLACK, CLR_WHITE ;
       STYLE nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU, ;
                  WS_MINIMIZEBOX)


    //-------------------------------------------------------------------//
      DEFINE BUTTONBAR oBar OF oDlg1 SIZE 70,70  2015   BOTTOM NOBORDER
      DEFINE BUTTON oBtn1 OF oBar  ;
      FILENAME "
DLG_NO";
      PROMPT "
Annulla" TOOLTIP "Esci" ;
      ACTION   ( oDlg1:end( IDCANCEL ) )

      DEFINE BUTTON oBtn2 OF oBar BTNRIGHT  ;
      FILENAME "
DLG_OK";
      PROMPT "
Conferma" ;
      TOOLTIP "
Conferma i dati" ;
      ACTION   ( oDlg1:end( IDOK ) )
      //-------------------------------------------------------------------//




      @ 70, 20  GET aGet[1] VAR ntest1   OF oDlg1 SIZE 32, 12 PIXEL  FONT oFont    PICTURE cPicture  UPDATE RIGHT
      @ 70, 82  GET aGet[2] VAR ntest2   OF oDlg1 SIZE 32, 12 PIXEL  FONT oFont    PICTURE cPicture  UPDATE RIGHT
      @ 70, 245 GET aGet[3] VAR ntest3   OF oDlg1 SIZE 32, 12 PIXEL  FONT oFont    PICTURE cPicture  UPDATE RIGHT
      @ 70, 295 GET aGet[4] VAR ntest4   OF oDlg1 SIZE 32, 12 PIXEL  FONT oFont    PICTURE cPicture  UPDATE RIGHT

aGet[1]:bLostFocus := {|| (aGet[1]:Assign(),aGet[1]:cText := STR(VAL(aGet[1]:cText) /100,6,2), aGet[1]:Refresh()) }
aGet[2]:bLostFocus := {|| (aGet[2]:Assign(),aGet[2]:cText := STR(VAL(aGet[2]:cText) /100,6,2), aGet[2]:Refresh()) }
aGet[3]:bLostFocus := {|| (aGet[3]:Assign(),aGet[3]:cText := STR(VAL(aGet[3]:cText) /100,6,2), aGet[3]:Refresh()) }
aGet[4]:bLostFocus := {|| (aGet[4]:Assign(),aGet[4]:cText := STR(VAL(aGet[4]:cText) /100,6,2), aGet[4]:Refresh()) }

aGet[1]:bGotFocus := {|| (aGet[1]:cText := STR(VAL(aGet[1]:cText) *100,6), aGet[1]:Refresh(),aGet[1]:SelectAll()) }
aGet[2]:bGotFocus := {|| (aGet[2]:cText := STR(VAL(aGet[2]:cText) *100,6), aGet[2]:Refresh(),aGet[2]:SelectAll()) }
aGet[3]:bGotFocus := {|| (aGet[3]:cText := STR(VAL(aGet[3]:cText) *100,6), aGet[3]:Refresh(),aGet[3]:SelectAll()) }
aGet[4]:bGotFocus := {|| (aGet[4]:cText := STR(VAL(aGet[4]:cText) *100,6), aGet[4]:Refresh(),aGet[4]:SelectAll()) }




   ACTIVATE DIALOG oDlg1 CENTERED ;
       ON INIT (  oDlg1:resize(),   ChangeButtons( oBar ) )
       IF oDlg1:nresult == IDOK
              oBrowse:aArraydata[nRecord][2]:= ntest1
              oBrowse:aArraydata[nRecord][3]:= ntest2
              oBrowse:aArraydata[nRecord][4]:= ntest3
              oBrowse:aArraydata[nRecord][5]:= ntest4
      endif
RETURN nil

//------------------------------------------------------------------------------------//
Function Build_Dbf(cDir)
    local lAppend     := .F.
   FIELD cod

            local aFields := { {  "
Cod",       "C",   5, 0 },;
                               {  "
test1",     "N",   6, 2 },;
                               {  "
test2",     "N",   6, 2 },;
                               {  "
test3",     "N",   6, 2 },;
                               {  "
test4",     "N",   6, 2 }}

   IF !lIsDir(alltrim(cDir))
       IF !lMkDir(cDir)
          MsgAlert("
Attention")
       ENDIf
    ENDIf



 if File( cdir+"
sample.dbf" )
      if !File( cdir+"
sample.cdx" )
         USE  &(cdir+"
sample") NEW EXCLUSIVE ALIAS DB
           INDEX ON Cod          TAG COD  FOR !Deleted()
         CLOSE DB
      endif
   else
      DbCreate( cdir+"
sample.dbf", aFields, "DBFCDX", .T., "DB" )
      lAppend  := .T.
         INDEX ON Cod         TAG COD  FOR !Deleted()
         CLOSE DB
      endif

/// add test


   if lAppend
      USE  &(cdir+"
sample") NEW EXCLUSIVE ALIAS DB
      INDEX ON Cod         TAG COD  FOR !Deleted()

   APPEND BLANK
      REPLACE COD WITH "
00001"
      REPLACE TEST1 WITH  0.10
      REPLACE TEST2 WITH  0.20
      REPLACE TEST3 WITH  3.60
      REPLACE TEST4 WITH  0.70
  APPEND BLANK
      REPLACE COD WITH "
00001"
      REPLACE TEST1 WITH  0.75
      REPLACE TEST2 WITH  0.20
      REPLACE TEST3 WITH  3.60
      REPLACE TEST4 WITH  0.50
   APPEND BLANK
      REPLACE COD WITH "
00001"
      REPLACE TEST1 WITH 1.2
      REPLACE TEST2 WITH 0.20
      REPLACE TEST3 WITH 3.60
      REPLACE TEST4 WITH 0.4

         CLOSE DB
   Endif
RETURN NIL


//-----------------------------------------------------------------------------------//
//-----------------------------------------------------------------------------------//
//-----------------------------------------------------------------------------------//

 CLASS TXData from TDatabase
    DATA cDbfPath init cFilePath(GetModuleFileName( GetInstance() ))  + "
Data\"
  ENDCLASS

CLASS TSample from TXData
METHOD New()
ENDCLASS

METHOD New( lShared ) CLASS TSample
   Default lShared := .t.
   ::super:New(,::cDbfPath + "
Sample" ,"DBFCDX", lShared)
   if ::use()
      ::setOrder(1)
      ::gotop()
   endif
   RETURN Self
//-----------------------------------------------------------------------------------//
//-----------------------------------------------------------------------------------//
//-----------------------------------------------------------------------------------//
Last edited by Silvio.Falconi on Fri Jan 19, 2024 8:44 am, edited 2 times 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: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 42 guests