DataEase 8.2 - Encoding for prohibited characters implemented in all String Functions (Ver. 184.108.40.2060)
It has always been "Impossible" to include prohibited characters in DE derivation/scripts. Characters like New Line (CR), Tab and " (Quote) which are very useful to get in there, has been very difficult to shoehorn in.
When I first started on DE development in "Modern times" my workaround was to create a global form where I saved a record with QUOTE, NEWLINE (but not tab, that was one to far). Quote was relatively simple, I only needed to save " in a field with one character and then define a relationship between the table where I wanted to use it and the Global Settings table with no restraint (i.e. it will always look up the first record).
New Line was a little harder, as DataEase notriously remove leading blanks, trailing blanks and trailing CR (new lines etc). My work around was to save .CR. and then use Midc(lookup Global Settings NewLine, 2,1)... It worked but not particularly straight forward, nor user friendly.
Every time I do and did something like this it make me believe that I am most likely the only person in the world that take advantage of this particular feature....and that can't be good when you sell a global software!
The first fix we did was CHR(), with this function you can concatenate any ASCII value together with any string so if you wanted Quotes, you simply did: Concat(chr(34),"My text",chr(34)) and you would get "MyText"...
To get new line you simply added CHR(10)+Chr(13).
Much better, especially if you only wanted to do this in a limited fashion.
With funcitons like MemoCopy and WriteToFile etc we made switches that added preceding and succeeding new lines etc.
With the introduction of the ExecDQL library the problem with "" etc fully hit us. In DQLs "" is used extensively as part of the syntax so even the simplest DQL became "impossible" to execute directly from the derivation.
imagine the following simple DQL.
define "myvar" text.
myvar := "My Text" .
Message concat("My answer: ", Myvar) window .
to execute this DQL directly with ExecDQL() you would have to write he following Derivation.
ExecDQL(concat("define ", chr(34),"myvar",chr(34)," text . myvar := ", chr(34),"My Text",". Message concat(",chr(34),"My Answer:",chr(34),"Myvar ) window ."),"","","","","")
Hopefully this is right (I haven't tested it) but you can see from this "derivation" that this is two hard to be used for anything meaningful. When you take into consideration that no parameter in any DataEase function can be longer than 255 characters you realise that this won't work....
To compensate for this the ExecDQL() library has many implementations like MemoExecDQL() that execute the DQL stored in a Memo, FileExecDQL() that run the DQL stored in a Text file, LabelExecDQL() that run the DQL written directly into a label in the form etc...
However, it would be nice to write the smaller ones directly into the function....
This is why we have now implemented StringEscape() functionaltiy in all String Functions (it should have been done ages ago).
Simply use the encoded version of the character and they will be replaced in the function with the real thing.
/' = "
/n = CR (New line)
/t = Tab
So our ExecDQL() will now look like this:
ExecDQL("define /'myvar/' text . myvar := /'My Tex/' . Message Concat(/'My answer: /',Myvar) window .
Suddenly this is doable after all.
Another obvious place is another "new" function that we have published today: SelectionFilter(). This is a completely unknown function in DFW, but when discovered and used properly one of the most useful... Only problem is that it is completely comprehensible and prior to DE8 not even usable.
Read the BLOG post about this function to figure out why.