Simplicty and flexibility!


DataEase 8.5 - MemoCopy Error


Started by arulj@naitcs.com
Search
You will need to Sign In to be able to add or comment on the forum!

DataEase 8.5 - MemoCopy Error

;
I am getting a error message, see below. I am pulling my hair.

But, cant seem to figure out why;


Written by arulj@naitcs.com 05/05/18 at 10:30:39 Dataease [{8}]FIVE

How to use a DummyTable to manipulate Memos directly in DQL

Download Sample
I can see why you get the error.


RispSpecificINterventions is a table so you are not designating a Memo field.

it should be Dummy := memocopy (RiskSpecificInterventions myMemoOfSomeKindInThisTable,TdescTxtLabel,1) .

I’m not sure what you are trying to do here but it can seem that even with the fix above nothing really happens.

RiskSpecificInterventions is the outer table so with the line above you modify the memo in this table.

But nowhere do you write it back to the table.

The modify records you use here will modify dummy in PhysOrder485 but not update RiskSpecETc.

MemoCopy is a manipulation function so it works on the underlying Multiview so the Memo so I think you get it “almost” right.

you don’t need modify records where you use them.

To get this to work you need a memo object in the overall Multiview to store the memo value when you build it as you can’t manipulate it directly in the lowest level as it doesn’t exist there. In Modify records you need to allocate values.

Example.

define "retval" text .

define "switch" number .

for DummyTable ; -- This table is the out “storage” for memos, as we just need a memo in memory to manipulate and transfer back to our table in the end.

for MainData ; -- This is the table that will receive the completed Memo from DummyTable.

DummyTable DummyMemo := "" . -- Clearing the Memo so it is blank at the start .

switch := 1 . -- first add to memo without CR -- We use a toggle switch so the first line is added without CR and after that we append with CR.

For SomeData ; -- This is the table with the multiple records that need to be concatenated into the memo.

retval := MemoCopy(DummyTable DummyMemo,concat(Name, " "),switch) . – here we build the new memo in the temporary Dummy Memo in dummy table.

switch := 4 . – Set toggle switch to append with CR.

End – end of work loop

modify records – now we are ready to write to the memo

MyMemo := DummyTable DummyMemo .

End -- Maindata

End – Dummy Loop

retval := RefreshScreen() . – Refresh screen to see the result of manipulation.


Written by DataEase 05/05/18 at 10:47:02 Dataease [{8}]FIVE

Re:How to use a DummyTable to manipulate Memos directly in DQL

Memo manipulation was big news in DE8 as we had never been able to use this very useful new storage class for anything meaningful due to lack of ways to program manipulation of them.


However, as you have found out it is a particular knack to it which is not completely “DataEasy”.

This was due to limitations in PRISM etc. that had not been sorted by the previous team.

The good news in DE9 is that it has now been sorted.

you will now be able to do:

define “myTempMemo” memo .

For MyTable1 ;

For MySecondTable ;
MyTempMemo := concat(myTempMemo,MyTextString) .

End

Modify records
MyMemo := MyTempMemo .
end

This might look much more like “proper” DataEase …. ;-)


Written by DataEase 05/05/18 at 10:52:14 Dataease [{8}]FIVE

Re:Re:How to use a DummyTable to manipulate Memos directly in DQL

It was actually a programmer's mistake this time :-)

Now I fixed it by renaming the field name differently from the table name, it works.

After this, I have a new problem. When I use the switch 1 for the first entry and switch 4 for the second entry.
Last character is getting cut off for the first entry. Any ideas?


Written by Jeyarajah Arulrajah 10/05/18 at 01:36:25 Dataease [{8}]FIVE

Re:Re:Re:How to use a DummyTable to manipulate Memos directly in DQL

Download: 2018-05-10_11-48-21.jpg

Here is the screen shot.


Written by Jeyarajah Arulrajah 10/05/18 at 17:52:41 Dataease [{8}]FIVE

Re:Re:Re:Re:How to use a DummyTable to manipulate Memos directly in DQL

Hi Arul.


This is “old” bug. It has to do with blank characters and carriage return at end of line (DataEase has traditionally cleaned away these things).

The result here is that it steal the end of your MemoCopy(). It is fixed a long time ago but the fix is not part of 8.5.

The workaround is simply to concat(WhatYouWant,” “) and then MemoCopy steal the extra blank.

If you look closely in my sample you will see that I employ this hack there.

I was as "surprised" as you when I saw it as I haven't seen this for "ages" but then quickly realised that that is because we work in 8.6 and 9.0....


Written by DataEase 10/05/18 at 20:03:52 Dataease [{8}]FIVE

Re:Re:Re:Re:Re:How to use a DummyTable to manipulate Memos directly in DQL

Problem here is, what if text is longer than 255 characters.

Will concat work then?


Written by arulj@naitcs.com 11/05/18 at 10:17:39 Dataease [{8}]FIVE

Re:How to use a DummyTable to manipulate Memos directly in DQL

Hi Arul.

8.5 and below.

You can’t work with strings longer than 255 so it will never happen. You might have corner case with strings exactly 255 but to be honest that is very unlikely.

All functions in 8.5 and below will never return anything bigger than 255.

This is why we made the memo manipulation class in the first place so you could work with Memos inside this limitation.

8.6 and above.

Here we have removed the old 255 limit so all string functions can work with arguments and return up to 4GB.

so you can do

concat(Memo1,Memo,”Hellop”,String255,number) and it will return all of it as the concatenated value.

in 8.6 and above MemoCopy is already surplus to requirement as you can start doing things the way they should have been from the beginning.

Let say you want to achive the same i.e. concatenate with line change.

the DQL would look something like this.

define “returnvalue” memo .
define “switch” text .

Define “retval” text .
for MyTable ;
returnvalue := concat(returnvalue,switch,NewLineValue) .

Switch := “/CR” . – To now get new line for each new NewLineValue after first line.
end
retval := SetVar(“MyMemoInTheSky”,returnvalue) . – this so we transfer the result to be used anywhere.

Even cooler you don’t have to do either this if you are using ExecDQL…


in 8.6 onwards execdql will return the body as return value (all of it). So you can in principle build a DQL that run different DQL’s that return their body’s as text and then return all of them as a new body and that will be a document/web page or whatever.

DQL

for MyTable ;
list records
NewLineValue .


BODY

.items
[{NewLineValue}]
.end

theconcatenatedtextwithCR := ExecDQL(DQL,””,””,””,””,””,Body) .

You can use it directly in a field derivation to and get the result of the DQL as the value in the field (virtual field if you like).


Written by DataEase 11/05/18 at 10:24:55 Dataease [{8}]FIVE

Re:Re:How to use a DummyTable to manipulate Memos directly in DQL

Download: MemoCopyIssue.zip

I am little confused by this..

Are you saying it cannot be done in 8.5?

Please see a sample database attached showing my problem.

It has two tables and one procedure. UserID and password left blank.


Written by Jeyarajah Arulrajah 11/05/18 at 16:57:03 Dataease [{8}]FIVE

Re:Re:Re:How to use a DummyTable to manipulate Memos directly in DQL

Depends on what you try to achive.
No function in DataEase up to 8.6/9 is able to RETURN more than 255 characters.

concat() will whatever you try to concat never return more than 255.
MemoCopy(Memo,Something,switch) will never be able to copy anything bigger than 255 to a Memo.

you can however merge and copy/append between Memos with MemoMemoCopy() etc.

So what you try to do can definitely be done in 8.5

Before 8.5 there was no way you could do ANYTHING outside 255 which we changed with the Memo manipulation class.

In 8.6 onwards we have removed the boundary that made Memo manipulation class necessary in 8.x so from 9.x you will be able to work with strings of any size up to 4gb the same way you have worked with strings smaller than 255 in DataEase since 2.x


Written by DataEase 11/05/18 at 22:04:15 Dataease [{8}]FIVE