Purpose Scroll through a table. On a screen with one or more table controls we want to read all lines of one of the tables, not just its visible part. |
Solution The InputScript "table_to_file" (below) downloads a table from screen to a file, scrolling through all lines. It also demonstrates how InputScripts can be written in a quite general manner. You can use it in a screen of your choice, specifying the table name and up to 5 column names as "using" parameters. Add more column names if needed, or your own logic for selecting a subset of the lines.
Example
GuiXT Script // add a button that downloads the order items to Excel size=(1,2) process="table_to_file.txt" using tabname = "All items" using fid1 = "Material" using fid2 = "Order quantity" using fid3 = "UN" using fid4 = "Description" using fid5 = "Net value"
// General script for table viewing / download // using fid1 = "Material" // using fid2 = "Order quantity" // using fid3 = "UN" // using fid4 = "Description" // using fid5 = "Net value" Parameter
filename
"&%[TEMP]\guixttemp.&V[today_ymdhms].csv" OpenFile "&U[filename]" -output -utf8 delimiter=";" // Variables Set V[relrow] 1 // Relative row number Screen *GetTableAttribute T[&U[tabname]] _ firstVisibleRow=FVisRow _ lastVisibleRow=LVisRow _ lastRow=LastRow // First row on
screen? Enter "/scrollToLine=1" table="T[&U[tabname]]" label new_screen Screen * GetTableAttribute T[&U[tabname]] _ firstVisibleRow=FVisRow _ lastVisibleRow=LVisRow _ lastRow=LastRow Set V[relrow] 1 label new_row // end of table? if V[absrow>&V[LVisRow]] Enter "/scrollToLine=&V[absrow]" table="T[&U[tabname]]" goto new_screen endif Set V[C1] "&cell[&U[tabname],&U[fid1],&V[relrow]]" Set V[C2] "&cell[&U[tabname],&U[fid2],&V[relrow]]" Set V[C3] "&cell[&U[tabname],&U[fid3],&V[relrow]]" Set V[C4] "&cell[&U[tabname],&U[fid4],&V[relrow]]" Set V[C5] "&cell[&U[tabname],&U[fid5],&V[relrow]]" AppendFile "&U[filename]" C1 C2 C3 C4 C5 Set
V[absrow]
&V[absrow]
+ 1 goto new_row label
end_of_table Start "&U[filename]" // Back to line 1 Enter "/scrollToLine=1" table="T[&U[tabname]]" Leave |
Components |