Sub ExportAsHTML ( fnamein as text, fnameout as text ) Dim html as text, out as text, end as text, i as integer html = FileData(fnamein) // First try to split it up into body records i = Instr(html,"") if i > 0 then out = Export__Fields(Left$(html,i-1)) html = Mid$(html,i) i = Instr(html,"") if NotTrue(i > 0) then i = Len(html) endif end = Mid$(html,i) Dim ok as boolean ok = CurrentRecset.MoveFirst while ok out = out + Export__Record(Left$(html,i-1)) ok = CurrentRecset.MoveNext endwhile ok = CurrentRecset.MoveFirst out = out + Export__Fields(end) else out = Export__Record(html) endif SaveData(fnameout,out) EndSub Function Export__Record ( html as text ) as text // First look for the next subview within the source html Dim out as text, sub0 as integer sub0 = instr(html,"") if nottrue(sub1 > 0) then sub1 = len(html) endif sub0 = j + 6 ok = r2.MoveFirst out = Export__Fields(Left$(html,sub0-1)) while ok out = out + Export__Record(Mid$(html,sub0,sub1-sub0)) ok = r2.MoveNext endwhile ok = r2.MoveFirst out = out + Export__Record(Mid$(html,sub1)) // might have more subviews in it Else out = Export__Fields(html) Endif Export__Record = out EndFunction Function Export__Fields ( html as text ) as text Dim i as integer, j as integer Dim f as field, v as variant, t as fieldtype, fld as text Dim dt as date, iv as interval, fl as file i = Instr ( html, "##", 1 ) while i > 0 j = Instr ( html, "##", i+2 ) fld = Mid$(html,i+2,j-i-2) f = CurrentRecset.Field(fld) v = f.GetValue t = f.GetType if t = fieldtype_Text then fld = text(v) else if t = fieldtype_Boolean then fld = str$(boolean(v)) else if t = fieldtype_Integer then fld = str$(integer(v)) else if t = fieldtype_Real then fld = str$(real(v)) else if t = fieldtype_Date then dt = v fld = str$(dt) else if t = fieldtype_Interval then iv = v fld = str$(iv) else if t = fieldtype_Graphic or t = fieldtype_File then fl = v fld = filename(fl) // our best hope is a file link endif endif endif endif endif endif endif // Need to remove paragraph space fld = replace ( fld, "\n", "
" ) html = Left$(html,i-1)+fld+Mid$(html,j+2) i = Instr ( html, "##", i+len(fld) ) endwhile Export__Fields = html EndFunction