Toolserver:User:Kylu/matrix gen

Yes, it's really quickbasic. Feel free to laugh, but it works. 'wikitable generation system '2008 kylu 'runs in qbx setup: DIM colname$(25) DIM matrix$(50, 50) q$ = CHR$(34)

main: CLS PRINT "Please enter values for the following:" PRINT PRINT "Global information:" INPUT "Global Background color: ", bg.color$ INPUT "Table title: ", title$ INPUT "Title background color: ", title.color$ PRINT PRINT "Column information:" INPUT "Column header color: ", col.color$ INPUT "Number of columns: ", columns INPUT "Odd column color: ", odd.col.color$ INPUT "Number of rows, not including title: ", rows PRINT INPUT "Output filename: ", file$

fill.cols: PRINT "Time to enter the column names:" FOR cur.col = 1 TO columns PRINT "Column "; cur.col; INPUT "title? ", column$(cur.col) NEXT cur.col

fill.matrix: PRINT "Time to enter the matrix values:" FOR cur.row = 1 TO rows PRINT "Row #"; cur.row FOR cur.col = 1 TO columns PRINT column$(cur.col); INPUT "value? ", matrix$(cur.row, cur.col) NEXT cur.col NEXT cur.row

write.header: PRINT "Generating: "; file$ OPEN file$ FOR OUTPUT AS #1

'output table header '{| class="toccolours" style="margin-bottom: 0.5em; border: #whatever       'solid 2px; background: bg.color$;" h$ = "{| class=" + q$ + "toccolours" + q$       h$ = h$ + " style=" + q$ + "margin-bottom: 0.5em; border: #000000" h$ = h$ + "solid 2px; background: " + bg.color$ + ";" + q$       PRINT #1, h$        h$ = ""

'seperator PRINT #1, "|-"

'output title bar '!align="center" style="background:title.color$" colspan=columns | title h$ = "!align=" + q$ + "center" + q$ + " style=" + q$ + "background:" h$ = h$ + title.color$ + q$ + " colspan=" + STR$(columns) + " |" + title$ PRINT #1, h$       h$ = ""

'seperator PRINT #1, "|-"

'output column headers '! align="center" style="background:#col.color$" | Column name FOR c = 1 TO columns h$ = "! align=" + q$ + "center" + q$               h$ = h$ + "style=" + q$ + "background:#" + col.color$ h$ = h$ + " | " + column$(c) PRINT #1, h$               h$ = "" NEXT c

'output table entry '| align="center" | table$(row,col) 'inner loop is columns, outer is rows FOR r = 1 TO rows FOR c = 1 TO columns h$ = "| align=" + q$ + "center" + q$ + " | " + matrix$(r, c)                       PRINT #1, h$                        h$ = "" NEXT c               IF odd = 1 THEN h$ = "|- bgcolor=" + q$ + "#" + odd.col.color$ + q$               ELSE h$ = "|-" END IF               odd = 1 - odd           'toggle state of odd PRINT #1, h$       NEXT r

'output close '|}       PRINT #1, "|}" PRINT "Done." CLOSE h$ = "notepad " + file$ SHELL h$       END