Sign in to follow this  
Followers 0
JD777

Need help with changing a variable with another variable

6 posts in this topic

Case $ca_gen_Button1
    $clk = 0
    
    Do
        $clk = $clk + 1 
        GUICtrlSetData("$ca_inkey_in" & $clk,random_x(8))   <-------- I'm having a problem with this
    Until $clk = 4

I think this is my first post so hello everyone.I'm trying to write a script and am having a problem with this part of the script.

What i'm trying to do is this:

GUICtrlSetData($ca_inkey_in1,random_x(8))
GUICtrlSetData($ca_inkey_in2,random_x(8))
GUICtrlSetData($ca_inkey_in3,random_x(8))
GUICtrlSetData($ca_inkey_in4,random_x(8))

GUICtrlSetData($ca_inkey_in5,random_x(4))

Instead of writing all of this I wanted to know how to do this:

("$ca_inkey_in" & $clk) = $ca_inkey_in1 or 2 or 3 or 4

I hope someone can help or understand what I'm saying.Thanks in advance

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Ehh, I'm not exactly sure what it is you want but from what I understood, you're looking for something like this?

Case $ca_gen_Button1
    $clk = 0
    
    Do
        $clk = $clk + 1 
        GUICtrlSetData("$ca_inkey_in1" & $clk,Random(1, 8)) 
        GUICtrlSetData("$ca_inkey_in2" & $clk,Random(1, 8))
        GUICtrlSetData("$ca_inkey_in3" & $clk,Random(1, 8))
        GUICtrlSetData("$ca_inkey_in4" & $clk,Random(1, 8))
        GUICtrlSetData("$ca_inkey_in5" & $clk,Random(1, 4))
    Until $clk = 4
Edited by RyGoTypE

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Case $ca_gen_Button1
    $clk = 0
    
    Do
        $clk = $clk + 1 
        GUICtrlSetData("$ca_inkey_in" & $clk,random_x(8))   <-------- I'm having a problem with this
    Until $clk = 4

I think this is my first post so hello everyone.I'm trying to write a script and am having a problem with this part of the script.

What i'm trying to do is this:

GUICtrlSetData($ca_inkey_in1,random_x(8))
GUICtrlSetData($ca_inkey_in2,random_x(8))
GUICtrlSetData($ca_inkey_in3,random_x(8))
GUICtrlSetData($ca_inkey_in4,random_x(8))

GUICtrlSetData($ca_inkey_in5,random_x(4))

Instead of writing all of this I wanted to know how to do this:

("$ca_inkey_in" & $clk) = $ca_inkey_in1 or 2 or 3 or 4

I hope someone can help or understand what I'm saying.Thanks in advance

If I understand correctly then you want this

Case $ca_gen_Button1
    $clk = 0
    
    Do
        $clk = $clk + 1 
        Assign("ca_inkey_in" & $clk,random_x(8))    <-------- I'm having a problem with this
    Until $clk = 4
Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

If I understand correctly then you want this

Case $ca_gen_Button1

$clk = 0

Do

$clk = $clk + 1

GUICtrlSetData("$ca_inkey_in" & $clk,random_x(8)) <-------- I'm having a problem with this

Until $clk = 4

yes thats the part i'm having problems with I want to use this ("ca_inkey_in" & $clk) as a variable that looks like

$ca_inkey_inX with X being $clk so that this is result:

$ca_inkey_in1

$ca_inkey_in2

$ca_inkey_in3

$ca_inkey_in4

etc...

Thanks

Edited by JD777

Share this post


Link to post
Share on other sites

Oh yea I should have cleared this up:

Case $ca_gen_Button1
    $clk = 0
    
Do
    $clk = $clk + 1
    GUICtrlSetData("$ca_inkey_in" & $clk, random_x(8))   <---------random_x(8) is a function my problem is "$ca_inkey_in" & $clk
    
Until $clk = 4


Func random_x($fgennum = 0)
    $genkeyout = 0
    $genkey = 0
    
    For $i = 1 To $fgennum
If Random() < 0.5 Then
    $genkey2 = Random(0, 10, 1)
Else
    $genkey2 = Chr(Random(Asc("a"), Asc("z"), 1))
Endif
        $genkey = $genkey & $genkey2
    Next 
    $genkeyout = StringRight($genkey, $fgennum)
    Return $genkeyout
    
EndFunc

Share this post


Link to post
Share on other sites

Thanks all I found out how to do this because martin pointed me in the right direction sort of.Heres what I did incase anyone else is interested:

$clk = 0
    
    Do
        $clk = $clk + 1

            --------------->GUICtrlSetData(Eval("ca_inkey_in" & $clk),random_x(8))   <---------------------                       

    Until $clk = 4

Func random_x($fgennum = 0)
    $genkeyout = 0
    $genkey = 0
    
    For $i = 1 To $fgennum
If Random() < 0.5 Then
    $genkey2 = Random(0, 10, 1)
Else
    $genkey2 = Chr(Random(Asc("a"), Asc("z"), 1))
Endif
        $genkey = $genkey & $genkey2
    Next 
    $genkeyout = StringRight($genkey, $fgennum)
    Return $genkeyout
    
EndFunc

This is going to help me tremendously in the future.Thanks again

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0