Simplicty and flexibility!


Function::Memo

MemoReplace
MemoReplace(MemoToReplaceIn,StringToReplace,StringToReplaceWith)
MemoReplace(MyMemo,"[{custoner}]","DataEase International Ltd")
MemoReplace(MyMemo,MyReplaceField,ReplaceWithField)
retval := MemoReplace(MemoToManipulate,"Test","OK") .

Memo and String is


To replace all occurrences of a string in a Memo with another string.

Can be used to populate a template with the content of a table etc.

Parameters


MemoToManipulate:

This is the Memo Column name that is to be manipulated. After the manipulation the value in the Record will have changed.


StringToReplace:

String to Replace in the Memo. You can ex. use a Tag like [{customername}] and later replace it with a real customer name.


StringToReplaceWith:

The new value you want to replace the one you searched for.

Returns/Result


integer : number of occurrences replaced. 0=Not found.

Examples


Example 1. (Found in ExecDQLStore in CRM sample)
DQLNr 301 - Generate Labels Avery1

define temp "Telle" number .

define temp "tRow" number .

define temp "tColumn" number .

define temp "tTemporaryID" text .

define temp "retval" text .

define temp "tMCopy" number .

tMCopy := 1 . -- The switch that tell the MemoMemoCopy to Overwrite or append a page. First page is Overwrite, rest is append.

tColumn := 1 . -- Column number in array

tRow := 1 . -- Row number in array.

for Customers with CustomerNR <= data-entry field1 ; -- Here you set the selection criteria for the labels. Lazy so just use CustomerNr < but you can use anything.

if tColumn > 3 then --end of row x, ka-ching new line. Here you can read the 3 as a variable from the Template system instead if you want to make it generic.

tColumn := 1 .

tRow := tRow+1 .

if tRow>6 then -- this is hardcode because we are lazy, you can of course look this up from your template form together with the template.

tRow := 1 .

Telle:=0 .

tMCopy := 0 . -- now 0 because we want to append another page.

end

end

modify records in Temporary with TemporaryID = "Avery1" -- we use a pre-existing page because you can't insert and modify a page in the same DQL. Lazy again.

Dummy := if(telle=0, concat(MemoMemoCopy(Body, any Templates with TemplateID ="TL0002" Body ,tMCopy),"") ,"") ; -- here we insert the first page, and append the successive.

Dummy := MemoReplace(Body ,concat("[{CustomerName",tRow,tColumn,"}]"), Customers CustomerName ) ; -- here we dynamically replace the tags in the matrix

Dummy := MemoReplace(Body ,concat("[{Address",tRow,tColumn,"}]"),Customers Address ) ;

Dummy := MemoReplace(Body ,concat("[{Contact",tRow,tColumn,"}]"),Customers Contact ) ;

Dummy := MemoReplace(Body ,concat("[{Town",tRow,tColumn,"}]"),Customers Town ) ;

Dummy := MemoReplace(Body ,concat("[{PostCode",tRow,tColumn,"}]"),Customers PostCode ) ;

Dummy := MemoReplace(Body ,concat("[{Country",tRow,tColumn,"}]"),Customers Country ) .

tColumn := tColumn + 1 . -- counting up the columns

telle := telle + 1 . -- lazy again, it never need to be more than 1 to make the trigger mechanise safe.

end

retval := SetLabelText("Status",concat("Generate Labels finished. ",data-entry field1, " labels generated.")) .

retval := SetVar("TempFilter","Avery1")+DocumentOpen("Temporary") .

Reference

MemoReplace

Type

Memo Function

Purpose

Replaces all occurences of search in a memo with new value. This is possibly one of the most influetial new functions in DataEase 8. This is the function you will use to replace tags in Memos to create letters, emails, webpages etc.

Syntax

MemoReplace(MemoToReplaceIn,Search,NewValue)

? where MemoToReplaceIn is the result Memo, Search is the value to be replaced and NewValue is the value that will substitute.


Returns

An empty string so the function can be used as part of any derrivation without interfering with the derivation result.

Example

Memo1 contains: "bla bla this is a test etc etc Companyname: [{company}] bla bla bla"
MemoReplace(Memo1,"[{company}]","4ThePeople Limited")

? will reuslt with the Memo1 containing : "bla bla this is a test etc etc Companyname: 4ThePeople Limited bla bla bla"


Complimentary Functions

MemoCopy() - same function but copies, inserts or overwrite a Memo with a normal DataEase field or constant.
WriteToFile() - Function that will perform the same functionality, but write to a file instead of a Memo.
Chr() - Function that returns the ASCII character for a number, you will need this to insert " or NewLine into a Memo.
MemoWriteToFile() - Same as WriteToFile() but writes, inserts or appends a memo to a file.
MemoReadFromFile() - Reads a file into a memo.

See Also



MemoMemoReplace()

StringReplace()

On the forum about MemoReplace

[@EOF@]...

Product: . Written by alembagheri tahmas 07/12/13 at 13:37:32

Hi there,I am trying to use an external MySQL DB in dataease. I have successfully create the ODBC link and added the DB to dataease. I can also access the DB from dataease. Now, just for testing purposes, I am trying to create a simple report b...

Product: DataEase for Windows 7.x. Written by George Washington 11/04/14 at 08:26:17

no se pude exportar ahora archivos a pdf, ni a excel o otros cosa mala. en verdad creo que hace faltaen las versiones anteriores me funcionaba mas o menos bien.&nbsp;le hace falta a los aplicativos que se desarrollan en Dataeasegr...

Product: DataEase 8 Reporter. Written by eduardo paez 02/05/14 at 14:40:11

Thanks. Anyway I'm trying to use this fuction but it seems to me that it doesn't work on 8.2. I tried also in a DQL.There's something wrong?<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA9IAAAJ3CAYAAAB4NWk3AAAAAXNSR0IArs4...

Product: . Written by Marco Marchesi 15/02/16 at 14:50:46

[@EOF@]...

Product: Dataease [{8}]FIVE. Written by Chamil Rajindra 21/02/19 at 10:17:46

Thanks for the very good explanation!AS...

Product: . Written by afonso santos 28/10/19 at 00:50:14

I am pleased to see that the migration from Dos 4.53 is then sa 5.5 works. A really useful thing would be a compiler of SQL languages. Will you get there?Original Text:Mi compiaccio a vedere che la migrazione da Dos 4.53 รจ poi sa 5.5 funzio...

Product: . Written by Grossi Gioacchino 18/11/19 at 14:33:44

How can i delete a Style sheet?...

Product: Dataease [{8}]FIVE. Written by Rainer 22/03/21 at 11:13:10

I run W7 and since a few days&nbsp;Dataease 8.5 is not starting any more, do you have an idea? i installed it again but that did not help....

Product: Dataease [{8}]FIVE. Written by Rainer 08/06/21 at 14:12:40

[@EOF@]...

Product: . Written by Hiralal Rampul 01/12/21 at 17:47:10

On the blog about MemoReplace


dg3_HelpView