Calculator revisited

Re: Calculator revisited

Postby TimStone » Wed May 28, 2014 6:48 pm

Receiving syntax errors for oBtnDel and oBtn0.

When commenting those out, it will build.

I suspect the problems are in the IIF( ) syntax, but I'm not sure yet what goes where.

Thanks.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2904
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Calculator revisited

Postby karinha » Wed May 28, 2014 7:26 pm

Very Good!!

Code: Select all  Expand view

/*
  TCALC.PRG  
  CLASE QUE PERMITE PONER UNA CALCULADORA CON ROLLO DE PAPEL VIRTUAL.
  Necesita el fichero de recursos: TCALC.RC

  Primera Versión: Junio del 2007 DC
  Ultima Revisión: 23/09/2007
  Autor: Verhoven.  ¡ Seguro les resultará de utilidad !
         1.- Queda autorizado su libre distribucion y uso, incluso con fines comerciales .
         2.- El autor declina cualquier responsabilidad en caso de funcionamiento anómalo.

  Ejemplo: Hacemos una calculadora que se active pulsando F12:
           Para incluirla en un programa basta con poner después de la función main() del mismo.
           #include 'TCALC.PRG'
           public oCalc:=tCalc():new()
           setkey(VK_F12, {|| oCalc:calculadora(oWnd,'@E 9,999,999.9999 ')})
 
  Vea el significado de las variables de instancia y de las que se les pasan a los métodos para
   aprovechar algunas posibilidades de configuración.
*/


#include "fivewin.ch"

STATIC oWnd

FUNCTION Main()

   PUBLIC oFont
   PUBLIC oCalc:=tCalc():new()

   DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 00, -14 BOLD

   setkey( VK_F12, { || oCalc:calculadora( oWnd, '@E 9,999,999.9999 ' ) } )

   DEFINE WINDOW oWnd TITLE "Press <F12> to Calculator"

   DEFINE BUTTONBAR oBar _3D OF oWnd

   DEFINE BUTTON OF oBar ACTION( oWnd:End() ) CANCEL

   SET MESSAGE OF oWnd TO "Press <F12> to Calculator" NOINSET CLOCK DATE KEYBOARD

   ACTIVATE WINDOW oWnd MAXIMIZED

RETURN NIL

CLASS TCalc
 DATA nResult             //Resultado de las operaciones en curso.    
 DATA aRolloCalc          //Operaciones realizadas desde la última vez que se borró todo.
 
 DATA cUltima, cUltimaop      
 DATA cPatronSalida       // cPatronSalida  -> Formato en que se pinta el resultado.    
   
 METHOD New() CONSTRUCTOR
 
 METHOD End()
     
 METHOD nCalculadigual(nGet)
     
 METHOD calculadora(oPadre,cPatronSalida,lBorraAlInicio)
                    // lBorraAlInicio -> Al llamar al método si está en .t. borra lo que hubiera.
                    //                    Si está en .f. ó NIL conserva las operaciones anteriores.
     
 METHOD TCalc_Teclas(nKey, oDlg)
ENDCLASS

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

METHOD New() CLASS TCalc

   ::aRolloCalc:={{'C',' '}}
   ::nResult   :=0
 
   ::cUltima   :=''
   ::cUltimaop :=''

return SELF

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

METHOD End() CLASS TCalc

   ::aRolloCalc:={{'C',' '}}
   ::nResult   :=0

   ::cUltima   :=''
   ::cUltimaop :=''

return NIL

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

METHOD calculadora(oPadre,cPatronSalida,lBorraAlInicio) CLASS TCalc

   local oDlg
   local oBtnSalir
   local oBtnmenos, oBtnmas, oBtnpor, oBtndividir, oBtnigual, oBtnBorra
   local oBtn0, oBtn1, oBtn2, oBtn3, oBtn4, oBtn5, oBtn6, oBtn7, oBtn8, oBtn9, oBtnP, oBtnSigno
   local oBtnConv, oBtnConv2
   local oBtnDel
   local oSay
   local oBrw, n:=1
   local oGet, nGet:=0 ,cGet:='', nGetAnt:=0
   local oFont1
   local oFontLst

   if cPatronSalida=NIL .and. ::cPatronSalida=NIL
      cPatronSalida:='@E 9,999,999,999.99 '  //Formato en que se pinta el resultado.
   endif

   //default cPatronSalida:='@E 9,999,999,999.99 '  //Formato en que se pinta el resultado.
   default lBorraAlInicio :=.f.  // Al llamar al método si está en .t. borra lo que hubiera.
                                 //  Si está en .f. entonces conserva las operaciones anteriores.

   ::cPatronSalida:=cPatronSalida

    DEFINE FONT oFont1   NAME "Arial"         SIZE 0,-20
    DEFINE FONT oFontLst NAME "MS Sans Serif" SIZE 0,-14
    DEFINE DIALOG oDlg RESOURCE 'Calculadora' OF oPadre TITLE 'CALCULADORA' FONT oFont

    REDEFINE BUTTON oBtnSalir ID 500 OF oDlg MESSAGE 'SALIR';
             ACTION oDlg:end() default CANCEL UPDATE
             oBtnSalir:cargo:='S'
   
    REDEFINE BUTTON oBtnmenos ID 401 OF oDlg MESSAGE 'Resta';
             ACTION (iif(nGet<>0,(nGetAnt:=nGet,aadd(::aRolloCalc,{transform(nGet,::cPatronSalida),'-'})),(::nResult:=::nResult-nGetAnt,aadd(::aRolloCalc,{transform(iif(::cUltimaOp='=',::nResult,nGetAnt),::cPatronSalida),'-'}))) ,;
                     oBrw:gobottom(),;
                     oBrw:refresh(),;
                     iif(::nResult=0,::nResult:=nGet,::nResult:=::nResult-nGet),;
                     ::cUltimaOp:='-'           ,;
                     oSay:SetText(transform(::nResult,::cPatronSalida)),;
                     nGet:=0                    ,;
                     cGet:=''                   ,;
                     oGet:SetText('')           ,;
                     oBtnIgual:Setfocus()       ,;
                     sysrefresh() ) UPDATE
             oBtnmenos:cargo:='-'
             
    REDEFINE BUTTON oBtnmas   ID 402 OF oDlg MESSAGE 'Suma';
             ACTION (iif(nGet<>0,(nGetAnt:=nGet,aadd(::aRolloCalc,{transform(nGet,::cPatronSalida),'+'})),(::nResult:=::nResult+nGetAnt,aadd(::aRolloCalc,{transform(iif(::cUltimaOp='=',::nResult,nGetAnt),::cPatronSalida),'+'}))) ,;
                     oBrw:gobottom(),;
                     oBrw:refresh(),;
                     iif(::nResult=0,::nResult:=nGet,::nResult:=::nResult+nGet),;
                     ::cUltimaOp:='+'           ,;
                     oSay:SetText(transform(::nResult,::cPatronSalida)),;
                     nGet:=0                    ,;
                     cGet:=''                   ,;
                     oGet:SetText('')           ,;
                     oBtnIgual:Setfocus()       ,;
                     sysrefresh() ) UPDATE
             oBtnmas:cargo:='+'
             
    REDEFINE BUTTON oBtnpor   ID 403 OF oDlg MESSAGE 'Multiplica';
             ACTION (aadd( ::aRolloCalc, iif(nGet=0 .and. ::nResult<>0,{transform(::nResult,::cPatronSalida),'x'},{transform(nGet,::cPatronSalida),'x'}) ),;
                     oBrw:gobottom(),;
                     oBrw:refresh(),;
                     iif(::nResult=0,::nResult:=nGet,iif(nGet<>0,::nResult:=::nResult*nGet,)),;
                     ::cUltimaOp:='*'           ,;
                     oSay:SetText(transform(::nResult,::cPatronSalida)),;
                     nGet:=0                    ,;
                     cGet:=''                   ,;
                     oGet:SetText('')           ,;
                     oBtnIgual:Setfocus()       ,;
                     sysrefresh() ) UPDATE
             oBtnpor:cargo:='*'
             
    REDEFINE BUTTON oBtndividir ID 404 OF oDlg MESSAGE 'Divide';
             ACTION (aadd( ::aRolloCalc, iif(nGet=0 .and. ::nResult<>0,{transform(::nResult,::cPatronSalida),'/'},{transform(nGet,::cPatronSalida),'/'}) ),;
                     oBrw:gobottom(),;                  
                     oBrw:refresh(),;
                     iif(::nResult=0,::nResult:=nGet,iif(nGet<>0,::nResult:=::nResult/nGet,)),;
                     ::cUltimaOp:='/'           ,;
                     oSay:SetText(transform(::nResult,::cPatronSalida)),;
                     nGet:=0                    ,;
                     cGet:=''                   ,;
                     oGet:SetText('')           ,;
                     oBtnIgual:Setfocus()       ,;
                     sysrefresh() ) UPDATE
             oBtndividir:cargo:='/'
                     
    REDEFINE BUTTON oBtnigual   ID 405 OF oDlg MESSAGE 'Calcula resultado';
             ACTION (iif(nGet=0,,aadd( ::aRolloCalc, {transform(nGet,::cPatronSalida),iif(::cUltimaOp='+' .or. ::cUltimaOp='-' .or. ::cUltimaOp='*' .or. ::cUltimaOp='/',' ',::cUltimaOp)} )),;
                     ::nCalculadIgual(nGet),;
                     aadd( ::aRolloCalc, {transform(::nResult,::cPatronSalida),'='} ),;
                     oBrw:gobottom(),oBrw:gobottom(),;                  
                     oBrw:refresh(),;
                     ::cUltimaOp:='='              ,;
                     oSay:SetText(transform(::nResult,::cPatronSalida)),;
                     nGet:=0                       ,;
                     nGetAnt:=0                    ,;
                     cGet:=''                      ,;
                     oGet:SetText('')              ,;
                     oBtnIgual:Setfocus()          ,;
                     sysrefresh() ) UPDATE
             oBtnigual:cargo:='='          

    REDEFINE BUTTON oBtnBorra ID 425 OF oDlg MESSAGE 'Borra todos los cálculos';
             ACTION (iif( len( ::aRolloCalc ) > 0,;
                          ( aSize( ::aRolloCalc, 0 ), oBrw:Refresh() ), ),;
                     aadd( ::aRolloCalc, {' ','C'} ),;
                     oBrw:gotop()                 ,;
                     oBrw:refresh()               ,;
                     ::nResult:=0                 ,;
                     ::cUltimaOp:='R'             ,;
                     oSay:SetText('0')            ,;
                     nGet:=0                      ,;
                     cGet:=''                     ,;
                     oGet:SetText('')             ,;
                     oBtnIgual:Setfocus()         ,;
                     sysrefresh() ) UPDATE
             oBtnBorra:cargo:='R'    
   
    REDEFINE BUTTON oBtnDel ID 426 OF oDlg MESSAGE 'Borra último dígito';
             ACTION (::cUltima:='CE'            ,;
                     iif(::cUltimaOp='=' .or. ::cUltimaOp='AP' .or. ::cUltimaOp='AE',(::cUltimaOp:='',::nResult:=0,aadd( ::aRolloCalc, {' ',' '} ), oBrw:gobottom(),oBrw:refresh()),),;
                     iif(nGet<>0,(              ,;
                     cGet:=LEFT(cGet,len(cget)-1),;
                     nGet:=val(cGet)),)         ,;
                     oGet:SetText(cGet)         ,;
                     oBtnIgual:Setfocus()       ,;
                     sysrefresh() ) UPDATE
             oBtnDel:cargo:=chr(8)
   
    REDEFINE BUTTON oBtnConv ID 407 OF oDlg MESSAGE 'Convierte de euros a PTS';
             ACTION ( iif(nGet<>0,::nResult:=round(nGet*166.386,0),::nResult:=round(::nResult*166.386,0)),;
                     aadd( ::aRolloCalc, {transform(::nResult,'@E 9,999,999,999      '),'pts'} ),;
                     oBrw:gobottom(),;                  
                     oBrw:refresh(),;
                     ::cUltimaOp:='AP'             ,;  // AP = a Pesetas
                     oSay:SetText(transform(::nResult,'@E 9,999,999,999 pts')),;
                     nGet:=0                       ,;
                     cGet:=''                      ,;
                     oGet:SetText('')              ,;
                     oBtnIgual:Setfocus()          ,;
                     sysrefresh() ) UPDATE
             oBtnConv:cargo:='E'                
   
    REDEFINE BUTTON oBtnConv2 ID 408 OF oDlg MESSAGE 'Convierte de PTS a Euro';
             ACTION ( iif(nGet<>0,::nResult:=round(nGet/166.386,2),::nResult:=round(::nResult/166.386,2)),;
                     aadd( ::aRolloCalc, {transform(::nResult,'@E 9,999,999,999.99 '),' €'} ),;
                     oBrw:gobottom(),;                  
                     oBrw:refresh(),;
                     ::cUltimaOp:='AE'             ,;  // AE = a Euros
                     oSay:SetText(transform(::nResult,'@E 9,999,999,999.99 €')),;
                     nGet:=0                       ,;
                     cGet:=''                      ,;
                     oGet:SetText('')              ,;
                     oBtnIgual:Setfocus()          ,;
                     sysrefresh() ) UPDATE
             oBtnConv:cargo:='P'    
             
    REDEFINE BUTTON oBtn0   ID 100 OF oDlg ;
             ACTION (::cUltima:='0'             ,;
                     iif(::cUltimaOp='=' .or. ::cUltimaOp='AP' .or. ::cUltimaOp='AE',(::cUltimaOp:='',::nResult:=0,aadd( ::aRolloCalc, {' ',' '} ), oBrw:gobottom(),oBrw:refresh()),),;
                     iif(nGet<>0 .or. at(".",cGet)>0,(              ,;
                     cGet:=cGet+::cUltima       ,;
                     nGet:=val(cGet)),)         ,;
                     oGet:SetText(cGet)         ,;
                     oBtnIgual:Setfocus()       ,;
                     sysrefresh() ) UPDATE
             oBtn0:cargo:='0'
    REDEFINE BUTTON oBtn1   ID 101 OF oDlg;
             ACTION (::cUltima:='1'             ,;
                     iif(::cUltimaOp='=' .or. ::cUltimaOp='AP' .or. ::cUltimaOp='AE',(::cUltimaOp:='',::nResult:=0,aadd( ::aRolloCalc, {' ',' '} ), oBrw:gobottom(),oBrw:refresh()),),;
                     cGet:=cGet+::cUltima       ,;
                     nGet:=val(cGet)            ,;
                     oGet:SetText(cGet)         ,;
                     oBtnIgual:Setfocus()       ,;
                     sysrefresh() ) UPDATE
             oBtn1:cargo:='1'
    REDEFINE BUTTON oBtn2   ID 102 OF oDlg;
             ACTION (::cUltima:='2'             ,;
                     iif(::cUltimaOp='=' .or. ::cUltimaOp='AP' .or. ::cUltimaOp='AE',(::cUltimaOp:='',::nResult:=0,aadd( ::aRolloCalc, {' ',' '} ), oBrw:gobottom(),oBrw:refresh()),),;
                     cGet:=cGet+::cUltima       ,;
                     nGet:=val(cGet)            ,;
                     oGet:SetText(cGet)         ,;
                     oBtnIgual:Setfocus()       ,;
                     sysrefresh() ) UPDATE
             oBtn2:cargo:='2'
    REDEFINE BUTTON oBtn3   ID 103 OF oDlg;
             ACTION (::cUltima:='3'             ,;
                     iif(::cUltimaOp='=' .or. ::cUltimaOp='AP' .or. ::cUltimaOp='AE',(::cUltimaOp:='',::nResult:=0,aadd( ::aRolloCalc, {' ',' '} ), oBrw:gobottom(),oBrw:refresh()),),;
                     cGet:=cGet+::cUltima       ,;
                     nGet:=val(cGet)            ,;
                     oGet:SetText(cGet)         ,;
                     oBtnIgual:Setfocus()       ,;
                     sysrefresh() ) UPDATE
             oBtn3:cargo:='3'
    REDEFINE BUTTON oBtn4   ID 104 OF oDlg;
             ACTION (::cUltima:='4'             ,;
                     iif(::cUltimaOp='=' .or. ::cUltimaOp='AP' .or. ::cUltimaOp='AE',(::cUltimaOp:='',::nResult:=0,aadd( ::aRolloCalc, {' ',' '} ), oBrw:gobottom(),oBrw:refresh()),),;
                     cGet:=cGet+::cUltima       ,;
                     nGet:=val(cGet)            ,;
                     oGet:SetText(cGet)         ,;
                     oBtnIgual:Setfocus()       ,;
                     sysrefresh() ) UPDATE
             oBtn4:cargo:='4'
    REDEFINE BUTTON oBtn5   ID 105 OF oDlg;
             ACTION (::cUltima:='5'             ,;
                     iif(::cUltimaOp='=' .or. ::cUltimaOp='AP' .or. ::cUltimaOp='AE',(::cUltimaOp:='',::nResult:=0,aadd( ::aRolloCalc, {' ',' '} ), oBrw:gobottom(),oBrw:refresh()),),;
                     cGet:=cGet+::cUltima       ,;
                     nGet:=val(cGet)            ,;
                     oGet:SetText(cGet)         ,;
                     oBtnIgual:Setfocus()       ,;
                     sysrefresh() ) UPDATE
             oBtn5:cargo:='5'
    REDEFINE BUTTON oBtn6   ID 106 OF oDlg;
             ACTION (::cUltima:='6'             ,;
                     iif(::cUltimaOp='=' .or. ::cUltimaOp='AP' .or. ::cUltimaOp='AE',(::cUltimaOp:='',::nResult:=0,aadd( ::aRolloCalc, {' ',' '} ), oBrw:gobottom(),oBrw:refresh()),),;
                     cGet:=cGet+::cUltima       ,;
                     nGet:=val(cGet)            ,;
                     oGet:SetText(cGet)         ,;
                     oBtnIgual:Setfocus()       ,;
                     sysrefresh() ) UPDATE
             oBtn6:cargo:='6'
    REDEFINE BUTTON oBtn7   ID 107 OF oDlg;
             ACTION (::cUltima:='7'             ,;
                     iif(::cUltimaOp='=' .or. ::cUltimaOp='AP' .or. ::cUltimaOp='AE',(::cUltimaOp:='',::nResult:=0,aadd( ::aRolloCalc, {' ',' '} ), oBrw:gobottom(),oBrw:refresh()),),;
                     cGet:=cGet+::cUltima       ,;
                     nGet:=val(cGet)            ,;
                     oGet:SetText(cGet)         ,;
                     oBtnIgual:Setfocus()       ,;
                     sysrefresh() ) UPDATE
             oBtn7:cargo:='7'
    REDEFINE BUTTON oBtn8   ID 108 OF oDlg;
             ACTION (::cUltima:='8'             ,;
                     iif(::cUltimaOp='=' .or. ::cUltimaOp='AP' .or. ::cUltimaOp='AE',(::cUltimaOp:='',::nResult:=0,aadd( ::aRolloCalc, {' ',' '} ), oBrw:gobottom(),oBrw:refresh()),),;
                     cGet:=cGet+::cUltima       ,;
                     nGet:=val(cGet)            ,;
                     oGet:SetText(cGet)         ,;
                     oBtnIgual:Setfocus()       ,;
                     sysrefresh() ) UPDATE
             oBtn8:cargo:='8'
    REDEFINE BUTTON oBtn9   ID 109 OF oDlg;
             ACTION (::cUltima:='9'             ,;
                     iif(::cUltimaOp='=' .or. ::cUltimaOp='AP' .or. ::cUltimaOp='AE',(::cUltimaOp:='',::nResult:=0,aadd( ::aRolloCalc, {' ',' '} ), oBrw:gobottom(),oBrw:refresh()),),;
                     cGet:=cGet+::cUltima       ,;
                     nGet:=val(cGet)            ,;
                     oGet:SetText(cGet)         ,;
                     oBtnIgual:Setfocus()       ,;
                     sysrefresh() ) UPDATE
             oBtn9:cargo:='9'
    REDEFINE BUTTON oBtnP   ID 110 OF oDlg;
             ACTION (::cUltima:='.'             ,;
                     iif(::cUltimaOp='=' .or. ::cUltimaOp='AP' .or. ::cUltimaOp='AE',(::cUltimaOp:='',::nResult:=0,aadd( ::aRolloCalc, {' ',' '} ), oBrw:gobottom(),oBrw:refresh()),),;
                     cGet:=cGet+::cUltima       ,;
                     nGet:=val(cGet)            ,;
                     oGet:SetText(cGet)         ,;
                     oBtnIgual:Setfocus()       ,;
                     sysrefresh() ) UPDATE WHEN int(nGet)==nGet
             oBtnP:cargo:='.'
    REDEFINE BUTTON oBtnSigno ID 111 OF oDlg;
             ACTION (::cUltima:='signo'    ,;
                     iif(::cUltimaOp='=' .or. ::cUltimaOp='AP' .or. ::cUltimaOp='AE',(::cUltimaOp:='',::nResult:=0,aadd( ::aRolloCalc, {' ',' '} ), oBrw:gobottom(),oBrw:refresh()),),;
                     nGet:=(-1)*nGet       ,;
                     oGet:SetText(nGet)    ,;
                     cGet:=alltrim(str(nGet)),;
                     oBtnIgual:Setfocus()  ,;
                     sysrefresh() ) UPDATE
             oBtnSigno:cargo:=' '              
    REDEFINE SAY oGet VAR nGet ID 211 OF oDlg FONT oFont1 ;
             COLOR nrgb( 0,  0, 0),nrgb(255,255,200) UPDATE
   
    REDEFINE SAY oSay VAR ::nResult ID 200 OF oDlg FONT oFont1 ;
             COLOR nrgb(50,250,50),nrgb(0,0,0) UPDATE
                               
    REDEFINE LISTBOX oBrw FIELDS ;
                     ::aRolloCalc[n][1],;
                     ::aRolloCalc[n][2];
             HEAD 'valor',' ';
             ID 212 OF oDlg FONT oFontLst COLOR  nrgb(0,0,0),nrgb(255,255,200) ;//clrLtrBrow,clrFonBrow ;
             UPDATE
   
    oBrw:aJustify  :={.t.,.f.}
    oBrw:aColSizes :={GetFontInfo(oFontLst)[2] * 1.25 * 17, GetFontInfo(oFontLst)[2] * 1.25 * 3} //aMatrizTc({17,3},oFontLst)
    oBrw:bGotop    := { || n := 1 }
    oBrw:bGoBottom := { || n := eval( oBrw:bLogicLen ) }
    oBrw:bSkip     := { | nwant, nold | nold := n , n += nwant,;
                                 n := max( 1, min( n, eval( oBrw:bLogicLen ))),;
                                 n - nOld }
    oBrw:bLogicLen := { || len( ::aRolloCalc ) }

    oBrw:nClrPane:={|| iif(::aRolloCalc[n][2]=='=',nrgb(200,255,125),nrgb(255,255,200)) }

    oDlg:bKeyDown:={|nKey| ::TCalc_Teclas(nKey,oDlg)}
   ACTIVATE DIALOG oDlg CENTERED ON INIT (if(lBorraAlInicio,oBtnBorra:CLICK(),.f.),oBrw:gobottom(),oBrw:refresh())
 oFont1:end()
 oFontLst:end()
return ::nResult

METHOD nCalculadigual(nGet) CLASS TCalc

   do CASE
   CASE ::cUltimaOp = '-'
        ::nResult := ::nResult - nGet
   CASE ::cUltimaOp = '+'
        ::nResult := ::nResult + nGet
   CASE ::cUltimaOp = '*'
        ::nResult := ::nResult * nGet
   CASE ::cUltimaOp = '/'
        ::nResult := ::nResult / nGet
   endcase

return NIL

METHOD TCalc_Teclas(nKey, oDlg) class TCalc

   local ny

   for ny:=1 TO len(oDlg:aControls)
      if oDlg:aControls[ny]:cargo==upper(chr(nKey))
         oDlg:aControls[ny]:CLICK()
      endif
   next ny

return nil
 


João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7214
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Calculator revisited

Postby TimStone » Wed May 28, 2014 7:46 pm

The code for those two buttons still generates a syntax error.

I found some extra commas on those two buttons and removed them. Now it builds
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2904
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Calculator revisited

Postby TimStone » Wed May 28, 2014 9:43 pm

I have it working now. I like the button sizing and the "tape" it displays.

Here is a thought. When a user is in an active numeric get, if they pressed the F12 key, it would be nice for the calculator to popup with the current get value, then a calculation could be made on it, and the value returned to the current get field.

Code suggestions for this behavior would be appreciated.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2904
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Calculator revisited

Postby Silvio.Falconi » Thu May 29, 2014 6:58 am

Friend,
I I use a Math function as sin or cos with getcalc of Timm it make error
do you have a solution for 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: 6772
Joined: Thu Oct 18, 2012 7:17 pm

Re: Calculator revisited

Postby Antonio Linares » Thu May 29, 2014 4:09 pm

Tim,

You could use:

SetKey( VK_F12, { || MyCalculator( GetTextWindow( GetFocus() ) ) } )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Calculator revisited

Postby TimStone » Thu May 29, 2014 4:46 pm

Is GetTextWindow( ) an actual function ? The compiler doesn't think so.

The calling procedure, in MAIN( ), for the suggested calculator is this:

public oCalc:=tCalc():new()
setkey(VK_F10, {|| oCalc:calculadora(oWnd,'@E 9,999,999.9999 ')})

What would be nice is for us to detect the current GET, if one is present and numeric, pass it's value to the calculator, and then return the result to the same Get field.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2904
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Calculator revisited

Postby Enrico Maria Giordano » Thu May 29, 2014 5:03 pm

Tim,

TimStone wrote:Is GetTextWindow( ) an actual function ? The compiler doesn't think so.


Code: Select all  Expand view
GetWindowText()


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8315
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Calculator revisited

Postby lucasdebeltran » Thu May 29, 2014 7:30 pm

Timm,

Can you please post the fixed code?.

Thanks
Muchas gracias. Many thanks.

Un saludo, Best regards,

Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]

Implementando MSVC 2010, FWH64 y ADO.

Abandonando uso xHarbour y SQLRDD.
User avatar
lucasdebeltran
 
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am

Re: Calculator revisited

Postby TimStone » Thu May 29, 2014 8:00 pm

I found the two buttons listed earlier in this thread had IIF( ) statements with 4 parameters instead of 3. In each case there was an extra comma ( , ). Remove those and it will build.

The error only occurred with Harbour and not xHarbour, although it was a clear error.

I don't want to post my revision because I changed prompts, coloring, etc. to match my program ( and use my established fonts and brush).
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2904
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Calculator revisited

Postby Antonio Linares » Thu May 29, 2014 9:23 pm

Tim,

It was a typo in my code, please use the function name that Enrico says, thanks :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Calculator revisited

Postby TimStone » Thu May 29, 2014 9:25 pm

I do that a lot these days. My excuse is that I'm getting old ...
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2904
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Calculator revisited

Postby Antonio Linares » Thu May 29, 2014 9:27 pm

Nah, we should love our mistakes ;-)

We are humans :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Calculator revisited

Postby Silvio.Falconi » Sun Jun 01, 2014 8:28 am

Antonio,
can we use math function on getcalc ?

sample as sin() cos() tan()

I tried compiling get calc with a function but when I insert the function it give me 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: 6772
Joined: Thu Oct 18, 2012 7:17 pm

Re: Calculator revisited

Postby Antonio Linares » Tue Jun 03, 2014 5:42 am

Silvio,

As full source code is provided you can modify your calculator the way you may need it :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 91 guests