Lyrics restrict entries in the TEXTBOX-> INPUSMASK

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
mustafa
Posts: 1158
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Lyrics restrict entries in the TEXTBOX-> INPUSMASK

Post by mustafa »

Hello Friends:
In the Clipper programming by restriction of
Data could be to attempt to enter restricted
in my case letters distrintas to "SNFGH" ie
that the user can only press each time "S" or
"N" or "F" etc.etc. unable to enter other letters
aotorizadas and besides that only in all caps
mod = "N"
@ 05.12 SAY "Data Entry" + SPACE (3) + "(SNFGH)";
GET PICTURE "@!" VALID mod $ "SNFGH"
READ

My question as I do the same by
InputMask TextBox?
mod = "N"
@ 168.313 TextBox Tex_02;
VALUE "N";
BACKCOLOR (183,214,255);
WIDTH 15 HEIGHT 18;
InputMask "!" VALID mod $ "SNFGH"

Presented in this way is giving me ERROR
Thanks for your attention
*----------------------------------------------------*
Restringir Entradas de Letras en el TEXTBOX -> INPUSMASK
Hola Amigos:
En la programación Clipper mediante restricción de
Datos se podia restringir que se intentara entrar
en mi caso letras distrintas a "SNFGH" es decir
que el usuario solo puede pulsar cada vez "S" o
"N" o "F" etc.etc. no pudiendo ingresar otras letras
que las aotorizadas y ademas solo en mayusculas

mod = "N"
@ 05,12 SAY " Entrada de Datos:"+SPACE(3)+"(SNFGH)";
GET PICTURE "@!" VALID mod$"SNFGH"
READ

Mi Pregunta como puedo hacer lo mismo mediante un
TEXTBOX con INPUTMASK ?
mod = "N"
@ 168,313 TEXTBOX Tex_02 ;
VALUE "N" ;
BACKCOLOR {183,214,255} ;
WIDTH 15 HEIGHT 18 ;
INPUTMASK "!" VALID mod$"SNFGH"

Presentado de este modo me está dando ERROR
Gracias por su atención
Mustafa :(
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: Lyrics restrict entries in the TEXTBOX-> INPUSMASK

Post by srvet_claudio »

Hola Mustafa,
aparentemente según el tutorial TEXTBOX no posee clausula VALID. Aqui va una función que la emula.
Saludos
Claudio

Code: Select all

#include <hmg.ch>


PROCEDURE Main

DEFINE WINDOW Win_1 ;
AT 0,0 ;
WIDTH 640 HEIGHT 450 ;
TITLE 'Invento' ;
MAIN 



PRIVATE mod := "N"

@ 168,313 TEXTBOX Tex_02 ;
VALUE mod ;
BACKCOLOR {183,214,255} ;
WIDTH 150 HEIGHT 18 ;
INPUTMASK "!" ON LOSTFOCUS func_test () ON ENTER func_test ()


@ 200,313 TEXTBOX Tex_03 ;
VALUE "Texto molesto" ;


END WINDOW

CENTER WINDOW Win_1

ACTIVATE WINDOW Win_1

RETURN 

function func_test ()
    if (win_1.tex_02.value $ "SNFGH") = .F.
       win_1.tex_02.value := mod
       win_1.tex_02.setfocus
    endif
return

Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
mustafa
Posts: 1158
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: Lyrics restrict entries in the TEXTBOX-> INPUSMASK

Post by mustafa »

Hola claudio
El Invento parece que funciona muy bien
gracias atender mi consulta.
Mustafa
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: Lyrics restrict entries in the TEXTBOX-> INPUSMASK

Post by srvet_claudio »

Hola Mustafa,
mirando los ejemplos, encontré una forma mucho mas genérica de resolver el problema que la función anterior:

Si los datos son incorrectos no permite abandonar la edición con:

Code: Select all

ON LOSTFOCUS If (.NOT.(This.Value $ "SNFGH") , This.SetFocus, NIL)

Code: Select all

ON LOSTFOCUS If (.NOT.(This.Value $ "SNFGH") , EVAL({|| This.SetFocus, This.Value:= 'N'}), NIL)
En esta ultima forma, ademas asigna un valor por defecto, en este caso 'N'
Lo mismo vale para ON ENTER

Saludos,
Claudio
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
mustafa
Posts: 1158
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: Lyrics restrict entries in the TEXTBOX-> INPUSMASK

Post by mustafa »

Hola Claudio
Muy amable por tu contestación
Reciba un cordial Saludo
Mustafa
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: Lyrics restrict entries in the TEXTBOX-> INPUSMASK

Post by srvet_claudio »

Hola Mustafa,
Esta función emula el viejo WHEN de Clipper, siguiendo con el ejemplo si el campo es diferente de 'N' no permite
la edición de los datos

Formato HMG:

Code: Select all

ON GOTFOCUS IF (This.Value <> "N", This.Enabled := .F., This.Enabled := .T.)
Formato no convencional con función en C:

Code: Select all

ON GOTFOCUS IF (This.Value <> "N", SET_TAB_KEY(), NIL)
Funcion en C:

Code: Select all

#pragma begindump

#include <shlobj.h>   
#include <winuser.h>
#include <windows.h>
#include "hbapi.h"

// Emula la digitacion de la tecla TAB, en consecuencia le pasa el foco al siguiente control activo

HB_FUNC (SET_TAB_KEY)
{  
   keybd_event(VK_TAB, VK_TAB, NULL, NULL); 
}

#pragma enddump
En esta ultima forma si no se satisface la condición le pasa el foco al siguiente control activo (simula la digitacion de la tecla
TAB para pasar al siguiente control).

Saludos
Claudio
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
mustafa
Posts: 1158
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: Lyrics restrict entries in the TEXTBOX-> INPUSMASK

Post by mustafa »

Hola amigo Claudio
He puesto en practica tu codigo haber si lo he
sabido interpretar ? Mira este sample que he puesto.
http://hmgforum.com/viewtopic.php?f=15&t=1244
En Codigo Fuente del Fichero "Create.Prg" si miras veras
@ 168,313 TEXTBOX Tex_02 ;
VALUE "" ;
BACKCOLOR {183,214,255} ;
WIDTH 15 HEIGHT 18 ;
INPUTMASK "!" ON LOSTFOCUS If (.NOT.(This.Value $ "CNDLM") , EVAL({|| This.SetFocus, This.Value:= 'C'}), NIL)

Bueno lo he puesto a mi manera pero veo que funciona.
Un saludo cordial
Mustafa
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: Lyrics restrict entries in the TEXTBOX-> INPUSMASK

Post by srvet_claudio »

Mustafa,
me alegro que te funciono.
Reitero lo que te postee sobre el "sample": FELICITACIONES!!!
Saludos,
Claudio.
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: Lyrics restrict entries in the TEXTBOX-> INPUSMASK

Post by bpd2000 »

srvet_claudio wrote:Hola Mustafa,
aparentemente según el tutorial TEXTBOX no posee clausula VALID. Aqui va una función que la emula.
Saludos
Claudio
Dear Dr. Claudio
Request to have VALID and WHEN clause in TEXTBOX in next version of HMG
BPD
Convert Dream into Reality through HMG
User avatar
serge_girard
Posts: 3165
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Lyrics restrict entries in the TEXTBOX-> INPUSMASK

Post by serge_girard »

Good idea BPD!

Serge
There's nothing you can do that can't be done...
Post Reply