Progress Programming Tips
By Rod Gaither (rdg@worldinfo.com)
PPT-6 Using the clipboard with streams
Tip:
An interesting feature I stumbled into recently was that the
clipboard can be the source/target for a stream. I found this
feature while looking for an elegant way to save a variable
list of fields. As an example consider the typical usage of
preprocessors in the UIB to create a list of enabled fields.
If I wanted to save the data in those fields, perhaps for
storage in a general table I could do the following -
---- Code insert begins ----
&SCOPED-DEFINED Search-Fields Name Abbrv Phone
DEFINE STREAM s-clip.
DEF VAR t-data AS CHAR NO-UNDO.
OUTPUT STREAM s-clip TO "clipboard".
/***[ Values have been entered into search fields ]***/
EXPORT STREAM s-clip {&Search-Fields}.
OUTPUT STREAM s-clip CLOSE.
ASSIGN t-data = CLIPBOARD:VALUE.
/***[ t-data could now be saved as a single field ]***/
---- code insert ends ----
The above technique has some limitations in that the clipboard
has a size limit and the clipboard is not a safe place if your
usage is not atomic enough - since other applications have access to
it... :-) Warning - I have not tested this to determine the true
feasibility of the approach.
If it worked as desired it gives you a little flexibility in
responding to variations in field lists and assignments. It is
not as dynamic as one would like but it does allow for templates
to be created that the UIB can help manage. In our custom viewers we
use the extra preprocessor lists to identify which fields are to be
used for filter and search. The underlying procedures could now save
and restore the search criteria to our generic criteria table without
code modifications should we decide to toggle a different set of
fields on or off.
To reverse the above process just assign t-data into the
clipboard and do an import rather than an export.
Overall this feature is neat but probably not very useful.
Wisdom:
Don't be afraid of getting it wrong the first time, unless of
course you won't get a second chance.
Rod Gaither | rdg@worldinfo.com
World Information Systems | (910) 333-2580 Voice
Greensboro, NC | (910) 333-2584 Fax