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

Re: [NTB] Generate Random Alphanumeric Codes

Expand Messages
  • Don
    Of course. From Help: ^$StrRandom(Size)$ (added in v4.84) ^$StrRandom(Size[;Characters])$ (added in v4.85) Returns a string of random characters of the
    Message 1 of 6 , Aug 21, 2013
    • 0 Attachment
      Of course. From Help:
      ^$StrRandom(Size)$ (added in v4.84)

      ^$StrRandom(Size[;Characters])$ (added in v4.85)

      Returns a string of random characters of the specified length. This
      function can be useful for generating random passwords. Example

      ^$StrRandom(6)$ = È$q3åî

      Starting with version 4.85, the StrRandom has been updated to let you
      optionally define which characters are used in the random string that is
      generated. The "Characters" parameter represents a string of characters
      that limits what the function can use in its result. You can define
      ranges by using "..". For example, A..Z represents all the uppercase
      letters of the Roman alphabet; A..Za..z0..1 represents all digits and
      letters of the Roman alphabet. Example:

      ^$StrRandom(10;A..F0..9)$ --> D744E70176
      =================================================

      If you want a clip, write the clips group for help :-) so please don't
      discuss clip solutions here in general help is the rule generally.

      But in the spirit of helpfulness that group might suggest something like
      this:
      ^!Set %counter%="10000"
      :Loop
      ^!InsertText ^$StrRandom(10;A..F0..9)$^P
      ^!Dec %counter%
      ^!If "^%counter%" = "0" End ELSE Loop

      Which would take about 40 seconds to generate 10000 unique codes of 10
      characters each.

      They might also have more elegant solutions that would be faster ...
      always amazing.

      You may also need to sort random just to be sure all are unique if that
      is important, and then perhaps add additional at the end.

      I'll copy clips in case there is clip discussion to be had.



      On 8/21/2013 5:17 PM, burtabreu wrote:
      > Hi. I have been using Notetab Pro for several years, but mostly as an enhanced text editor and sometimes use the built in menu tools to clean stuff up. I know it is possible to do some macro like programming stuff but have never experimented.
      >
      > I will need to generate a list of 10,000 random unique alphanumeric numbers every so often here at work and was wondering if NoteTab Pro can do this and if there might be an example or an existing clip I can use?
      >
      > Thanks for your help.
      >
      > Burt
      >
      >
      >
      > ------------------------------------
      >
      > Fookes Software: http://www.fookes.com/
      > NoteTab website: http://www.notetab.com/
      > NoteTab Discussion Lists: http://www.notetab.com/groups.php
      >
      > ***
      > Yahoo! Groups Links
      >
      >
      >
      >
    • flo.gehrke
      ... Don, Inserting line by line makes it rather slow here. It s done in a second when first creating the list in the memory... ^!SetHintInfo Working... ^!Set
      Message 2 of 6 , Aug 21, 2013
      • 0 Attachment
        --- In ntb-clips@yahoogroups.com, Don <don@...> wrote:
        >
        > :Loop
        > ^!InsertText ^$StrRandom(10;A..F0..9)$^P
        > etc.
        >
        > Which would take about 40 seconds to generate 10000 unique codes of
        > 10 characters each. They might also have more elegant solutions
        > that would be faster ...

        Don,

        Inserting line by line makes it rather slow here. It's done in a second when first creating the list in the memory...

        ^!SetHintInfo Working...
        ^!Set %Counter%=10000
        :Loop
        ^!Set %Str%=^$StrRandom(10;A..F0..9)$
        ^!Append %List%=^%Str%^%NL%
        ^!Dec %Counter%
        ^!If ^%Counter% > 0 Loop
        ^%List%
        ^!ClearVariables

        Regards,
        Flo
      • Don
        ... Figured there was a blinding fast way. Nicely done Flo!
        Message 3 of 6 , Aug 21, 2013
        • 0 Attachment
          On 8/21/2013 7:28 PM, flo.gehrke wrote:
          > Inserting line by line makes it rather slow here. It's done in a second when first creating the list in the memory...

          Figured there was a blinding fast way. Nicely done Flo!
        • Adrian Worsfold
          Based on contributions I ve therefore added in flexibility to length, number and presentation: ^!Set %chars%=^?{Character length=001} ^!Set %counter%=^?{How
          Message 4 of 6 , Aug 21, 2013
          • 0 Attachment
            Based on contributions I've therefore added in flexibility to length, number and presentation:

            ^!Set %chars%=^?{Character length=001}
            ^!Set %counter%=^?{How many=10}
            ^!Set %layout%=^?{(T=L;H=2)Presentation:=New line^=^%NL%|Space^= }
            ^!SetHintInfo Working...
            :Loop
            ^!Set %Str%=^$StrRandom(^%chars%;A..F0..9)$
            ^!Append %List%=^%Str%^%layout%
            ^!Dec %Counter%
            ^!If ^%Counter% > 0 Loop
            ^%List%^%NL%
            ^!ClearVariables





            Adrian Worsfold

            http://www.pluralist.co.uk
            http://pluralistspeaks.blogspot.com
            pluralist@...
            22-08-2013
            ----- Received the following content -----
            From: flo.gehrke
            Receiver: ntb-clips
            Time: 2013-08-22, 00:28:47
            Subject: [Clip] Re: [NTB] Generate Random Alphanumeric Codes


            [Non-text portions of this message have been removed]
          • hsavage
            On 8/21/2013 6:28 PM, flo.gehrke wrote: --- In ... second when first creating the list in the memory... ... Florian, Don, I only mention this because Burt
            Message 5 of 6 , Aug 21, 2013
            • 0 Attachment
              On 8/21/2013 6:28 PM, flo.gehrke wrote:> --- In
              ntb-clips@yahoogroups.com, Don <don@...> wrote:
              >>
              >> :Loop
              >> ^!InsertText ^$StrRandom(10;A..F0..9)$^P
              >> etc.
              >>
              >> Which would take about 40 seconds to generate 10000 unique codes of
              >> 10 characters each. They might also have more elegant solutions
              >> that would be faster ...
              >
              > Don,
              >
              > Inserting line by line makes it rather slow here. It's done in a
              second when first creating the list in the memory...
              >
              > ^!SetHintInfo Working...
              > ^!Set %Counter%=10000
              > :Loop
              > ^!Set %Str%=^$StrRandom(10;A..F0..9)$
              > ^!Append %List%=^%Str%^%NL%
              > ^!Dec %Counter%
              > ^!If ^%Counter% > 0 Loop
              > ^%List%
              > ^!ClearVariables
              >
              > Regards,
              > Flo

              Florian, Don,

              I only mention this because Burt admittedly hasn't done a lot of clipping.

              It's a fine clip and is extermely fast but additional line at the start
              might be useful, neater and furnish a discrete file of only generated
              numbers.

              ^!Menu File/New
              ^!SetHintInfo Working...
              ^!Set %Counter%=10000
              :Loop
              ^!Set %Str%=^$StrRandom(10;A..F0..9)$
              ^!Append %List%=^%Str%^%NL%
              ^!Dec %Counter%
              ^!If ^%Counter% > 0 Loop
              ^%List%
              ^!ClearVariables

              ···············································
              ¤• JD#.234 - ¤• SL.933/@1>4 - 13.08.22~00.01.27

              • Maybe It's True That Life Begins
              • At Fifty, But Everything Else Starts
              • To Wear Out, Fall Out, Or Spread Out.

              • --Phyllis Diller

              € hrs € hsavage € pobox € com
            • John Wallace
              Is there a clip that can backup or copy all the files that are open in NoteTab, like the ones in the quick list to a usb device? I have a lot of files in
              Message 6 of 6 , Aug 25, 2013
              • 0 Attachment
                Is there a clip that can backup or copy all the files that are 'open' in NoteTab, like the ones in the quick list to a usb device?

                I have a lot of files in quick list and all in hundreds of different locations/folders.
                I would like to be able to run a clip and have all of them copied to a usb memory stick.
                (instead of opening each and saving it to the stick)

                Thanks for any help.

                John Wallace
              Your message has been successfully submitted and would be delivered to recipients shortly.