Implementing a memo field into a form

Topic Specific Tutorials and Tips.

Moderator: Rathinagiri

bluebird
Posts: 172
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF

Implementing a memo field into a form

Post by bluebird »

Dear HMG mentor

To implement a memo .dbt file into a form, must I use an EDITBOX as the control?

When I specify a field as type memo do I write for example "MyNotes,m " or is there more setup parameters like "MyNotes,m,10,5"

Finally, can I be directed to the best tutorial example.

Thanks
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Implementing a memo field into a form

Post by serge_girard »

Hi Bluebird,

I would recomment TEXTBOX for memo IF the textlen is limited to 1 line ELSE use EDITBOX. See SAMPLES TEXBOX and SAMPLES EDITBOX.

Regards, Serge
There's nothing you can do that can't be done...
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Implementing a memo field into a form

Post by Pablo César »

For Memo fields you will read field and assign a variable.
You don't use "MyNotes,m " (this comma) inside a string doesn't any thing.
For reading and assigning you make like this:

Code: Select all

cText:=hb_MemoRead("MyNotes") // supposed to be this name for memo field 
Then you define your EditBox in VALUE property with cText

I have a good reason in my experience to avoid MEMO fields into DBFs. Instead, I create individual text files stored into a special subfolder and each names of text files be compoused by any code from dbf's field . Example:

Code: Select all

cNum:=StrZero((dbf->Client_cod),8,0)
cFile:="Note_"+cNum+".txt"
cFolder:=cFilePath(GetProgramFileName())+"\Notes" // subfolder named Notes
hb_MemoWrit(cFolder+"\"+cFile,"Here's your text to be saved")
bluebird wrote: Thu Jan 19, 2017 6:30 am Finally, can I be directed to the best tutorial example.
Finally, my contribution to your questions only found at moment is to download Stru and locate for Function Stru_Process()
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
bluebird
Posts: 172
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF

Re: Implementing a memo field into a form

Post by bluebird »

Thank you all for the help

I downloaded the STRUcture utility and recorder the following line.
Please tell me what the last two entries in the structure of the memo field mean, i.e.. the 010 and the 000?
I threw away my Clipper manuals 20 years ago, which was a mistake because HMG renewed my interest.

+--------- PLINFO.DBF ----------+
| Nr Name Type Siz Dec |
+-------------------------------+
| 01 "CODE" ,"C",004,000 |
| 02 "NAME" ,"C",040,000 |
| 03 "TYPE" ,"C",040,000 |
| 04 "ACCOUNT" ,"C",040,000 |

| 05 "LOGONID" ,"C",015,000 |
| 06 "PASSWORD" ,"C",015,000 |
| 07 "URL" ,"C",030,000 |
| 08 "PHONE" ,"C",013,000 |
| 09 "EMAIL" ,"C",040,000 |
| 10 "NOTES" ,"M",010,000 | < My memo field **
+------ Total records 29 -------+
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Implementing a memo field into a form

Post by Pablo César »

bluebird wrote: Thu Jan 19, 2017 4:03 pm Please tell me what the last two entries in the structure of the memo field mean, i.e.. the 010 and the 000?
010 field size 000 is decimal field. Both are not stricted for fill up. Memo field accept text, string. Not need to define limit of size/decimal.
bluebird wrote: Thu Jan 19, 2017 4:03 pm I threw away my Clipper manuals 20 years ago, which was a mistake because HMG renewed my interest.
What's you mean is Harbour not HMG. Who's really treats DBF is Harbour. All you know in Clipper you reuse in Harbour 100%.

Graphical controls like as EditBox is with HMG.

Stru is not the best example to see Memo fields. Sorry, I was wrong indicated. I thought for EditBox treatment.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Anand
Posts: 595
Joined: Tue May 24, 2016 4:36 pm
DBs Used: DBF

Re: Implementing a memo field into a form

Post by Anand »

Hi bluebird,

"NOTES" ,"M",010,000 in the dbf structure list imples that the dbf file has a "Memo" field. The actual data text of the memo field is stored in a separate .DBT file (for Clipper). The memo field in the dbf stores the file pointer in the DBT file of the text.

When you assign the memo field to a variable, it gets the text from the DBT file.
xVar := file->MEMO1
Now xVar has the text value.

The length of the text which can be stored in the MEMO field is unlimited (i.e. DBT file) and is stored in chunk of 512 in Clipper.

If the corresponding DBT file is missing or deleted, then you can not open the DBF file. So you must ensure to copy DBF and DBT file for backup or sync etc. purpose.

Regards,

Anand
Regards,

Anand

Image
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Implementing a memo field into a form

Post by serge_girard »

Hi,

And I think that '10' in "NOTES" ,"M",010,000 in the dbf structure is ignored.

Code: Select all

	AADD(aDBF, { "M1", "M", 10, 0 })
	AADD(aDBF, { "M2", "M",  0, 0 })
	AADD(aDBF, { "M3", "M", 1 , 0 })
	AADD(aDBF, { "M4", "M", 100, 0 })


Gives all the same result... At least in my DBF viewer!
Serge
There's nothing you can do that can't be done...
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Re: Implementing a memo field into a form

Post by Pablo César »

serge_girard wrote:
Pablo César wrote: Thu Jan 19, 2017 5:14 pm 010 field size 000 is decimal field. Both are not stricted for fill up. Memo field accept text, string. Not need to define limit of size/decimal.
And I think that '10' in "NOTES" ,"M",010,000 in the dbf structure is ignored.
Yes, this info is correct, Serge.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
bluebird
Posts: 172
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF

Re: Implementing a memo field into a form

Post by bluebird »

Thanks for all replies.

Continuing with my Memo field problem

My application works except that I cannot save the memo composed in the EDITBOX control named T_Notes
The field name in my DBF is "Names,m".

Looking at the code that attempts to save PLInfo_>Notes, I get a context error only on those lines that contain T_Notes (see asterisks)

Do I have to save that field in a different way to other fields ?

The HMG examples do not seem to save memos. Do I have to use
the old Clipper MEMOEDIT commands. Its been 20 years since using it so I've forgotten how. :)

If lNew // is this a new record
PLInfo->(DBSetOrder(1))
PLInfo->(DBGoBottom())
WebCode := StrZero( Val( PLInfo->Code ) + 1 , 4 )
PLInfo->(DBAppend())
PLInfo->Code := WebCode
PLInfo->Name := Form_2.T_Name.Value
PLInfo->Type := Form_2.T_Type.Value
PLInfo->PassWord := Form_2.T_PassWord.Value //new PW is undisguised
PLInfo->LogOnID := Form_2.T_LogOnID.Value
PLInfo->Account := Form_2.T_Account.Value
PLInfo->URL := Form_2.T_URL.Value
PLInfo->Phone := Form_2.T_Phone.Value
PLInfo->EMail := Form_2.T_Email .Value
PLInfo->Notes := Form_Memo.T_Notes.Value **********************< Context Error
Else
cCode := Form_2.T_Code.Value
PLInfo->(DBSetOrder(1))
If ! PLInfo->(DBSeek( cCode ))
MsgSTOP("Registration "+cCode+" not located!!","PLInfo")
Release Window ALL
EndIf**********************< Context Error

If BlockRegistrationOnNetwork( "PLInfo" )
PLInfo->Name := Form_2.T_Name.Value
PLInfo->Type := Form_2.T_Type.Value
PLInfo->PassWord := PWDisguise(Form_2.T_PassWord.Value) //undo PW disguise
PLInfo->LogOnID := Form_2.T_LogOnID.Value
PLInfo->Account := Form_2.T_Account.Value
PLInfo->URL := Form_2.T_URL.Value
PLInfo->Phone := Form_2.T_Phone.Value
PLInfo->EMail := Form_2.T_Email.Value
PLInfo->Notes := Form_Memo.T_Notes.Value **********************< Context Error
PLInfo->(DBUnlock())
EndIf
EndIf
MsgInfo( "Information "+Iif( lNew , "Registered" ,"Altered!!" ) )
PosicionaIndice( Left( PLInfo->Name , 1 ) )
Research_PLInfo()
Form_2.Release
Return Nil
bluebird
Posts: 172
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF

Re: Implementing a memo field into a form

Post by bluebird »

Note to all responders on this subject.

I apologize if I have taken too much of your time. For some reason the code above now compiles error free. I do not know what I did
to make it work. Its a frustration to see an "context" error when the line of code agrees with the HMG description but still does not work.

Thanks to all
Post Reply