hexagon logo

How do I use a random number generator?

I would like to create a random number. I have tried using the RND command but it returns a value of zero.

Has anyone tried to create a random number and assign it to a variable in PCDMIS?

Thanks
Parents
  • Can you explain how the If-Then block beginning with "If Not Var is Nothing..." Works?


    Var is assigned as a copy of the PC-DMIS variable "RND" - if that variable name doesn't exist in your program, this code will not create it, but give the error message that the variable can not be found.

    If the name is found, Var gets a new random value between 0.000 and 0.999... from RND(1), and then this new value is sent back to the PC-DMIS variable.

    What is the variable "I" being declared for?


    Just to check that you are actually reading the code Slight smile In other words - I haven't the faintest idea, must be a reminiscence of something else I tried.
Reply
  • Can you explain how the If-Then block beginning with "If Not Var is Nothing..." Works?


    Var is assigned as a copy of the PC-DMIS variable "RND" - if that variable name doesn't exist in your program, this code will not create it, but give the error message that the variable can not be found.

    If the name is found, Var gets a new random value between 0.000 and 0.999... from RND(1), and then this new value is sent back to the PC-DMIS variable.

    What is the variable "I" being declared for?


    Just to check that you are actually reading the code Slight smile In other words - I haven't the faintest idea, must be a reminiscence of something else I tried.
Children
No Data