FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Switches (switchtst.prg)
Posts: 1279
Joined: Mon Feb 06, 2006 04:28 PM
Switches (switchtst.prg)
Posted: Tue Jun 06, 2017 11:28 AM

Este prg, al compilarlo me da error tanto en xharbour como en harbour.

Application

Path and name: C:\fwh\samples\switchtst.exe (32 bits)
Size: 3,456,000 bytes
Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20161218)
FiveWin version: FWHX 17.04
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 0 secs
Error occurred at: 06/06/17, 08:04:01
Error description: Error BASE/1066 Argument error: conditional
Args:
[ 1] = U

Stack Calls

Called from: .\source\classes\TSWITCH.PRG => TSWITCH:NEW( 105 )
Called from: switchtst.prg => MAIN( 44 )

Saludos/Regards,

José Murugosa

"Los errores en programación, siempre están entre la silla, el teclado y la IA!!"
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Switches (switchtst.prg)
Posted: Wed Jun 07, 2017 02:49 PM

José,

Falta hacer un DEFAULT lOval := .F. en el código

gracias

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1279
Joined: Mon Feb 06, 2006 04:28 PM
Re: Switches (switchtst.prg)
Posted: Wed Jun 07, 2017 04:00 PM
No funcionó, yo lo resolví corrigiendo el encabezado de la clase tswitch en switchtst.prg añadiendo los valores loval y lradstyle.

Así funciona perfectamente, añadí al ejemplo que los switches fueran uno no oval, uno oval y uno radstyle:
Code (fw): Select all Collapse
#include "fivewin.ch"

#xcommand @ <nRow>, <nCol> SWITCH [ <oSw> VAR ] <lVar> ;
             [ PROMPT <cCaption> ] ;
             [ <of:OF, WINDOW, DIALOG> <oWnd> ] ;
             [ SIZE <nWidth>, <nHeight> ] ;
             [ <help:HELPID, HELP ID> <nHelpId> ] ;
             [ FONT <oFont> ] ;
             [ <change: ON CLICK, ON CHANGE> <uClick> ] ;
             [ VALID   <ValidFunc> ] ;
             [ <color: COLOR, COLORS> <nClrFore> [,<nClrBack>] ] ;
             [ <design: DESIGN> ] ;
             [ <pixel: PIXEL> ] ;
             [ MESSAGE <cMsg> ] ;
             [ <update: UPDATE> ] ;
             [ WHEN <WhenFunc> ] ;
             [ BORDERSIZE <nBorderSize> ] [ BORDERCOLOR <nClrBorder> ] ;
             [ THUMBSIZE  <nThumbSize>  ] [ THUMBCOLOR  <nClrThumb> ] ;
           [ RADSTYLE  <lRadStyle>  ] [ OVAL  <lOval> ];           
      => ;
         [ <oSw> := ] TSwitch():New( <nRow>, <nCol>, <cCaption>,;
             bSETGET(<lVar>), <oWnd>, <nWidth>, <nHeight>, <nHelpId>,;
             [<{uClick}>], <oFont>, <{ValidFunc}>, <nClrFore>, <nClrBack>,;
             <.design.>, <.pixel.>, <cMsg>, <.update.>, <{WhenFunc}>, ;
             <nBorderSize>, <nClrBorder>, <nThumbSize>, <nClrThumb>, <lRadStyle>, <lOval> )

function Main()

   local oWnd, oFont
   local lVar1, lVar2, lVar3
   local oYn1, oYn2, oYn3, oSay1, oSay2, oSay3

   lVar1 := lVar2 := lVar3 := .t.

   

   DEFINE FONT oFont NAME "Segoe UI Light" SIZE 0,-18 BOLD

   DEFINE WINDOW oWnd COLOR CLR_GRAY,CLR_WHITE
   oWnd:SetFont( oFont )
//   oWnd:nOpacity := 140

   @  98, 40 SAY oSay1 PROMPT If( lVar1, 'On', 'Off' ) SIZE 60,30 PIXEL OF oWnd UPDATE

   @ 100,207 SWITCH oYn1 VAR lVar1 OVAL .f. PIXEL OF oWnd UPDATE ;
      COLOR CLR_GREEN, CLR_GRAY ;
      ON CHANGE oWnd:Update()

   @ 128, 40 SAY oSay2 PROMPT If( lVar2, 'On', 'Off' ) SIZE 60,30 PIXEL OF oWnd UPDATE

   @ 130,207 SWITCH oYn2 VAR lVar2 OVAL .t. PIXEL OF oWnd UPDATE ;
      COLOR CLR_GREEN, CLR_GRAY ;
      THUMBSIZE 16 THUMBCOLOR CLR_BLUE ;
      ON CHANGE oWnd:Update()

   @ 158, 40 SAY oSay3 PROMPT If( lVar3, 'On', 'Off' ) SIZE 60,30 PIXEL OF oWnd UPDATE

   @ 160,207 SWITCH oYn3 VAR lVar3 OVAL .f. RADSTYLE .t.PIXEL OF oWnd UPDATE ;
      ON CHANGE oWnd:Update()                                                   //con radstyle oval debe ser .f.
   
   ACTIVATE WINDOW oWnd
   RELEASE FONT oFont

return nil


Quizá sería conveniente corregir este cabezal para próximas versiones y añadirlo a fivewin.ch o a un "switch.ch", eso lo dejo a vuestro criterio :-).
Saludos/Regards,

José Murugosa

"Los errores en programación, siempre están entre la silla, el teclado y la IA!!"
Posts: 2064
Joined: Fri Jan 06, 2006 09:28 PM
Re: Switches (switchtst.prg)
Posted: Wed Jun 07, 2017 04:21 PM

Saludos, disculpa mi ignorancia, podrias dar una idea de su utilidad.? gracias, saludos... :shock:

Dios no está muerto...



Gracias a mi Dios ante todo!
Posts: 1279
Joined: Mon Feb 06, 2006 04:28 PM
Re: Switches (switchtst.prg)
Posted: Wed Jun 07, 2017 05:28 PM


Son los switches tipo Android :-)
El primero es en formato rectangular (no oval) en off, el segundo es de tipo oval en on, y el tercero es tipo Radio en on en la imagen, es el resultado del código que está más arriba.
Saludos/Regards,

José Murugosa

"Los errores en programación, siempre están entre la silla, el teclado y la IA!!"
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Switches (switchtst.prg)
Posted: Wed Jun 07, 2017 05:31 PM
En que momento se podrá usar?



??????????
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1279
Joined: Mon Feb 06, 2006 04:28 PM
Re: Switches (switchtst.prg)
Posted: Thu Jun 08, 2017 09:56 AM

Karinha,

No entendí tu pregunta..

Es una opción de diferente estética a los checkboxes, disponible en las últimas versiones de fivewin.

Saludos/Regards,

José Murugosa

"Los errores en programación, siempre están entre la silla, el teclado y la IA!!"
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Switches (switchtst.prg)
Posted: Thu Jun 08, 2017 12:54 PM

Gracias José. Me parece, que este modelo sigue siendo un poco primitivo. No me gustó. Creo que tiene que ser mejorado.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 2064
Joined: Fri Jan 06, 2006 09:28 PM
Re: Switches (switchtst.prg)
Posted: Thu Jun 08, 2017 02:57 PM

Jose, gracias por tu explicacion e idea, "entre gustos y colores", siempre es bueno salir de la rutina y tener opciones y asi no existe monopolio, pero de verdad crei seria para algo "diferente", igual de mi parte te felicito y agradezco tu aporte, pero para mi es como mezclar naranjas con cebollas, me gusta mas el stylo original de los checkbox, para que inventar la rueda.?, gracias, saludos... :shock:

Dios no está muerto...



Gracias a mi Dios ante todo!
Posts: 1279
Joined: Mon Feb 06, 2006 04:28 PM
Re: Switches (switchtst.prg)
Posted: Thu Jun 08, 2017 03:06 PM

Totalmente valido estimado. :-)

Saludos/Regards,

José Murugosa

"Los errores en programación, siempre están entre la silla, el teclado y la IA!!"
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Switches (switchtst.prg)
Posted: Fri Jun 09, 2017 10:41 AM
The command translate in fivewin.ch is the correct one.
Just remove the xcommand inside the sample program.

This is the revised sample switchtst.prg
Code (fw): Select all Collapse
#include "fivewin.ch"

function Main()

   local oWnd, oFont
   local lVar1, lVar2, lVar3
   local oYn1, oYn2, oYn3, oSay1, oSay2, oSay3

   lVar1 := lVar2 := lVar3 := .t.

   DEFINE FONT oFont NAME "Segoe UI Light" SIZE 0,-18 BOLD

   DEFINE WINDOW oWnd COLOR CLR_GRAY,CLR_WHITE
   oWnd:SetFont( oFont )
//   oWnd:nOpacity := 140

   @  98, 40 SAY oSay1 PROMPT If( lVar1, 'On', 'Off' ) SIZE 60,30 PIXEL OF oWnd UPDATE

   @ 100,207 SWITCH oYn1 VAR lVar1 PIXEL OF oWnd UPDATE ;
      COLOR CLR_GREEN, CLR_GRAY ;
      ON CHANGE oWnd:Update()

   @ 128, 40 SAY oSay2 PROMPT If( lVar2, 'On', 'Off' ) SIZE 60,30 PIXEL OF oWnd UPDATE

   @ 130,207 SWITCH oYn2 VAR lVar2 PIXEL OF oWnd UPDATE OVALSTYLE ;
      COLOR CLR_GREEN, CLR_GRAY ;
      THUMBSIZE 16 THUMBCOLOR CLR_BLUE ;
      ON CHANGE oWnd:Update()

   @ 158, 40 SAY oSay3 PROMPT If( lVar3, 'On', 'Off' ) SIZE 60,30 PIXEL OF oWnd UPDATE

   @ 160,207 SWITCH oYn3 VAR lVar3  PIXEL OF oWnd UPDATE RADIOSTYLE ;
      ON CHANGE oWnd:Update()

   ACTIVATE WINDOW oWnd
   RELEASE FONT oFont

return nil

Rectangular and Oval styles are used in Windows 8.1 and 10.
Not only in Android.
Regards



G. N. Rao.

Hyderabad, India
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Switches (switchtst.prg)
Posted: Fri Jun 09, 2017 01:49 PM
Very good mister Nages, thanks.



Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341

Continue the discussion