Question About Getting New Random Number Everytime



  • Hi

    So my script is using RANDOM_NUMBER variable which randoms between 1-5

    now I'm not ending the thread, I'm just calling SET LABEL and MOVE to LABEL however every time it calls the LABEL it always used the same RANDOM_NUMBER variable which it generated at first run of the thread. Now how can I get new RANDOM_NUMBER variable every time I call it?

    Thank you



  • Probably need to put generate random number inside
    or between Set Label and Move to Label actions.
    Seems that you only call already generated random number
    between those 2 statements so its always same because actual
    generation is already done before Set Label.



  • @gag said in Question About Getting New Random Number Everytime:

    Probably need to put generate random number inside
    or between Set Label and Move to Label actions.
    Seems that you only call already generated random number
    between those 2 statements so its always same because actual
    generation is already done before Set Label.

    The random_number variable is created and generated inside "Set Label" and "Move to Label" actions, that's why I'm not sure what I'm doing wrong :(

    When I'm doing it on "Recording Mode" step by step, I can see in the LOG that it generated a new random_number variable everytime, however when I "Run" it it only generates SAME random_number variable.



  • This post is deleted!




  • @stephenperry18 said in Question About Getting New Random Number Everytime:

    The random_number variable is created and generated inside "Set Label" and "Move to Label" actions, that's why I'm not sure what I'm doing wrong :(
    When I'm doing it on "Recording Mode" step by step, I can see in the LOG that it generated a new random_number variable everytime, however when I "Run" it it only generates SAME random_number variable.

    Can you post a sample script?



  • And why dont you use a loop instead os label?
    Dont know how things are moving now but earlier
    bas support recomended using loops over labels.

    Im always using loops rarely labels, maybe labels work
    a bit differently and are not suitable for every task.



  • @gag said in Question About Getting New Random Number Everytime:

    And why dont you use a loop instead os label?
    Dont know how things are moving now but earlier
    bas support recomended using loops over labels.

    Im always using loops rarely labels, maybe labels work
    a bit differently and are not suitable for every task.

    Well I figured it out but I dont know if this is the best solution for it.

    I used Global Variables to forced it to change everytime, When I used local variables it not working.

    Also I'm using labels because everytime it fails to load the URL it will go to back to Label. I don't know if you can use loops, I know you can use WHILE loop but its easy to use Labels hehe



  • FOREACH, FOR, IF loops are perfectly suitable if you put error handling into your script (which you should).

    Global variables are shared across all threads, while the local variable is only within the current thread. If you request a value at the beginning of your thread, it will remain the same during the whole lifespan of that thread unless otherwise specified. For example, you could generate a few of them in a loop, save to list, then you have multiple random numbers to choose from.