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

Re: [NTS] Hello (Reg. Exp. Find and Replace, coding question)!

Expand Messages
  • Don - HtmlFixIt.com
    Some padding things in notetab: Choice one (probably not): ^!SetNameFormat Mask (added in v4.6) The name format is used when new documents are created. The
    Message 1 of 3 , Apr 13 10:15 AM
    • 0 Attachment
      Some padding things in notetab:

      Choice one (probably not):
      ^!SetNameFormat Mask (added in v4.6)
      The name format is used when new documents are created. The code "%d"
      indicates where the incremental numbering is inserted in the name. In
      the following example, the "0.2" between the % and d tells NoteTab to
      format numbers smaller than 2 digits with leading zeroes: NoName%0.2d.txt


      Padding on a string (probably not, limited to spaces -- would be great
      if you could specify the padding character):
      ^$StrAlign("Str";TextWidth;Alignment[;Pad=False])$ (added in v4.9)

      This function aligns the Str value within a space specified by
      TextWidth. Alignment values can be Left, Right, or Center. If the Pad
      parameter is used, a True value adds blank spaces on the right side of
      Str (if necessary). Examples:

      ^$StrAlign("Test";10;Right)$ -> " Test"

      ^$StrAlign("Test";10;Center;True)$ -> " Test "

      Of course you could do a second replace I suppose.

      I often use this routine to zero pad things:
      ;use Hugo's ideas to get places and pad with zeros
      ^!Set %Field%=^$GetField(^$GetRow$;1)$
      ^!If ^$StrSize("^%Field%")$=1 ^!Set %Field%=00^%Field%
      ^!If ^$StrSize("^%Field%")$=2 ^!Set %Field%=0^%Field%

      But that assumes that you have created a variable.

      There is a way to assign the regex find patterns to a variable and then
      you can work on it.

      Are you doing this with a clip?

      Here is another zero padding method I have used:
      ^!Set %format%="^$GetLineCount$"
      ^!Set %formatsize%="^$StrSize("^%format%")$"


      :Loop
      ^!Jump Line_End
      ; set padding of zero's
      ^!Set %length%="^$Calc(^%formatsize%-^$StrSize("^$GetRow$")$)$"
      ^!InsertText ^$StrFill(0;^%length%)$^%Line%

      I have spent half of my life doing zero padding.
    • copyacademyperfect
      ... Thank You! I ll try your Jedi mind tricks, one by one. I am so very green I hafta read everything four, five or six times while focusing on some manual in
      Message 2 of 3 , Apr 14 9:28 AM
      • 0 Attachment
        --- In ntb-scripts@yahoogroups.com, "Don - HtmlFixIt.com" <don@...>
        wrote:

        > Some padding things in notetab:

        Thank You! I'll try your Jedi mind tricks, one by one. I am so very
        green I hafta read everything four, five or six times while focusing on
        some manual in another window while jotting down the code. If I only
        had known/explored the ^!if and ^!set commands (for example) last night.


        > Are you doing this with a clip?

        I have recently (four days?) started to use NoteTab. I've only
        searched/replaced files all days now. I have also discovered NoteTab's
        excellent ways of fixing and dealing with lines. But from what I
        understand, "clipping" is something I'll play with quite abit.


        > I have spent half of my life doing zero padding.

        I've spent more than half of my life (=24/33years) using computers
        doing "zero coding" (=not any at all). Why? You can really utilize your
        machine with it, and do all those little things you wish was
        implemented in various software. Suddenly I am issuing commands from
        one application into another in commandlines without opening any
        window. This is great when you're working with pictures/audio, like I
        do. Thank You NoteTab!

        And thanks Don. 'tis really nice of you to take the time. Appriciate it.

        //Peter
      Your message has been successfully submitted and would be delivered to recipients shortly.