Announcement

Collapse
No announcement yet.

Die roll

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Die roll

    What would be a good random for a die roll?? I made one long ago but i forget the commands needed.
    ran(5)+1

    ?

    ------------------
    Life without programming is pointless.

  • #2
    Code:
    x& = RND(1,6)

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


    • #3
      Thanks, but it keeps giving me the error of

      Error 414: ")" expected

      ?

      ------------------
      Life without programming is pointless.

      Comment


      • #4
        Lance's function is good for PB 3.5, but if you use an older version, you should use a function wrapper similar to this:
        Code:
        FUNCTION RndRange(BYVAL First AS LONG, BYVAL Last AS LONG) AS LONG
        ' Return a Random Long between First and Last
          FUNCTION = MIN%(last,first) + RND * ABS(Last-First)
        END FUNCTION
        
        'Call for die:
          value = RndRange(1, 6)
        regards,

        ------------------
        [email protected]
        :) IRC :)

        Comment


        • #5
          Thanks Ian.

          Folks, if you are not using the latest version of a PowerBASIC compiler, please make that fact known when posting questions (our clairvoyant is away due to unforseen circumstances!).

          Thanks!

          ------------------
          Lance
          PowerBASIC Support
          mailto:[email protected][email protected]</A>
          Lance
          mailto:[email protected]

          Comment


          • #6
            You are welcome Lance.
            This venue has helped me many times. I don't even have to ask the questions (and show how ignorant I really am ), because someone else always seems to find the hard parts first.
            Thanks,

            ------------------
            [email protected]
            :) IRC :)

            Comment

            Working...
            X