Sign in to follow this  
Followers 0
JohnBailey

More Efficient

3 posts in this topic

Is there a more efficient way to write the following script. The problem I have is the var name in the GUICtrlRead, so I couldn't think of a way to increment the number at the end of $Checkbox_ <---

; ----  days to run
    Global $daystoRunExport[8] ;0 to 7 = 8
    $daystoRunExport[0] = 7
    ;Monday
    If GUICtrlRead($Checkbox1) = 4 Then
        $daystoRunExport[1] = "1"
    Else
        $daystoRunExport[1] = "0"
    EndIf
    ;Tuesday
    If GUICtrlRead($Checkbox2) = 4 Then
        $daystoRunExport[2] = " 1"
    Else
        $daystoRunExport[2] = " 0"
    EndIf
    ;Wednesday
    If GUICtrlRead($Checkbox3) = 4 Then
        $daystoRunExport[3] = " 1"
    Else
        $daystoRunExport[3] = " 0"
    EndIf
    If GUICtrlRead($Checkbox4) = 4 Then
        $daystoRunExport[4] = " 1"
    Else
        $daystoRunExport[4] = " 0"
    EndIf
    If GUICtrlRead($Checkbox5) = 4 Then
        $daystoRunExport[5] = " 1"
    Else
        $daystoRunExport[5] = " 0"
    EndIf
    If GUICtrlRead($Checkbox6) = 4 Then
        $daystoRunExport[6] = " 1"
    Else
        $daystoRunExport[6] = " 0"
    EndIf
    If GUICtrlRead($Checkbox7) = 4 Then
        $daystoRunExport[7] = " 1"
    Else
        $daystoRunExport[7] = " 0"
    EndIf
    
    $daysAlphatoBinary = "" 
    For $i = 1 to $daystoRunExport[0]
        $daysAlphatoBinary &= $daystoRunExport[$i]
    Next
    
    ;saving
    $b = GUICtrlRead($ProfileName) &" | "&$newRunTime&" | "&$newDate&" | "&$daysAlphatoBinary&" | "& GUICtrlRead($Input1)

A decision is a powerful thing

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

for $i = 1 to 7

If GUICtrlRead(eval("Checkbox"&$i)) = 4 Then

$daystoRunExport[$i] = "1"

Else

$daystoRunExport[$i] = "0"

EndIf

next

Edited by lod3n

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

for $i = 1 to 7

If GUICtrlRead(eval("Checkbox"&$i)) = 4 Then

$daystoRunExport[$i] = "1"

Else

$daystoRunExport[$i] = "0"

EndIf

next

Oh glorious day! Eval great idea! thanks lod3n! :whistle:

A decision is a powerful thing

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