i need an example ..

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
rpiccioli
Posts: 17
Joined: Sun Dec 21, 2008 8:43 am
Location: Roma - Italy

i need an example ..

Post by rpiccioli »

Hiya to you all,

Having for example a DBF file called user.dbf with two fields: Name and Surname, i need an example about:

Adding a new record in the DBF, Locate a Record, Browse DB ...

Is there anywhere?

Thank you.
--
Riccardo Piccioli
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: i need an example ..

Post by mol »

Hello Riccardo!
There are a lot of examples in HMG\SAMPLES folder.
I'm sure, you will find something for you.

Searching for record, you can do creating button "Search" and then call InputBox (for example) to input search string (InputBox is for character variables). After seeking record, call YourBrowse.Refresh.

If you have troubles with definition of Browse, it's good way to use HMGIDE to define windows and browse - then you can watch your definition file .FMG

Best regards, Marek
rpiccioli
Posts: 17
Joined: Sun Dec 21, 2008 8:43 am
Location: Roma - Italy

Re: i need an example ..

Post by rpiccioli »

mol wrote:Hello Riccardo!
There are a lot of examples in HMG\SAMPLES folder.
I'm sure, you will find something for you.

Searching for record, you can do creating button "Search" and then call InputBox (for example) to input search string (InputBox is for character variables). After seeking record, call YourBrowse.Refresh.

If you have troubles with definition of Browse, it's good way to use HMGIDE to define windows and browse - then you can watch your definition file .FMG

Best regards, Marek
Hiya Marek.

I'm just trying to working a little bit in HMGIDE. I define on a new form the windows withe browse. I can i link a file DBF inside ?

I will connect again on january the 2nd since i left the work early today. So I wish you (and to all the users of this forum) an Happy new Year!
--
Riccardo Piccioli
User avatar
dhaine_adp
Posts: 457
Joined: Wed Aug 06, 2008 12:22 pm
Location: Manila, Philippines

Re: i need an example ..

Post by dhaine_adp »

Hi Ricardo,

If you can see my posting regarding my problem with browse heading that turn's into bold font, it has a source code in it.

1. Download the program, then replace my database with your database
2. Comment out or delete the Beneficiary browse and what's left with you is the BROWSE brwMaster.
3. Now, there is a textbox control with name txbQFind. There on that line, put an action in ON CHANGE.
4. The action should be for table searching, your index must be prepared and open the table by surname (in my case, as you can see is I LastName).

Perhaps you already figure out what I meant, add another static function like this:

*****************************
static function QFindOnChangeAction()

LOCAL cLastFile := ALIAS()
LOCAL cFindThis := ALLTRIM( frmGUI_2.txbQFind.Value )
LOCAL nThisRecPos := YOURALIAS->( RECNO() )

DBSELECTAREA( "YOURALIAS")
DBSEEK( cFindThis )
IF EOF()
YOURALIAS->( DBGOTO( cThisRecPos ) )
ENDIF
frmGUI_2.brwMaster.Value := YOURALIAS->( RECNO() )
frmGUI_2.brwMaster.Refresh
frmGUI_2.brwMaster.Setfocus
RETURN NIL


So what happen is every time you typed something in the textbox, it will do an incremental search. Pressing backspace will let you go back to the previous record that match or to next higher index key if it not found. It will do a relative seek. See also SOFTSEEK and EXACT.

Regarding adding and saving record, I use to define another window, which is attached to New Button. Of course it has button save and button close also.

During edit I disbable the key field or make the textbox as readonly so the user could not change the key fields. That means and Employee ID or badge number, depending on the key field.

If you are in a hurry the BROWSE CONTROL OBJECT would let you edit INPLACE. See the manual that comes with HMG distribution with regards to that.

TO CLEAR the txbQFind you have create another ACTION in the textbox called ON ENTER like the example below:


****************************
static function QFindOnEnterAction()

LOCAL nThisRec := YOURALIAS->( RECNO() ) // save the current record number highlighted by the browse cursor

frmGUI_2.txbQFind.Value := "" // here, truncate the value of the textbox and of course ON CHANGE ACTION
// would be executed because it was an event attached to the textbox
// however the user wont see that because,

YOURALIAS->( DBGOTO( nThisRec ) ) // you have saved the records position before QFindOnChangeAction()
// get executed, and by now we are going to put it back to where
// the record is located originally

*************************************************************************************
** now doing a refresh on the browse would position the record pointer and browse cursor to the place that it
** should supposed to be with. SET BROWSE SYNCH must be ON, in your program.
*************************************************************************************
frmGUI_2.brwMaster.Value := YOURALIAS->( RECNO() )
frmGUI_2.brwMaster.Refresh
frmGUI_2.brwMaster.Setfocus


For me, I used to code my program for network environment whether the program would be ran on an stand alone machine. Most of the time, users goes for lan environment so I save myself a trouble of modifying the codes.


Happy New Year (and to everyone),

Danny
Regards,

Danny
Manila, Philippines
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: i need an example ..

Post by esgici »

Hello Danny

Thanks a lot.

This is (very) advanced Browse sample.

Regards

--

esgici
Viva INTERNATIONAL HMG :D
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: i need an example ..

Post by mol »

rpiccioli wrote:
mol wrote: I'm just trying to working a little bit in HMGIDE. I define on a new form the windows withe browse. I can i link a file DBF inside ?

I will connect again on january the 2nd since i left the work early today. So I wish you (and to all the users of this forum) an Happy new Year!
While defining your browse, you can set WORKAREA property - simply set it to alias of your database.
(Your database must be opened before loading window...)

Remember to define FIELDS property - it is a table with name of fields from your database, you can also browse fields from related database (eq rel_dbf->fields_A). Other properties like HEADERS, WIDTHS, JUSTIFY are optional - you can defined them later,

I wish you Happy New Year too!

Marek
Post Reply