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

[Clip] Re: Single Use Random Numbers

Expand Messages
  • Charles M. Raine
    Hi Jody and All: The following clip will generate single occurrence random numbers. As it is written, it does NOT save the numbers used to a file, but that
    Message 1 of 4 , Nov 29, 1999
    • 0 Attachment
      Hi Jody and All:

      The following clip will generate single occurrence random numbers. As it is
      written, it does NOT save the numbers used to a file, but that could be
      easily changed. It does slow down a bit when the used list gets nearer to
      completion but nothing that would be extremely bothersome.

      This clip would require further modification to store the Range value in
      an .ini file variable, in order to have it retrievable, to be able to
      support recurring random number selections.

      This clip basically only demonstrates a method of single use random number
      selection. Without all the comments, it is really a simple short clip which
      some of you may find useful.

      ---------< start clip >---------
      H="Single Use Random Numbers"
      ; Charles M. Raine <rainec@...>
      ; 11/29/1999, 01:03:42 PM
      ^!ClearVariables
      ^!SetListDelimiter ^%nl%
      ^!Set %range%=^?[Enter Number Range 1 to =]
      ; Initialize list.
      ^!Set %list%=^%nl%
      ; Set maximum number of digits. Example - 100 requires 3 digits.
      ^!Set %digits%=^$StrSize("^%range%")$

      :Again
      ; The following select a random # between 1 and %range%
      ^!Set %RanNum%=^$Calc(1+int(^$Calc(rnd(^%range%))$))$
      ; The following inserts the necessary leading zeroes.
      ; --- begin long line ---
      ^!Set
      %RanNum%=^$StrFill("0";^$Calc(^%digits%-^$StrSize("^%RanNum%")$;0)$)$^%RanNum%
      ; --- end long line ---
      ; The following checks if number already selected and select again if so.
      ^!If ^$StrCount("^%RanNum%";"^%List%";no;yes)$=1 Again
      ; Appends new number to the list.
      ^!Append %list%=^%RanNum%^%nl%
      ; Displays number selected and the list used so far.
      ^!Info Next Random Number^p^%RanNum%^pList Used^$StrSort("^%list%";n;y;n)$
      ; If count of numbers in list greater than the range, skip else do again.
      ^!If ^$StrCount("^%nl%";"^%list%";no;no)$>^%range% Skip
      ^!GoTo Again
      ; Display completion message, and list used.
      ^!Info The list is Completed^$StrSort("^%list%";n;y;n)$
      ---------< end clip >-----------
      |----< Copy between wrappers >----|
      | right click over the clipbook |
      | and choose "Add from Clipboard" |
      |---------------------------------|

      Charlie.

      Charles M. Raine Home Page: http://www.escape.ca/~rainec
      Phone (204) 895-0940 ICQ # 300058
      Winnipeg, Manitoba, Canada
    • Doc
      charles m. raine wrote: original article:http://www.egroups.com/group/ntb-clips/?start=2100 ... Hey Charlie, This clip won t shut off
      Message 2 of 4 , Nov 30, 1999
      • 0 Attachment
        "charles m. raine" <raine-@...> wrote:
        original article:http://www.egroups.com/group/ntb-clips/?start=2100
        > Hi Jody and All:
        >
        > The following clip will generate single occurrence random numbers.
        > ---------< start clip >---------
        > H="Single Use Random Numbers"
        > ; Charles M. Raine <rainec@...>
        > ; 11/29/1999, 01:03:42 PM

        Hey Charlie,
        This clip won't "shut off" till it has used all the numbers available
        in the range given in the pop-up.
        Really rough if you try 1-1000 as I did to play with it.
        Won't quit till "list complete" is given.
        Was this susposed to be this way? Could you add a line to cancel it,
        and just hold it's place till the sequence is finishes, or better just
        don't use a big range?
        Peace,
        doc
      • Jody
        Hi Doc, ... Anytime you want a Clip to stop (like if it is in a loop) simply get a big hammer no, just press Ctrl+Alt. If an Info box, Promt, etc. is
        Message 3 of 4 , Nov 30, 1999
        • 0 Attachment
          Hi Doc,

          >> H="Single Use Random Numbers"
          >> ; Charles M. Raine <rainec@...>

          > This clip won't "shut off" till it has used all the numbers
          > available in the range given in the pop-up.

          Anytime you want a Clip to stop (like if it is in a loop) simply
          get a big hammer <g> no, just press Ctrl+Alt. If an Info box,
          Promt, etc. is showing just press Ctrl+Alt and press OK or
          whatever the button is to go on.

          ; The following checks if number already selected and select again if so.
          ^!If ^$StrCount("^%RanNum%";"^%List%";no;yes)$=1 Again

          Thanks Charles - it never occured to me.

          cya,
          Jody

          If'n u right me bak, rite reel slow,
          cuz this hillbille don't reed reel fast!

          Sojourners of the Lord
          http://www.sureword.com/sojourner
          Clean-Funnies Mailing List
          mailto:CF@...?subject=subscribe
        • Doc
          jody wrote: original article:http://www.egroups.com/group/ntb-clips/?start=2124 ... Jody, Charlie filled me in on this too, thanks! Guess I
          Message 4 of 4 , Dec 1, 1999
          • 0 Attachment
            jody <kjb161-@...> wrote:
            original article:http://www.egroups.com/group/ntb-clips/?start=2124
            > Hi Doc,
            > Anytime you want a Clip to stop (like if it is in a loop) simply
            > get a big hammer <g> no, just press Ctrl+Alt.
            Jody,
            Charlie filled me in on this too, thanks!
            Guess I "really should" spend the time to read the "entire" help file
            for ntb, but I just cannot seem to force myself into doing so. Guess
            I'll just have to force myself ;-(
            Least ways I won't feel so dumb by not knowing the apparently "obvious"
            ways it works. LOL
            I'm getting some real help from this group, thanks to everyone out
            there that contributes.
            Peace,
            doc

            Always did say if I can't laugh at myself, I shouldn't laugh at others.
            I find me laughing at "me" a lot
          Your message has been successfully submitted and would be delivered to recipients shortly.