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

Re: [Clip] The operation of ^%NL%

Expand Messages
  • Larry Thomas
    Hi Roy, ... You are trying to compare two strings with the ^!If command and this is not working for that purpose. Eric designed the basic ^!If command to
    Message 1 of 4 , Oct 2, 2003
    • 0 Attachment
      Hi Roy,

      At 04:01 PM 10/2/03 -0600, you wrote:
      >I have a question on the operation of ^%NL%.
      >I have a simple clip below that deletes blank lines.
      >It works fine, but if a line contains an equal sign (=), it thinks
      >it is a null line and deletes it.
      >Can anyone help?
      >Thanks, Roy
      >
      >For example, in the file below, b= gets deleted:
      >a
      >b=
      >c
      >
      >
      >^!Set %Row%=0
      >:BumpRow
      >^!Inc %Row%
      >^!SetCursor ^%Row%:1
      >:Getline
      >^!Set %MaxRow%=^$GetTextLineCount$
      >^!If ^%Row% >= ^%MaxRow% BumpRowEnd
      >^!If ^$GetLine$ <> ^%NL% ^!GoTo BumpRow
      >^!DeleteLine
      >^!GoTo Getline
      >:BumpRowEnd

      You are trying to compare two strings with the ^!If command and this is not
      working for that purpose. Eric designed the basic ^!If command to compare
      number values and it will try to convert strings to their ascii values
      before comparing them. This frequently causes problems when you want to
      make such comparisons. I am not really familiar with the exact rules for
      ascii comparisons but Eric did provide several methods for you to use for
      this purpose.

      ^!IfSame and IfDiff are the two that I am most familiar with but there is a
      method that will allow you to use the ^!If command in your clip. Instead
      of comparing strings, compare the relative lengths of the lines and you can
      find blank lines this way.

      Replace:

      !If ^$GetLine$ <> ^%NL% ^!GoTo BumpRow

      With:

      ^!If ^$GetLineSize$ < 0 BumpRow ELSE Next

      And that should solve your problem. I checked this out and all blank lines
      have a line length of zero.

      Regards,

      Larry
      lrt@... e¿ê
    • Larry Thomas
      Hi Roy, Sorry, I got the sign backward. ^!If ^$GetLineSize$ 0 BumpRow ELSE Next Regards, Larry
      Message 2 of 4 , Oct 2, 2003
      • 0 Attachment
        Hi Roy,

        Sorry, I got the sign backward.

        ^!If ^$GetLineSize$ < 0 BumpRow ELSE Next

        Should be:

        ^!If ^$GetLineSize$ > 0 BumpRow ELSE Next

        Regards,

        Larry
        lrt@... e¿ê
      • Larry Thomas
        ... Hi Roy, This clip removes all blanks from your document(s) including any blanks that may be at the end of the document. It addresses a number of problems
        Message 3 of 4 , Oct 5, 2003
        • 0 Attachment
          At 04:01 PM 10/2/03 -0600, you wrote:
          >I have a question on the operation of ^%NL%.
          >I have a simple clip below that deletes blank lines.
          >It works fine, but if a line contains an equal sign (=), it thinks
          >it is a null line and deletes it.
          >Can anyone help?
          >Thanks, Roy

          Hi Roy,

          This clip removes all blanks from your document(s) including any blanks
          that may be at the end of the document. It addresses a number of problems
          in the clip you previously posted. Your clip does not work if any lines
          are wrapped to the screen. Also, your clip fails to take into account the
          fact that the total line count for the document decreases everytime a line
          is deleted. The result is that the clip will try to run past the end of
          the document. In addition to that, your clip will only process every other
          line because it moves the cursor even when a line is deleted. You do not
          want to do this because deleting a line moves all of the other lines up in
          the document so that the current line is now the one you want to process
          but your clip jumps to the next line without processing it.

          Here is my replacement clip:

          ______[Copy below this line]_______
          H="Remove Blank Lines"
          ;lrt@... e¿ê
          ;10/05/2003, 03:58:17 PM
          ^!Set %Wordwrap%=^$IsWordWrap$
          ^!SetWordwrap 0
          ^!Jump 1
          :Loop
          ^!If ^$GetLineSize$ > 0 Skip_2 ELSE Next
          ^!DeleteLine
          ^!If ^$GetRow$ = ^$GetTextLineCount$ Skip ELSE Loop
          ^!Jump +1
          ^!If ^$GetLineSize$ > 0 Skip ELSE Next
          ^!DeleteLine
          ^!If ^$GetRow$ >= ^$GetTextLineCount$ Next ELSE Loop
          ^!SetWordwrap ^%Wordwrap%
          ^!Keyboard Ctrl+End
          ^!If ^$GetLineSize$ > 0 Exit ELSE Next
          ^!Keyboard Ctrl+End Backspace
          _____[Copy above this line]______
          | right click over the clipbook |
          | and choose "Add from Clipboard" |
          ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

          Regards,

          Larry
          lrt@... e¿ê
        • Larry Thomas
          ... Hi Roy, I just received your post to me about wanting to delete lines that appear blank but contain non-printing characters such as spaces, tabs,etc as
          Message 4 of 4 , Oct 5, 2003
          • 0 Attachment
            At 04:01 PM 10/2/03 -0600, you wrote:
            >I have a question on the operation of ^%NL%.
            >I have a simple clip below that deletes blank lines.
            >It works fine, but if a line contains an equal sign (=), it thinks
            >it is a null line and deletes it.
            >Can anyone help?
            >Thanks, Roy

            Hi Roy,

            I just received your post to me about wanting to delete lines that appear
            blank but contain non-printing characters such as spaces, tabs,etc as well
            a the newline character pair. I have revised my clip and I believe that
            this will work for you.

            Here it is.

            ______[Copy below this line]_______
            H="Remove Blank Lines"
            ;lrt@... e¿ê
            ;10/05/2003, 04:32:24 PM
            ^!Set %Wordwrap%=^$IsWordWrap$
            ^!SetWordwrap 0
            ^!Jump 1
            :Loop
            ^!IfTrue ^$Isblank(^$Getline$)$ Skip ELSE Next
            ^!If ^$GetLineSize$ > 0 Skip_2 ELSE Next
            ^!DeleteLine
            ^!If ^$GetRow$ = ^$GetTextLineCount$ Skip ELSE Loop
            ^!Jump +1
            ^!IfTrue ^$Isblank(^$Getline$)$ Skip ELSE Next
            ^!If ^$GetLineSize$ > 0 Skip ELSE Next
            ^!DeleteLine
            ^!If ^$GetRow$ >= ^$GetTextLineCount$ Next ELSE Loop
            ^!SetWordwrap ^%Wordwrap%
            ^!Keyboard Ctrl+End
            ^!IfTrue ^$Isblank(^$Getline$)$ Next ELSE Skip
            ^!DeleteLine
            ^!If ^$GetLineSize$ > 0 Exit ELSE Next
            ^!Keyboard Ctrl+End Backspace
            _____[Copy above this line]______
            | right click over the clipbook |
            | and choose "Add from Clipboard" |
            ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

            Regards,

            Larry
            lrt@... e¿ê
          Your message has been successfully submitted and would be delivered to recipients shortly.