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.
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.
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") .
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.
MemoMemoReplace()
StringReplace()
Product: Dataease [{8}]FIVE. Written by Tor Nerland 12/11/14 at 09:42:53
Product: Dataease [{8}]FIVE. Written by DataEase 12/11/14 at 10:53:54
Product: Dataease [{8}]FIVE. Written by DataEase 05/10/11 at 12:19:30
Product: Dataease [{8}]FIVE. Written by DataEase 08/05/13 at 13:46:40