Results 1 to 3 of 3

Random command and variables

This is a discussion on Random command and variables within the AutoHotKey Help/Training forums, part of the General/Help category; I have 17 variables. named var1-var17. I also have a random code generating a number between one and 17. How ...

  1. #1
    micaheljcaboose is offline Real name: Shawn
    Join Date
    Jun 2009
    Location
    PDX
    Posts
    220

    Default Random command and variables

    I have 17 variables. named var1-var17. I also have a random code generating a number between one and 17.
    How do I get the random generators number (%rand%) into a variable?

    I tried %var%rand%% but I got and error.

    Does anyone know? Or another way I could get a random to choose a variable?
    Want to make money uploading files? --------------> Click here
    Tell me if you sign up under my link, I will show you my method.
    Make money from Twitter! -----------------------------> Click here
    Earn $2 a day viewing ads!

  2.   Alt These ads help cover server costs and such.


  3. #2
    Seatbelt99's Avatar
    Seatbelt99 is offline Site Owner
    Join Date
    Apr 2008
    Location
    Somewhere North of you
    Posts
    3,431

    Default

    so you want each variable (var1 - var 17) assigned a random number between 1 and 17?

    If so, I think this would work but its untested:

    loop, 17
    {
    Random, Rand, 1, 17
    Var%A_Index% = %Rand%
    }

    I'll look again after I get back from dropping kids off at school if this does not work.

  4. #3
    micaheljcaboose is offline Real name: Shawn
    Join Date
    Jun 2009
    Location
    PDX
    Posts
    220

    Default

    No. I'm trying to get it to randomly select a variable to display. Here's my code:

    Code:
    var1= MJ8TR-DXBRH-46Q47-9GQ3K-V3X83
    var2= B832G-86G87-W9F4J-2P2BG-HPJQB
    var3= B643T-D6RJ6-RGVDV-944JC-77B4T
    var4= Q7YQ2-BRYHK-WBP86-7KQTV-MJWBM
    var5= PTPW8-GYK93-746CW-G7M8D-RT4MQ
    var6= MY6V4-CB336-Y69WP-X2TQB-3Q2V8
    var7= XP637-TFRYV-X77VJ-YD4TW-X7DRW
    var8= B34P3-M433W-QMR44-3MBWP-CVPWQ
    var9= J4GG6-7M3H2-JRQXG-CHY2X-BVY2G
    var10= F3VFY-BJ2C6-992CR-284WM-4HY2J
    var11= DB2HG-FGYYV-FCRTG-92733-YJWCM
    var12= P48CB-WP2W7-YVFG9-TV9TY-TFB2T
    var13= H34T9-MPTWJ-P34TV-RK22K-77Y2Y
    var14= BJY2R-KHC6Y-9FG87-VVHWB-7WWC3
    var15= GG4XR-G6FJB-82TQY-TM4FX-287GY
    var16= B2YJB-FM7W8-QGFXV-47HR8-K9RQD
    var17= C6974-KX34T-JCFMX-H9TDR-VWWDG
    
    
    Random, rand, 1, 1
    
    
    MsgBox, 1, , Press OK to generate your Microsoft Points code!
    IfMsgBox, Cancel
        return
    
    Sleep, 1000
    MsgBox ,1, , Testing %var%rand%% ;Error is here, I want the number in my variable to be the random.

    Yes I know. Simple, horrible code.
    Want to make money uploading files? --------------> Click here
    Tell me if you sign up under my link, I will show you my method.
    Make money from Twitter! -----------------------------> Click here
    Earn $2 a day viewing ads!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Facebook Bots | Admin Forum