Page 3 of 3

Re: Variables and Definition Errors

Posted: Mon Apr 02, 2018 10:48 am
by dragancesu
The clipper has the command SAY, GET and READ, SAY displays, GET loads, READ stops the program for some action

In the HMG program you do not SAY, GET, READ but have a TEXTBOX instead of SAY / GET, or what do you do when the value is entered? What are READ instead?
@ <nRow>, <nCol>
TEXTBOX <ControlName>
[ OF | PARENT <ParentWindowName> ]
[ HEIGHT <nHeight> ]
[ WIDTH <nWidth> ]
[ FIELD <FieldName> ]
[ VALUE <cValue> ]
[ READONLY ]
[ FONT <cFontName> SIZE <nFontSize> ]
[ BOLD ] [ ITALIC ] [ UNDERLINE ] [ STRIKEOUT ]
[ TOOLTIP <ToolTipText> ]
[ BACKCOLOR <aBackColor> ]
[ FONTCOLOR <aFontColor> ]
[ DISABLEDBACKCOLOR <aDisabledBackColor> ]
[ DISABLEDFONTCOLOR <aDisabledFontColor> ]
[ MAXLENGTH <nInputLength> ]
[ UPPERCASE ]
[ LOWERCASE ]
[ NUMERIC ]
[ PASSWORD ]
[ ON CHANGE <OnChangeProcedure> ]
[ ON GOTFOCUS <OnGotFocusProcedure> ]
[ ON LOSTFOCUS <OnLostFocusProcedure> ]
[ ON ENTER <OnEnterProcedure> ]
[ RIGHTALIGN ]
[ INVISIBLE ]
[ NOTABSTOP ]
[ HELPID <nHelpId> ]
Look attention to ON clauses and you see that you have CHANGE, GOTFOCUS, LOSTFOCUS and ENTER and make the functions you need when entering the field

You can use everything to control input, but put ON LOSTFOCUS in the last field and write the function that will save the data there, so easy, isn't it?

Re: Variables and Definition Errors

Posted: Mon Apr 02, 2018 10:49 am
by ROBROS
asharpham wrote: Mon Apr 02, 2018 8:36 am Going back to the DATA_BOUND example, the line "Win_1.Add1.Refresh" where Win_1 is the Window name and "Add1" is the Textbox name (I've changed them for my purposes), am I correct in saying that "refresh" refreshes the value of the textbox? In each case the textbox refers to a database FIELD but I presume it doesn't save to the database at this point as these statements are followed by a series of .save statements.

So what are the "refresh" statements refreshing? And are the "save" statements saving to the database or do I still need to use "dbCommit()"?

Alan you say it correctly, by refresh method the value of textbox is refreshed, writing to dbf is done by save.

A problem I am having with my edited version of DATA_BOUND which I've saved as "TestLib.prg" is that I want to include the ability to add new records. In doing this, I want to refresh the screen with mostly empty textboxes but keeping 2 of them the same as the last entry. This seems to work but when I mouse over the textboxes they revert to the previous (or top) entry. I have no "mouseover" commands anywhere in my code so I'm not sure why this is happening.

In dBase you could assign a set carry to (fieldnames), I have not found a corresponding command for harbour, maybe so else can help.

I'm uploading the TestLib file and including my database and index files so it can be run. I'm getting there but still need some direction and I appreciate all the help being given.

Regards,
Alan

Re: Variables and Definition Errors

Posted: Mon Apr 02, 2018 2:59 pm
by asharpham
It's getting very late and I'm no longer thinking well and I'll have to go over the post by ROBROS tomorrow.

But a quick question; I want to display the record number of the first record in my TESTLIB file). It's fine when the program is first loaded. But I can't seem to get onto the correct code for redisplaying the record number when I click "Next" or "Bottom" or any other navigation around the database. It just stays as "1".

To redisplay it I've tried to "refresh" the value of the LABEL that displayed in the first place but I get the error that "the LABEL has already been defined". How do you release a LABEL? Or am I totally on the wrong track? I don't want to use TEXTBOX here because it's not a user entered value. Is LABEL in fact the right way to display this FIELD?

Alan

Re: Variables and Definition Errors

Posted: Mon Apr 02, 2018 5:09 pm
by ROBROS
Hi,

the type of value in a label must be character, maybe this causes the error.
I assume the value of record number is numeric.

The runtime errors of hmg are sometimes very puzzling :roll:

But, I am quite a newbie too.

Robert

Re: Variables and Definition Errors

Posted: Mon Apr 02, 2018 5:58 pm
by serge_girard
Alan,

You can use a TEXTBOX with READONLY attr.
For the "the LABEL has already been defined" I use this:

Code: Select all

IF IsControlDefined ('ART' , 'Form_1' )  
   DoMethod ('Form_1' , 'ART' , 'Release' )   
ENDIF
// now define it safely !
Serge