Sign in to follow this  
Followers 0
Jack023

$label15 + $i

10 posts in this topic

Hey all,

Is it possible to do $label15 like + 1 ? so it will be $label16 after the do loop , so each time +1?

Else
        $day = $serverdayfinal
    Do
        $statistics = ""
        $oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
        $oHTTP.Open("GET", $statistics, 0)
        $oHTTP.Send()
        $txt = $oHTTP.Responsetext
        $strip1 = _StringStripChars($txt, '{"date "[bnr_clicksimpressionscomplioncrcpmol_nlnc,hquv}:')
        FileWrite("test1234.txt", $strip1)
        Local $fileopen = FileOpen("test1234.txt")

        $date = FileReadLine($fileopen, 4)
        $banner_clicks = FileReadLine($fileopen, 5)
        $banner_impressions = FileReadLine($fileopen, 6)
        $ctr = FileReadLine($fileopen, 8)
        $ecpm = FileReadLine($fileopen, 9)
        $totalbalance = FileReadLine($fileopen, 10)
        $total_clicks = FileReadLine($fileopen, 11)
        $error_impressions = FileReadLine($fileopen, 12)
        $totalhits = FileReadLine($fileopen, 13)
        $totalimpes = FileReadLine($fileopen, 14)
        $totalreq = FileReadLine($fileopen, 15)
        $videoclicks = FileReadLine($fileopen, 16)
        $video_impressions = FileReadLine($fileopen, 17)
        $video_test1 = FileReadLine($fileopen, 18)
        $video_test2 = FileReadLine($fileopen, 19)
        $video_test3 = FileReadLine($fileopen, 20)
        $video_t1 = StringTrimLeft($video_test1, 1)
        $video_t2 = StringTrimLeft($video_test2, 1)
        $video_t3 = StringTrimLeft($video_test3, 1)

        $date1 = GUICtrlSetData($Label15, $serveryearfinal & "-" & $servermonthfinal & "-" & $serverdayfinal)
        $req1 = GUICtrlSetData($Label19, $totalreq)
        $impres1 = GUICtrlSetData($Label23, $totalimpes)
        $clicks1 = GUICtrlSetData($Label27, $total_clicks)
        $ctr1 = GUICtrlSetData($Label31, $ctr & "%")
        $eCpm1 = GUICtrlSetData($Label35, "$" & $ecpm)
        $Earnings1 = GUICtrlSetData($Label39, "$" & $totalbalance)

        FileClose($fileopen)
        FileDelete("test1234.txt")

        $serverdayfinal -= 1
    Until $serverdayfinal = $day - 4

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

set it first, then use it in the command

 

For $i = 15 to 20

$Label = "$Label" & $i

msgbox (0, '' , $Label)

next
Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

What is the purpose to increment variables instead of saving the values to e.g. an array?

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

@UEZ I think he's trying to fill text boxes.

The for loop should work (or an Array as suggested), but you should look up the Execute function if you want to reference controls by generating a string of the same name.

Share this post


Link to post
Share on other sites

Well i think i can fix this tommorow, and at end when whole gui is done I'm going to ask how to improve my code to make it faster , thanks for the reply's!

Share this post


Link to post
Share on other sites

You have to use Assign and Eval:

 

For $i = 15 To 20
    Assign("Label" & $i, Random(0, 99, 1))
Next
For $i = 15 To 20
    ConsoleWrite(Eval("Label" & $i) & @LF)
Next
Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Got it working thanks ;)

I made arrays of the $labels so i would easily change it haha !

Thanks for the suggestions and help

Edited by Jack023

Share this post


Link to post
Share on other sites
but you should look up the Execute function if you want to reference controls by generating a string of the same name

 

 

@Spud - This single post is all I understand about execute  (ensuring the type of the resulting variable in other languages, and simply procedural in AutoIt). If you are feeling kind can you explain its role here?  Thank you.


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I think execute could be used almost interchangably with Eval in the example above, but I could be wrong. 

AFAIK you can use Execute to refer to a variable no matter what type it is...Object, Array, Control, etc.

In this very confusing example I use Execute to perform data extraction from dynamic/any size arrays.

;#include <Array.au3>

Local $arr[5]=["Never","Gonna","Give","You","Up"]
_DynEnumArray($arr)

Local $arr[6][2]=[["Penn", "Teller"],["Gilbert", "Sullivan"],["Sonny", "Cher"],["Stone", "Parker"],["Fischbacher", "Horn"],["Plant", "Page"]]
_DynEnumArray($arr)

Local $arr[2][3][2]=[[["All","Your"],["Base","Are"],["Belong","To Us"]],[["Is","This"],["The","Way"],["Back","Home"]]]
_DynEnumArray($arr)

Local $arr[1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][3]=[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[1,2,3]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
_DynEnumArray($arr)

Func _DynEnumArray($arr)
    Local $arrDims[1][2]=[["ElementIdx","ElementCount"]]   ;Create an Array to Track Dimensions and Elements
    For $x = 1 to UBound($arr,0)
        ReDim $arrDims[$x+1][2]
        $arrDims[$x][0]=0
        $arrDims[$x][1]=UBound($arr,$x)
    Next
    Do   ;Loop Through Array Elements
        $var = "$arr"
        For $x = 1 to UBound($arrDims)-1
            $var &= "[" & $arrDims[$x][0] & "]"
        Next
        ConsoleWrite($var & " " & Execute($var) & @CRLF)  ;Output Subscript and Value

        $arrDims[UBound($arrDims)-1][0] += 1   ;Increment Last Dimension Element
        For $y = UBound($arrDims)-2 To 1 Step -1   ;Increment Dimension Element
            If $arrDims[$y+1][0] = $arrDims[$y+1][1] Then
                $arrDims[$y+1][0]=0
                $arrDims[$y][0]+=1
            EndIf
        Next

    Until $arrDims[1][0]=$arrDims[1][1]
    Return ConsoleWrite(@CRLF)
EndFunc

I first learned about Execute >in this thread when I was dealing with using Object properties.

edit: spelling & changed variable inside func from Global to Local
Added 64 dimension array for fun.  *Note this causes known bug in Au3Check.

Edited by spudw2k
1 person likes this

Share this post


Link to post
Share on other sites

Thank you sir, a fine example.


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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