FWH 14.08: MsgGet() to handle arrays and Quick Dialogs

FWH 14.08: MsgGet() to handle arrays and Quick Dialogs

Postby nageswaragunupudi » Sat Sep 06, 2014 7:01 am

When we need to get user input for a single variable, MsgGet() function is very handy. But when we need to obtain user input for 2 or more variables MsgGet() does not help and we may need to quickly code a small dialog box.

Now MsgGet is extended to handle arrays. Syntax:
MsgGet( cTitle, [ cMessage (or) aPrompts ], aData ) --> lModified

Simple example:
Code: Select all  Expand view

local cName := "Mark"
local cCity := "New York"
local aData

aData := { cName, cCity }
if MsgGet( "Enter Values", { "Name", "City" }, aData )
   cName := aData[ 1 ]
   cCity := aData[ 2 ]
   ? cName, cCity
endif
 

Note: MsgGet() automatically pads some extra space for data entry and trims the values while returning.

Still this does not impress much. Even this involves writing many lines of code. If there are more variables more the code. We may still feel comfortable with coding a small dialog box of our own.

Now FWH makes the process even much simpler with the translate EDITVARS.
This is the translate:
#xtranslate EDITVARS <v1> [,<vN>] ;
[ TITLE <ttl> ] ;
[ PROMPTS <prmt,...> ] ;
[ PICTURES <pic,...> ] ;
[ VALIDS <bvld,...> ] ;
=> ;
MsgGet( <ttl>, {<prmt>}, ;
ArrTranspose( \{ \{ <"v1"> [,<"vN">] \}, ;
\{ bSETGET( <v1> ) [, bSETGET( <vN> ) ] \} , nil, ;
{<pic>}, {<bvld>} \} ) )

Now let us see how simole it is to get user input for multiple variables. Any number of variables.

First a very simple case:
Code: Select all  Expand view

   local cName, cCity, lMarried := .f.,  nSalary := 0.00

   EDITVARS cName, cCity, lMarried, nSalary
   ? cName, cCity, lMarried, nSalary
 


Image

Now let us use User friendly prompts and this time let us get User name and Password:
Code: Select all  Expand view

   local cUser, cPW

   EDITVARS cUser, cPW PROMPTS "User Name", "Password"
   ? cUser, cPW
 


Image

Please note how password edit is handled automatically.

The capability is not limited to two or three vairables. We can use for unlimited number of variables. The dialog box SCROLLS.
It is also possible for us to specify picture clauses, combo boxes, dbcombos, checkboxes (auto), memo edits, valids etc with a single command.

Here is a more complex example:
Code: Select all  Expand view

   local cName, cCity, cNotes
   local cState   := "NY"
   local lMarried := .f., nAge := 20, nSalary := 20000.00
   local aStates

   use c:\fwh\samples\states
   aStates  := FW_DbfToArray()
   close states

   EDITVARS cName, cCity, cState, lMarried, nAge, nSalary, cNotes ;
    PROMPTS "Name", "City", "State", "Married", "Age", "Salary", "Notes" ;
   PICTURES nil, nil, aStates, nil, "99", nil, 'M' ;
     VALIDS nil, nil, nil, nil, { || nAge >= 20 }, { || nSalary >= 10000 }

   ? cName, cCity, cState, lMarried, nAge, nSalary, cNotes
 


Image

In this dialog, we have checkbox for logical values, memo edit for memos, DbCombo for State, Valid check for Age and Salary, etc.

Finally, if we are not happy with the bitmaps used by default, we can modify the bitmaps with our own globally (or till next change)

What if we have more variables than the screen can accommodate? No problem. The dialog Scrolls.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FWH 14.08: MsgGet() to handle arrays and Quick Dialogs

Postby nageswaragunupudi » Sat Sep 06, 2014 7:25 am

Incidentally MsgGet() uses TDataRow() class default Edit Dialog.

Let us see how simple it is to use TDataRow() with Data.
Simple sample that reduces a lot of coding
Code: Select all  Expand view

   USE CUSTOMER NEW ALIAS CUST SHARED VIA "DBFCDX"
   TDataRow():New():Edit()
 

Result of these two lines of code:
Image

This dialog box provides complete navigation, refresh, undo and save actions.
Adequate for maintenance of a dbf.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FWH 14.08: MsgGet() to handle arrays and Quick Dialogs

Postby Carles » Sat Sep 06, 2014 9:58 am

Nages

Great !!!

Quickly & easy


Thank you
Salutacions, saludos, regards

"...programar es fácil, hacer programas es difícil..."

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
Skype -> https://join.skype.com/cnzQg3Kr1dnk
User avatar
Carles
 
Posts: 1134
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona

Re: FWH 14.08: MsgGet() to handle arrays and Quick Dialogs

Postby joseluisysturiz » Sat Sep 06, 2014 1:55 pm

Excelente, evitar hechar algo de codigo, buenisimo para esos dialogos cortos, muchas gracias...saludos... :shock:
Dios no está muerto...

Gracias a mi Dios ante todo!
User avatar
joseluisysturiz
 
Posts: 2064
Joined: Fri Jan 06, 2006 9:28 pm
Location: Guatire - Caracas - Venezuela

Re: FWH 14.08: MsgGet() to handle arrays and Quick Dialogs

Postby joseluisysturiz » Sat Sep 06, 2014 1:57 pm

nageswaragunupudi wrote:Incidentally MsgGet() uses TDataRow() class default Edit Dialog.

Let us see how simple it is to use TDataRow() with Data.
Simple sample that reduces a lot of coding
Code: Select all  Expand view

   USE CUSTOMER NEW ALIAS CUST SHARED VIA "DBFCDX"
   TDataRow():New():Edit()
 

Result of these two lines of code:
Image

This dialog box provides complete navigation, refresh, undo and save actions.
Adequate for maintenance of a dbf.

Como se haria en MySql, por lo menos con la Dolphin.? saludos... :shock:
Dios no está muerto...

Gracias a mi Dios ante todo!
User avatar
joseluisysturiz
 
Posts: 2064
Joined: Fri Jan 06, 2006 9:28 pm
Location: Guatire - Caracas - Venezuela

Re: FWH 14.08: MsgGet() to handle arrays and Quick Dialogs

Postby lucasdebeltran » Wed Oct 22, 2014 7:43 am

Hello,

Can we also indicate ACTION for the Gets and the BITMAP for that button, such as:

REDEFINE GET cDIRECCION ID 100 OF oDlg;
ACTION( _VerLoc( cDireccion ) ) ;
BITMAP "MNUMAPA"

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: FWH 14.08: MsgGet() to handle arrays and Quick Dialogs

Postby Enrrique Vertiz » Tue May 15, 2018 6:59 am

Greetings Mr. Rao

Lines above shows how to do the Edit of "all fields of a table", but if I just wanted to edit 2 or 3, NOT all, what would be the command.

This is for all :
USE CUSTOMER NEW ALIAS CUST SHARED VIA "DBFCDX"
TDataRow():New():Edit()

I need only edit two or tree colums

Thank you very much
Enrrique Vertiz Pitta
Lima-Peru
xHb 1.23.1026X, Fwh 24.09, BCC74, MySQL 8.0.X, SQLLIB 1.9m
Enrrique Vertiz
 
Posts: 541
Joined: Fri Oct 07, 2005 2:17 pm
Location: Lima - Peru

Re: FWH 14.08: MsgGet() to handle arrays and Quick Dialogs

Postby nageswaragunupudi » Tue May 15, 2018 8:31 am

TDataRow():New( "CUST", "FIRST,CITY,SALARY" ):Edit()
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FWH 14.08: MsgGet() to handle arrays and Quick Dialogs

Postby Enrrique Vertiz » Fri May 18, 2018 4:08 pm

Thank you very much
Enrrique Vertiz Pitta
Lima-Peru
xHb 1.23.1026X, Fwh 24.09, BCC74, MySQL 8.0.X, SQLLIB 1.9m
Enrrique Vertiz
 
Posts: 541
Joined: Fri Oct 07, 2005 2:17 pm
Location: Lima - Peru

Re: FWH 14.08: MsgGet() to handle arrays and Quick Dialogs

Postby joseluisysturiz » Tue May 22, 2018 4:12 pm

Saludos, he probado con un solo campo, en mi caso usandola para buscar un registro...pero solo acepta la entrada de datos usando el boton CHECK, si le doy ENTER en el GET, es como si hubiese cancelado, saludos...gracias... :shock:
Dios no está muerto...

Gracias a mi Dios ante todo!
User avatar
joseluisysturiz
 
Posts: 2064
Joined: Fri Jan 06, 2006 9:28 pm
Location: Guatire - Caracas - Venezuela


Return to FiveWin for Harbour/xHarbour

Who is online

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