The browser is very convenient for displaying data.
This example shows how to display the content of a 1D array (split into rows for 'easier' viewing purposes) using a simple html table.
It uses the 'title' attribute to get a mouse-over effect (when you move the mouse over a cell the array index of that cell will be shown).
Compile/run the program and open the resulting file (/test.html, make sure there is no file /test.html as it will get overwritten) in a browser.
When you rerun the program and press reload (F5?) in the browser you get an updated html table (values will have changed due to use of randomness for array values).
An example of what the output looks like can be found here.
Code: Select all
Function rnd_range (byval first As Double, byval last As Double) As Double
Function = Rnd * (last - first) + first
End Function
function create_table_i cdecl(byval table as integer ptr, byval size as integer, byval slice as integer) as integer
dim i as integer
if (size = 0) then
return -1
end if
if (table = 0) then
return -1
end if
if (slice = 0 orelse slice > size - 1) then
return -1
end if
dim fh as integer = freefile()
''change the name of the file!?
open "/test.html" for output as #fh
var err_ = err()
if (err_ <> 0) then
return -1
end if
print #fh, "<!DOCTYPE html>"
print #fh, "<html>"
print #fh, "<body>"
print #fh, "<table border=""1"">"
print #fh, !"<tr title = \"" & "0" & !"\"" & ">"
print #fh, !"<td bgcolor=\"grey\" title = \"" & i & !"\">" & i & "</td>"
while (i < size)
if (i mod slice = 0 andalso i <> 0) then
print #fh, "</tr>"
print #fh, !"<tr title = \"" & i & !"\">"
print #fh, !"<td bgcolor=\"grey\" title = \"" & i & !"\">" & i & "</td>"
end if
print #fh, !"<td title = \"" & i & !"\">" & table[i] & "</td>"
i += 1
wend
print #fh, "</tr>"
print #fh, "</table>"
print #fh, "</body>"
print #fh, "</html>"
close #fh
return 0
end function
function mymain() as integer
const TABLE_SIZE = 100
const SLICE_SIZE = 10
dim integer_array as integer ptr = new integer[TABLE_SIZE-1]
if (integer_array = 0) then
return -1
end if
randomize()
for i as integer = 0 to TABLE_SIZE - 1
integer_array[i] = Int(rnd_range(69, 421))
next i
var error_ = create_table_i(integer_array,TABLE_SIZE,SLICE_SIZE)
if (error_) then
return -1
end if
delete[] integer_array
end function
var error_ = mymain()
if (error_) then
print "something went wrong"
end if