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

noteblock.clb - tabs2Spaces (even spacing)

Expand Messages
  • Pat(kitPatH)
    Morning, I need some help again ... (I m still using notetab 4.95np) One of the clips in a library authored by Jody works for whole documents but locks on
    Message 1 of 4 , Oct 2, 2007
    View Source
    • 0 Attachment
      Morning, I need some help again ... (I'm still using notetab 4.95np)


      One of the clips in a library authored by Jody works for whole documents but
      locks on selected text. Wonder if anyone can spot the problem in the code.
      It used to work on selected (I think....)

      The data: each row has the same number of tabs / no missing values.
      Only dealing with four variables.

      Calories: 299 Milk 0.1
      Fat (gm): 23.7 Vegetable: 0.0
      Sat. fat (gm): 6 Fruit 0.2
      Cholesterol (mg): 94 Bread: 0.0
      Sodium (mg): 603 Meat 5.0
      % Calories from fat 30 Fat 1.7



      H="Tabs2Spaces... Pro and Std/Lt - aligns tab delimited, evenly, 2 spaces btw cols"
      ; Date: Mon, 15 May 2000 13:50:22 +0200
      ; Reply-To: ntb-clips@egroups.com
      ; Subject: Re: [Clip] Making a table
      ; Input data must have columns separated by either a tab
      ; character or two or more blanks. If you want to have a gap
      ; in the table, ie an empty cell followed by non-empty
      ; cell(s), you have to use a tab as column separators for
      ; each field skipped. Regards /Claes/Jody
      ^!Continue Works in Pro, Std & Light - aligns tab delimited files^%nl%evenly leaving two spaces between columns. Also^%nl%works on documents having two spaces between^%nl%the fields. The Clip starts aligning on the line where^%nl%the cursor is at so put your cursor on line 1 if that^%nl%is where you want to start formatting at. Continue?
      ^!ClearVariables
      ^!Set %SelStart%=^$GetRowStart$:1; %SelEnd%=^$Calc(^$GetRowEnd$+1)$
      ^!IfTrue ^$IsEmpty("^$GetSelection$")$ Next else Start
      ^!Set %NoSel%=1
      ^!Jump Doc_End
      ^!IfFalse ^$IsEmpty(^$GetLine$)$ Skip_2
      ^!Replace "^p" >> "" SB
      ^!IfError Next else Skip_-2
      ^!InsertText ^p
      ^!Jump 1
      :Start
      ^!SetHintInfo Working...
      ^!SetScreenUpdate Off
      ^!SetWordWrap OFF
      ;Make all delimiters tabs
      ^!IfTrue ^%NoSel% Next else Skip_2
      ^!Replace "[ ][ ]+" >> "\t" STAIRWH
      ^!Goto Skip
      ^!Replace "[ ][ ]+" >> "\t" STAIRH
      ^!SetListDelimiter ^t
      ^!SetArray %oldsz%=0
      ; ^!Jump TEXT_START
      ^!SetCursor ^%SelStart%
      ;FIND THE REQUIRED COLUMN SIZES
      ;Get a line as an array
      :nextrec
      ^!Select EOL
      ^!Set %a%=^$GetSelection$
      ^!SetArray %new%=^%a%
      ^!SetArray %newsz%=^%new%
      ;Make array of field sizes
      ^!Set %ix%=0
      ^!Inc %ix%
      ^!Set %newsz^%ix%%=^$StrSize("^%new^%ix%%")$
      ^!If ^%ix%<^%new0% Skip_-2
      ;Merge new and old array
      ^!SetArray %long%=^%oldsz%
      ^!SetArray %short%=^%newsz%
      ^!If ^%oldsz0%>^%newsz0% mergethem
      ^!SetArray %long%=^%newsz%
      ^!SetArray %short%=^%oldsz%
      :mergethem
      ^!Set %ix%=0
      ^!Inc %ix%
      ^!Set %long^%ix%%=^$calc(max(^%oldsz^%ix%%;^%newsz^%ix%%))$
      ^!If ^%ix%<^%short0% Skip_-2
      ^!SetArray %oldsz%=^%long%
      ^!If ^$GetRow$=^$GetLineCount$ InsertSpace
      ;Get next line
      ^!Jump +1
      ^!Jump LINE_START
      ^!GoTo nextrec
      ;NOW INSERT SPACES
      :InsertSpace
      ; ^!Jump TEXT_START
      ^!SetCursor ^%SelStart%
      ;Again pick up a line as an array
      :nextrec2
      ^!Select EOL
      ^!Set %a%=^$getselection$
      ^!Setarray %new%=^%a%
      ;Skip record if only one field
      ^!If ^%new0%<2 nextline
      ^!Setarray %newsz%=^%new%
      ;Make array of field sizes
      ^!Set %ix%=0
      ^!Inc %ix%
      ^!Set %newsz^%ix%%=^$StrSize("^%new^%ix%%")$
      ^!If ^%ix%<^%new0% Skip_-2
      ;Get nbr of blanks needed and insert them
      ^!Set %ix%=1
      ^!Jump LINE_START
      :nextfld2
      ^!Find "^t" TIS
      ^!InsertText ^$StrFill(" ";^$Calc(^%oldsz^%ix%%-^%newsz^%ix%%+2)$)$
      ^!Inc %ix%
      ^!If ^%ix%<^%newsz0% nextfld2
      ^!If ^$GetRow$=^$GetLineCount$ Exit
      ;Get next line
      :nextline
      ^!Jump +1
      ^!Jump LINE_START
      ^!IfTrue ^%NoSel% Next else Skip_2
      ^!If ^$GetRow$ = ^$GetLineCount$ End
      ^!Goto nextrec2
      ^!If ^$GetRow$ = ^%SelEnd% End
      ^!Goto nextrec2
    • Sheri
      Just glancing, I see a Replace command with options for W (whole document) and H (highlight). Those are mutually exclusive options, no idea what the impact
      Message 2 of 4 , Oct 2, 2007
      View Source
      • 0 Attachment
        Just glancing, I see a Replace command with options for "W" (whole
        document) and "H" (highlight). Those are mutually exclusive options,
        no idea what the impact of including both would be.

        But it doesn't look like that replace even gets used when there is a
        selection.

        Just tried the clip on your sample (with and without a selection) and
        it worked fine in the current version of NoteTab (without no
        modifications).

        Regards,
        Sheri
      • Alan C
        ... (I didn t spot anything) But in the case that you might need it, here s a clip that will put a copy of your selected text into a new document -- (you said
        Message 3 of 4 , Oct 2, 2007
        View Source
        • 0 Attachment
          On 10/2/07, Pat(kitPatH) <kitpath@...> wrote:
          >
          > Morning, I need some help again ... (I'm still using notetab 4.95np)
          >
          >
          > One of the clips in a library authored by Jody works for whole documents
          > but
          > locks on selected text. Wonder if anyone can spot the problem in the
          > code.
          > It used to work on selected (I think....)


          (I didn't spot anything)

          But in the case that you might need it, here's a clip that will put a copy
          of your selected text into a new document -- (you said that the tabs2spaces
          clip works on an entire doc -- well now you have an entire doc) ie selection
          to new doc then run on said new doc the clip that works on an entire doc.

          H="Sel_text_2_a_new_doc"
          ^!Set %my_sel_text% =^$GetSelection$
          ^!Toolbar "new document"
          ^!Insert ^%my_sel_text%
          ; now have a whole doc
          ; end


          --
          Alan.


          [Non-text portions of this message have been removed]
        • Pat
          Dear eagle eye sheri, The WH conflict was it! thank you for seeing it... -pat ... and
          Message 4 of 4 , Oct 5, 2007
          View Source
          • 0 Attachment
            Dear eagle eye sheri,
            The WH conflict was it! thank you for seeing it...

            -pat



            --- In ntb-clips@yahoogroups.com, "Sheri" <silvermoonwoman@...> wrote:
            >
            > Just glancing, I see a Replace command with options for "W" (whole
            > document) and "H" (highlight). Those are mutually exclusive options,
            > no idea what the impact of including both would be.
            >
            > But it doesn't look like that replace even gets used when there is a
            > selection.
            >
            > Just tried the clip on your sample (with and without a selection)
            and
            > it worked fine in the current version of NoteTab (without no
            > modifications).
            >
            > Regards,
            > Sheri
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.