Tim,
The answer is yes.
A few years ago before I joined 4Js, I wrote such a routine so that every DISPLAY ARRAY and every INPUT ARRAY had a 'Copy Entire Table to Clipboard' function that copied the array as the user saw it (i.e respected sort order, hidden columns, columns moved around).
The technique I used went something like this...
1. Replace END DISPLAY and END INPUT in the code with END_DISPLAY(array_variable) and END_INPUT_ARRAY(array_variable)
2. Define a pre-processor command like so ...
&define END_DISPLAY_ARRAY(p1) ON ACTION copy_entire_table_to_clipboard(base.TypeInfo.create(p1)) END DISPLAY
&define END_INPUT_ARRAY(p1) ON ACTION copy_entire_table_to_clipboard(base.TypeInfo.create(p1)) END INPUT
3. Create a function
FUNCTION copy_entire_table_to_clipboard(om)
DEFINE om.DomNode
4. Inside this function, what you have to do is build up the string buffer like in Sebs example but instead of having to refer to explicit column names, traverse the serialized version of the array variable aka the DomNode. If you ignore sorting, hidden columns etc, this is something like
DEFINE row, column om.DOmNode
DEFINE rowList, columnList om.NodeList
DEFINE sb base.StringBuffer
LET sb = base.StringBuffer.create()
LET rowlist = om.SelectByTagName("Record")
FOR i = 1 TO rowlist.getLength()
LET row = rowlist.item(i)
LET columnlist = row.SelectByTagName("Field")
FOR j = 1 TO columnlist.getLength()
LET column = columnlist.item(j)
CALL sb.append(column.getAttribute("value"))
CALL sb.append(ASCII(9))
END FOR
CALL sb.append(ASCII(10))
END FOR
CALL ui.Interface.FrontCall("standard","cbset",[sb.toString()]
5. Once you have that stage working then gradually add in the ability to cope with these things...
i) handle the case where the value you are copying has a TAB or CR character, you want to delimit or quote or do something to these values
ii) the user has sorted the array, the sortColumn and sortType are in the ui.Interface root node. If there are ties, the tie-break rule is to use the index of the array
iii) the user has hidden the column, the hidden attribute of the column in the AUI tree will have value 1 or 2
iv) the user has moved the columns around, from memory look at the tabIndex attribute of the column in the AUI tree.
v) add column headers which are again available in the AUI tree
vi) maybe add an interrupt flag to cope with very large arrays.
What I never figured out was a way to cope with the case where two or more columns had the same tab index value. This was never a problem for me as our code standard was not to use TAB INDEX.
Also with combo-boxes the value will be the raw value, not the display value, you may want to interrogate the AUI tree to get the display value not the raw value.
Hope that helps, feel free to ask any questions and I'll see what I can remember, or I may have to ask my former colleagues to help fill in the gaps.
As Seb said, this topic is under consideration for inclusion in 2.20. If anyone else wants this functionality then let us know. The more that ask for a feature, the more it is likely to be included.
Reuben