function importdoc, fname {
  text = import(fname, /text)
  importdoc = stringarray(0)
  o = 0
  for i=1, nelements(text) {
    if (o == 1) importdoc += text[i]
    if (o == 0 && text[i] == "/*!") o = 1
    if (o == 1 && text[i] == "*/") {
      o = 0
      importdoc[nelements(importdoc)] = ""
    }
  }
}

text = importdoc("functions_doc.h")

html = stringarray(0)
html += "<html>"
html += "<head>"
html += "  <meta name=\"Author\" content=\"Thomas Ott\">"
html += "  <title>DPUSER - The Next Generation: Alphabetical function index</title>"
html += "</head>"
html += "<body>"
html += ""
html += "<h1>Alphabetical function index</h1>"

summary = stringarray(0)
while (nelements(text) > 0) {
  i = 1
  while(text[i] != "" && i < nelements(text)) i++
  function = text[1:i]
  summary += function[1]
  if (i < nelements(text)) {
    text = text[i+1:nelements(text)]
  } else {
    text = stringarray(0)
  }
}

summary = summary[sort(summary)]
current = "3"
html += "<font size=+2><b>3D</b></font><br>"
html += "<table width=\"100%\" bgcolor=\"#FFFF99\" cellpadding=0 cellspacing=0 border=0>"
count = 0

for i=1, nelements(summary) {
  if (summary[i][1] != current) {
    for j=count, 4 html += "<td width=\"20%\">&nbsp;</td>"
    current = summary[i][1]
    html += "</tr></table><br>"
    html += "<font size=+2><b>" + upper(current) + "</b></font><br>"
    html += "<table width=\"100%\" bgcolor=\"#FFFF99\" cellpadding=0 cellspacing=0 border=0>"
    count = 0
  }
  count++
  if (count > 5) {
    html += "</tr>"
    count = 1
  }
  if (count == 1) html += "<tr>"
        
  // test if function name is obsolete ("function_name (obsolete)"). When true the " (obsolete)"-string will be removed for the file-name
  filename = summary[i]
  if (strpos(filename, "obsolete") != -1) {
    filename_len = nelements(filename)
    filename = filename[1:filename_len-11] 
  }
  
  html += "<td width=\"20%\"><a href=\"function_" + filename + ".html\">" + filename + "</a></td>"
        
  if (i == nelements(summary)) {
    for j=count, 4 html += "<td width=\"20%\">&nbsp;</td>"
    html += "</tr></table>"
  }
}
    
html += "</body>"
html += "</html>"

export "functions.html", html


text = importdoc("procedures_doc.h")

html = stringarray(0)
html += "<html>"
html += "<head>"
html += "  <meta name=\"Author\" content=\"Thomas Ott\">"
html += "  <title>DPUSER - The Next Generation: Alphabetical procedure index</title>"
html += "</head>"
html += "<body>"
html += ""
html += "<h1>Alphabetical procedure index</h1>"

summary = stringarray(0)
while (nelements(text) > 0) {
  i = 1
  while(text[i] != "" && i < nelements(text)) i++
  function = text[1:i]
  summary += function[1]
  if (i < nelements(text)) {
    text = text[i+1:nelements(text)]
  } else {
    text = stringarray(0)
  }
}

summary = summary[sort(summary)]
current = "3"
html += "<font size=+2><b>3D</b></font><br>"
html += "<table width=\"100%\" bgcolor=\"#FFFF99\" cellpadding=0 cellspacing=0 border=0>"
count = 0

for i=1, nelements(summary) {
  if (summary[i][1] != current) {
    for j=count, 4 html += "<td width=\"20%\">&nbsp;</td>"
    current = summary[i][1]
    html += "</tr></table><br>"
    html += "<font size=+2><b>" + upper(current) + "</b></font><br>"
    html += "<table width=\"100%\" bgcolor=\"#FFFF99\" cellpadding=0 cellspacing=0 border=0>"
    count = 0
  }
  count++
  if (count > 5) {
    html += "</tr>"
    count = 1
  }
  if (count == 1) html += "<tr>"
        
  // test if procedure name is obsolete ("procedure_name (obsolete)"). When true the " (obsolete)"-string will be removed for the file-name
  filename = summary[i]
  if (strpos(filename, "obsolete") != -1) {
    filename_len = nelements(filename)
    filename = filename[1:filename_len-11] 
  }

  html += "<td width=\"20%\"><a href=\"procedure_" + filename + ".html\">" + filename + "</a></td>"
  if (i == nelements(summary)) {
    for j=count, 4 html += "<td width=\"20%\">&nbsp;</td>"
    html += "</tr></table>"
  }
}
    
html += "</body>"
html += "</html>"

export "procedures.html", html

