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

Re: [Clip] Sorting HTML tables solved (this time working)

Expand Messages
  • Michael Gerholdt
    Thanks, Hugo, for noticing and mentioning GetRowEnd etc. That goes a long way toward what I was after. In Internet Explorer there is the notion of InnerHTML
    Message 1 of 5 , Sep 30, 2002
    • 0 Attachment
      Thanks, Hugo, for noticing and mentioning GetRowEnd etc. That goes a long
      way toward what I was after.

      In Internet Explorer there is the notion of InnerHTML and OuterHTML.
      Thinking along those lines, and wanting to be able to re-use code for a
      variety of purposes and reflecting on the HTML table sorter Hugo and Ville
      have been crafting/perfecting:

      H="_SelectElement"
      ^!SetScreenUpdate OFF
      ^!If ^$IsEmpty(^%Tag%)$=0 Skip
      ^!Set %Tag%=^?{=_Table|h2|body|div}
      ^!If ^$IsEmpty(^%InOut%)$=0 Skip
      ^!Set %InOut%=^?{==Inner|Outer}
      ^!Clip ^%InOut%HTML
      ^!ClearVariable %InOut%
      ^!ClearVariable %Tag%

      H="_InnerHTML"
      ^!Find "</^%Tag%>" IS
      ^!Set %End%=^$GetRowStart$:^$GetColStart$
      ^!Find "<^%Tag%" BIS
      ^!Select HTMLTAG
      ^!Set %Beg%=^$GetRowEnd$:^$GetColEnd$
      ^!SetCursor ^%Beg%
      ^!SelectTo ^%End%

      H="_OuterHTML"
      ^!Find "</^%Tag%>" IS
      ^!Set %End%=^$GetRowEnd$:^$GetColEnd$
      ^!Find "<^%Tag%" BIS
      ^!Select HTMLTAG
      ^!Set %Beg%=^$GetRowStart$:^$GetColStart$
      ^!SetCursor ^%Beg%
      ^!SelectTo ^%End%

      You place a call to the first clip, _SelectElement (the list of html tags of
      course needs to be expanded).
      Call like this:

      ^!Set %InOut%="Inner";%Tag%="Table"
      ^!Clip SelectElement

      Or simply

      ^!Clip SelectElement

      to be prompted for HTML tag and choice between Inner and Outer HTML (no
      prompt in the first case).

      Once the first three are debugged and in working order, in future one would
      need write only one or two lines of code to be able to select inner or outer
      html of any (container) element. Using FarClip this could be useful from any
      clip library, including the HTML Table Sorter that Ville and Hugo have
      provided.

      Comments, improvements solicited!

      Mike
    • Ville Saalo
      Very nice work. :) Here s how I would improve it: H= _SelectElement ^!SetScreenUpdate OFF ^!If ^$IsEmpty(^%Tag%)$=0 Skip_5 ^!FIND
      Message 2 of 5 , Oct 1, 2002
      • 0 Attachment
        Very nice work. :) Here's how I would improve it:

        H="_SelectElement"
        ^!SetScreenUpdate OFF
        ^!If ^$IsEmpty(^%Tag%)$=0 Skip_5
        ^!FIND "</" IS
        ^!Jump SELECT_END
        ^!Select WORD
        ^!Set %Tag%=^$GetSelection$
        ^!Set %Tag%=^?{=_Table|^%Tag%|H2|Body|Div}
        ^!If ^$IsEmpty(^%InOut%)$=0 Skip
        ^!Set %InOut%=^?{==_Inner|Outer}
        ^!Clip ^%InOut%HTML
        ^!ClearVariable %InOut%
        ^!ClearVariable %Tag%

        Notice how it's now easy to select the element in which you currently
        are. That isn't an idiotproof solution as if the starting tag is after
        our cursor's beginning place it obviously doesn't surround the text
        the cursor was on, but anyway. I have actually made a clip which can
        select any tag correctly, look for the Surrounding.zip (.clb) under the
        HTML Libraries at NoteTab's homepage. It's one of my first serious
        clips and/so it looks rather ugly (35 lines of code + some blank lines
        + comments...) but I should now be able to improve it. Uhh, now I'm
        completely off-topic, sorry. :)

        I still left the underscore in front of the Table -choice as we're
        working with them. I also added an underscore in front of the
        Inner|Outer -selection.

        Another thing I noticed here is that the ^!Select HTMLTAG command
        actually has a bug: create an empty document and insert some simple
        table. There should be nothing above the starting tag. Now try
        selecting the inner html of the table, either with my original clip or
        Mike's improved clip. They both fail, selecting the inner html *and* the
        starting <TABLE -tag. It's a bit disturbing...

        -Ville




        -----Original Message-----
        From: Michael Gerholdt <keywordz@...>
        To: ntb-clips@yahoogroups.com <ntb-clips@yahoogroups.com>
        Date: Tuesday, October 01, 2002 6:49 AM
        Subject: Re: [Clip] Sorting HTML tables solved (this time working)


        >Thanks, Hugo, for noticing and mentioning GetRowEnd etc. That goes a long
        >way toward what I was after.
        >
        >In Internet Explorer there is the notion of InnerHTML and OuterHTML.
        >Thinking along those lines, and wanting to be able to re-use code for a
        >variety of purposes and reflecting on the HTML table sorter Hugo and Ville
        >have been crafting/perfecting:
        >
        >H="_SelectElement"
        >^!SetScreenUpdate OFF
        >^!If ^$IsEmpty(^%Tag%)$=0 Skip
        >^!Set %Tag%=^?{=_Table|h2|body|div}
        >^!If ^$IsEmpty(^%InOut%)$=0 Skip
        >^!Set %InOut%=^?{==Inner|Outer}
        >^!Clip ^%InOut%HTML
        >^!ClearVariable %InOut%
        >^!ClearVariable %Tag%
        >
        >H="_InnerHTML"
        >^!Find "</^%Tag%>" IS
        >^!Set %End%=^$GetRowStart$:^$GetColStart$
        >^!Find "<^%Tag%" BIS
        >^!Select HTMLTAG
        >^!Set %Beg%=^$GetRowEnd$:^$GetColEnd$
        >^!SetCursor ^%Beg%
        >^!SelectTo ^%End%
        >
        >H="_OuterHTML"
        >^!Find "</^%Tag%>" IS
        >^!Set %End%=^$GetRowEnd$:^$GetColEnd$
        >^!Find "<^%Tag%" BIS
        >^!Select HTMLTAG
        >^!Set %Beg%=^$GetRowStart$:^$GetColStart$
        >^!SetCursor ^%Beg%
        >^!SelectTo ^%End%
        >
        >You place a call to the first clip, _SelectElement (the list of html tags of
        >course needs to be expanded).
        >Call like this:
        >
        >^!Set %InOut%="Inner";%Tag%="Table"
        >^!Clip SelectElement
        >
        >Or simply
        >
        >^!Clip SelectElement
        >
        >to be prompted for HTML tag and choice between Inner and Outer HTML (no
        >prompt in the first case).
        >
        >Once the first three are debugged and in working order, in future one would
        >need write only one or two lines of code to be able to select inner or outer
        >html of any (container) element. Using FarClip this could be useful from any
        >clip library, including the HTML Table Sorter that Ville and Hugo have
        >provided.
        >
        >Comments, improvements solicited!
        >
        >Mike
      • Michael Gerholdt
        Ville, I like the improvement and will use it. Hmmm, most of my tables aren t consistent from row to row. stuf stuf
        Message 3 of 5 , Oct 2, 2002
        • 0 Attachment
          Ville,

          I like the improvement and will use it.

          Hmmm, most of my tables aren't consistent from row to row.

          <TR>
          <TD>stuf</TD>
          <TD colspan="2">stuf</TD>
          </TD>stuf</TD>
          </TR>

          <TR>
          <TD>stuf</TD>
          </TD>stuf</TD>
          <TD>stuf</TD>
          </TD>stuf</TD>
          </TR>

          The first row doesn't get sorted. This looks interesting.

          But last night was miles before sleep. Tonight, it's sleep before miles.

          Sleep is lovely dark and deep
          and i've no promises to keep . . .

          'night, with apologies to R.F.

          Thanks,
          Mike
        Your message has been successfully submitted and would be delivered to recipients shortly.