Loading ...
Sorry, an error occurred while loading the content.

Re: [Clip] how to read a file a line at a time

Expand Messages
  • Larry Hamilton
    Don, Sorry I could not have gotten back to you last night. Glad you figured it out! It took me a while to make sense out of how the clip worked myself. I also
    Message 1 of 5 , Jan 31, 2001
    • 0 Attachment
      Don,

      Sorry I could not have gotten back to you last night. Glad you
      figured it out! It took me a while to make sense out of how the clip
      worked myself. I also use a modification of Joe Barta's csvtotable
      clip to put it in a table. That is what the clip code you could not
      make sense of was for, to clean things up for the clip from Joe.

      HTH,


      ;
      =================================================
      ========
      ; CSV to HTML TABLE v1.0
      ; by Joe Barta jbarta@...
      ; Modified by Larry Hamilton
      =================================================
      ========
      ^!ClearVariables
      ;you can set it to open a document here or use the current file.
      ^!Keyboard CTRL+A
      ^!Set %Text%=^$GetSelection$

      ^!SetHintInfo ^$GetDate(hh:nn:ss am/pm dddd, mmmm dd, yyyy)$

      ^!SetClipboard ^%Text%
      ^!Toolbar New Document
      ^!Keyboard CTRL+V
      ;^!Save AS D:\NoteTab\Documents\membtest1.htm
      ^!Set %Path%=^?[Path?:==NoteTab
      Docs^="D:\NoteTab\Documents\"|HNGS
      Notes^="D:\NoteTab\Documents\HNGS_Notes\"|HNGS
      Site^="D:\NoteTab\Documents\HNGSSite\"]
      ^!Set %name%=^?[Filename?:(membtest1 or emailtest or
      deadtest)=_membtest1.htm|emailtest.htm|deadtest.htm]
      ^!Save AS ^%Path%^%name%
      ; Set cursor to beginning of document
      ^!SetCursor 1:1
      ;^!InsertText
      MEMBER|NAME|ADDRESS|PHONE|EXPIRATION^%NL%
      ; Replace all empty cells with a blank space
      ; Do it a few times so nothing gets missed
      ^!Replace || | | ATIWS
      ^!SetCursor 1:1
      ^!Replace || | | ATIWS
      ^!SetCursor 1:1
      ^!Replace || | | ATIWS
      ^!SetCursor 1:1
      ^!Replace || | | ATIWS

      ; Check for beginning blank cells...
      ^!SetCursor 1:1
      ^!Replace ^P| ^P | ATIWS

      ; ...and check for trailing blank cells
      ^!SetCursor 1:1
      ^!Replace |^P | ^P ATIWS

      ; Go back and check for a blank cell at the VERY beginning
      ^!SetCursor 1:1
      ^!InsertText ^P
      ^!SetCursor 1:1
      ^!Replace ^P| ^P | ATIWS
      ^!SetCursor 1:1
      ^!DeleteLine

      ; Back to beginning of document
      ^!SetCursor 1:1

      ; Replace all line breaks with appropriate TD and TR tags.
      ^!Replace ^P </TD></TR>^P<TR><TD> ATIWS
      ; ALIGN=^?[Horizontal alignment of cell data=_left|right|center]>
      ATIWS
      ; VALIGN=^?[Vertical alignment of cell data=top|bottom|_middle]>
      ATIWS

      ; Remove last line
      ^!Jump TEXT_END
      ^!DeleteLine

      ; Insert TD and TR tags at beginning of first line.
      ^!SetCursor 1:1
      ^!InsertText <TR><TD> ATIWS
      ; ALIGN=^?[Horizontal alignment of cell data=left|_right|center]>
      ATIWS
      ; VALIGN=^?[Vertical alignment of cell data=top|bottom|_middle]>
      ATIWS

      ; Replace all commas with TD pairs
      ^!Replace | </TD><TD> ATIWS
      ; ALIGN=^?[Horizontal alignment of cell data=left|_right|center]>
      ATIWS
      ; VALIGN=^?[Vertical alignment of cell data=top|bottom|_middle]>
      ATIWS

      ; Add a TABLE tag to the beginning
      ^!SetCursor 1:1
      ^!InsertText <TABLE BORDER=^?[Border (0 is no
      borders)=0|_1|2|3|4|5|6|7|8|9|10] CELLPADDING=^?[Cellpadding (2
      is average)=0|1|_2|3|4|5|6|7|8|9|10] CELLSPACING=^?[Cellspacing
      (0 looks clean)=_0|1|2|3|4|5|6|7|8|9|10]>^P

      ; Add a closing /TABLE tag to the end
      ^!Jump TEXT_END
      ^!InsertText </TABLE>^P

      ^!Jump TEXT_START
      ^!Find "ATIWS" TH
      ^!Keyboard Delete
      ^!Keyboard Backspace

      ;Replace <TD with ^P<TD. Previously its own clip.
      ^!Set Wordwrap false
      ^!SetCursor 1:1
      ^!Replace "<TD" >> "^P<TD" WASI
      ^!SetCursor 1:1
      ^!Replace "" >> "" WASI
      ^!SetCursor 1:1
      ^!Replace "> " >> ">" WASI
      ^!Keyboard CTRL+S

      ; Prompt when completed
      ;^!Prompt All Done!
      <---end clip---->

      On 30 Jan 2001, at 23:01, Don Passenger wrote:

      > and in fact I have my project done!
      > awesome clip
      > very clever

      Larry Hamilton, Jr.
      lm_hamilton@...
      http://notlimah.tripod.com/
      Hamilton National Genealogical Society, Inc.
      http://www.hamiltongensociety.org/
    Your message has been successfully submitted and would be delivered to recipients shortly.