Saving a tab formatted field to a file and retaining its formatting

Bob Sneidar bobsneidar at iotecdigital.com
Mon Apr 8 12:30:58 EDT 2019


This is a bit more useful. Pass the long id of the field object:

function fieldToHTMLTable pFieldID
   if not there is a field pFieldID then return "ERROR: Field object does not exist!"
   put the htmltext of pFieldID into ht
   put the effective textSize of pFieldID into fs
   put the tabstops of pFieldID into tStops
   put the width of pFieldID into fw
   put empty into tabbs
   -- we need tabstops relative, not absolute
   put item 1 of tStops into tabbs[1]
   repeat with i=2 to the num of items of tStops
      put item i of tStops - item (i-1) of tStops into tabbs[i]
   end repeat
   set itemdel to ("&" & "#9;");
   set linedel to "<p>"
   replace "</p>" with empty in ht
   put "<table width=" &fw& " cellpadding=0 cellspacing=2 "& \
         "style='font-size:"&fs&"'>"into s0
   repeat for each line L in ht
      put empty into s
      repeat with i=1 to the num of items of L
         put item i of L into II
         put "<td style='width:"& tabbs[i] &"'>" &II& "</td>" after s
      end repeat
      if s is not empty then put cr&"<tr>"&s&"</tr>" after s0
   end repeat
   put "<html><head><meta charset='UTF8'></head>" & cr & \
         "<body style='padding:0; margin:0; " & \
         "font-family:verdana,arial,sans-serif;'>" & \
         s0 & cr & "</table></body</html>" into htm
   return htm
end fieldToHTMLTable

Bob S

> On Apr 8, 2019, at 09:07 , hh via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> -- Converts a simple table field with tabstops to a html <table>
> http://lists.runrev.com/pipermail/use-livecode/2019-March/253271.html





More information about the Use-livecode mailing list