To "decompile" or "unwind" a Memo field into 256 long chunks that can be handled by ordinary DataEase functions and saved in Text fields.
Pre DataEase 8 there was no way one could manipulate of use the content of Memo fields. The only way one could add to the was by manually keying in the content and the only way one could exploit the content was via reading it on screen.
In 8 Memo fields are one of the most important field types and visual controls.
We have added a entirely new class of functions simply to manipulate, populate and extract data from memo fields.
MemoChunk() is a function that will simply retrieve a 256 bytes large chunk from a Memo field and return it as a normal text string(256).
The usage of MemoChunk() can be for saving the content of a Virtual Memo Control into normal text fields for indexing, searching etc.
!Hint to legacy DataEase users!
If you have problems with your old style Memo fields being migrated to new style from 6.5x to 7.x you can use this function to unwind your data back into a Fields structure like the old style Memos. You can also use the New Style memo for editing and then unwind it back into a standard field structure.
26.06.17
Updated in 8.6 to contain options "line" and "word".
When these options are used it will return the line indicated by number or word indicated by number.
Returns [@EOF@] when you have come to the end of the memo.
23.04.18
Updated in 9.0 to include string from and string to.
When this option is used it will return the N occurrence of the string you search for in the text. Same as StringBetween but it will fin all occurrences and return the one you have asked for.
MEMO FIELD
This is the memo field you want to unwind into manageable chunks.
NUMERIC VALUE
This is the number of the 256 byte large chunk you want to retrieve. The first one is 0 and the second one is 1 etc.
Example 1
To make it easy for the example create we say we have a memo that contain a ledger where each entry is exactly 256 characters long ;-)
Each entry start with the number of the entry and then it continues with the name of the person etc.
First entry is 1. Andy MacNicol, born...Entry 40 starts with 40. Peter Cool born... and entry 1143 starts with 1143. Albin Youn born...
MemoChunk(MyMemo,0)
Returns: 1. Andy MacNicol born.... etc for 256 characters.
MemoChunk(MyMemo,39)
Returns: 40. Peter Cool born.... etc...
MemoChunk(MyMemo,1142)
Returns: 1143. Albin Youn born....
(I think you got it now)
Example 2
In this example we see a memo field with a HTMLEdit field control. When the record is saved the content of the memo is split into 4 Text fields by each of the calling.
MemoChunk(MyMemo,0) through MemoChunk(MyMemo,3).
We have now looked at a lot of functions that manipulate,extend, copy and append to a Memo field.
What about "normalising" it again. A lot of you traditionalist, don't and never will trust a memo field, and anyhow, even us "extremists" can't use traditional DataEase functions on a Memo field.
Maybe there is times we want to unwind a Memo field and save it in a normal DataEase table structure. It is not such a big defeat, we can simply rebuild it if we like with the MemoMemoCopy Function etc.
Enter MemoChunk().
string(256) MemoChunk(MemoToChunk,Chunk#)
Chunk# is proper Data techy, 0 is the first, 1 is the second, 2 is the third and on we go...Why make it easy?
MemoChunk(MemoToChunk,0) will return the first 256 bytes of the memo field , and MemoChunk(MemoToChunk,1) the next 256 and so we go.
So how do I know when I have reached the end of the Memo?
Firstly this is proper DataEase functionality, it will not GPF even though you try to take a chunk that doesn't exist, so don't worry. It will simply return nothing, like a good little boy, and this is how you can tell that you have come to the end...
When MemoChunk(MemoToChunk,N) returns blank, it is all over.
Enjoy!
MemoCopy
MemoDecodePair
MemoLength
MemoReplace
MemoReadFromFile
Product: Dataease [{8}]FIVE. Written by DataEase 07/10/11 at 12:11:29