REBOL [ Title: "Name block to heading block" Purpose: {Given a block of blocks, with each sub-block containing one word, convert that block of block to a block of strings where each string is the contents of the corresponding sub-block converted to a string.} ] ;; [---------------------------------------------------------------------------] ;; [ This is a function for a very specific situation. ] ;; [ This SQL command: ] ;; [ select ] ;; [ COLUMN_NAME ] ;; [ from information_schema.columns ] ;; [ where (TABLE_NAME = 'xxxxxxxx') -- xxxxxxx is a table name ] ;; [ order by ORDINAL_POSITION, COLUMN_NAME ] ;; [ will produce a result set that is a block of blocks, and each sub-block ] ;; [ will have one item which will be a column name from the table, list this: ] ;; [ [ [colname-1] [colname-2] ... [colname-n] ] ] ;; [ This function will take that result set and turn it into a block of ] ;; [ headings for a specific report related to this specific project, ] ;; [ like this: ] ;; [ [ "colname-1" "colname-2" ... "colname-n" ] ] ;; [---------------------------------------------------------------------------] NAMEBLOCK-TO-HEADINGBLOCK: func [ RESULTSET /local HEADINGBLOCK ] [ HEADINGBLOCK: copy [] foreach SUBBLOCK RESULTSET [ append HEADINGBLOCK to-string first SUBBLOCK ] return HEADINGBLOCK ] ;;Uncomment to test ;TESTRESULTSET: [ ; [COL-1] ; [COL-2] ; [COL-3] ; [COL-4] ; [COL-5] ;] ;TESTHEADINGS: NAMEBLOCK-TO-HEADINGBLOCK TESTRESULTSET ;probe TESTHEADINGS ;halt