New Sample - Labels... do I need to say more? (Ver 8.0.0.1301)
DataEase 8 is all about tearing down walls and remove boundaries.
One almost insurmountable problem seem to be labels. Something that was so simple in DFD has been almost impossible in DFW.
If you managed to fit the labels on Page 1 they would miss on page two. They would print differently on different printers. You would get unwanted lines and borders...
Anyway. It might not be so much used anymore, but it is a good way to show off some of the new functionality in 8 so we had a go.
This application use ExecDQL(),PrintMemo(), MemoMemoCopy(), MemoReplace() and a lot of other neat 8 functions to achieve the goal.
Remember, this is a sample but feel free to "steal" it and make it your own, but remember that we do a lot of stuff in one place just to show off the functionality so you might want to use the functionality a little more "sparingly" and spread out ;-)
SetLabelText("From",concat("From customer (",CustomerName,"):"))+SetValue("From Customer", CustomerNr)+SetFocus("From Customer")This is the "function" on the button. It changes the label in front of the From Customer field, it sets the value in the field and it gives the field focus.
Forget about the "old style" DQL, everything in 8 is about ExecDQL and the same here. To do the generation of the DQL we simply load a virtual memo with the DQL we want to use and execute it on like this
MemoExecDQL(DQL,From Customer ,To Customer ,"","","")The DQL itself looks like this:
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 between data-entry field1 to data-entry field2; -- 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("[{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 := SetGlobal("TempFilter","Avery1")+DocumentOpen("Temporary") .
Re:New Sample - Labels... do I need to say more? (Ver 8.0.0.1301)
Update 06.06.13
We have now included some more cool functionality for you to rip off ;-)
ExecDQL(concat("define temp ",chr(34),"retval",chr(34)," text. Modify records in customers with Selected=Yes Selected:=blank. retval :=SetValue(",chr(34),"Search",chr(34),",",chr(34),"A",chr(34),")."),"","","","","")
And you only have a limited space there, so we had to revert to our favoured MemoExecDQL and load the DQL from our DQLStore.
Only problem with that method is that we need to either have a fresh relationship or take advantage if to existing one.
The existing one was originally hardcoded to: 303 (which is the DQLNr in our ExecDQLStore form) but then it was changed to
if (Only Print Selected Customers =yes, 304,303)
After we introduces the Selected feature. For that we used a checkbox which is a field/column and will trigger the virtual field to re-derive, but what about if I want this to be triggered from a button?
Simply take advantage of some of the new beauties of DataEase 8. SetValue(), Wait() and of course MemoExecDQL() in full harmony ;-)
SetValue("DQLNr","305")+Wait(0.1)+MemoExecDQL(DQL,"","","","","")
This is the action on the button, and it is almost too good to be true. The field DQLNr is virtual and derrived, but still we can "force" its hand with SetValue().
SetValue() then trigger DQL which is a virtual Memo field with derivation.
lookup "ExecDQLStore" "DQL"
define temp "retval" number .
modify records in customers with Selected = yes
Selected := blank .
retval := FormClear() .
You will find the download link to the updated sample on the top of the main article.