Jump to content

$label15 + $i


Jack023
 Share

Recommended Posts

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
Link to comment
Share on other sites

set it first, then use it in the command

 

For $i = 15 to 20

$Label = "$Label" & $i

msgbox (0, '' , $Label)

next
Edited by boththose

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

Link to comment
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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
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.

Link to comment
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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
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.

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

Link to comment
Share on other sites

I think execute could be used almost interchangeably 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 any size array.

Local $arr[]=["Never","Gonna","Give","You","Up"]
ConsoleWrite(_DynEnumArray($arr) & @CRLF)

Local $arr[][]=[["Penn", "Teller"],["Gilbert", "Sullivan"],["Sonny", "Cher"],["Stone", "Parker"],["Fischbacher", "Horn"],["Plant", "Page"]]
ConsoleWrite(_DynEnumArray($arr) & @CRLF)

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

Func _DynEnumArray(ByRef $array)
    If Not IsArray($array) then Return SetError(1,0,"") ;Make sure parameter IsArray
    Local $aDims[1][2]=[["ElementIdx","ElementCount"]]   ;Create an array to track Source array dimensions and elements
    Local $sArrayContents = ""   ;Create empty result string for Source array contents
    For $iX = 1 to UBound($array,0)   ;Get Source array size and save in tracking array
        ReDim $aDims[$iX+1][2]
        $aDims[$iX][0]=0
        $aDims[$iX][1]=UBound($array,$iX)
    Next
    Do   ;Loop through Source array elements
        $var = ""
        For $iX = 1 to UBound($aDims)-1   ;Build array dimension string
            $var &= "[" & $aDims[$iX][0] & "]"
        Next
        $sArrayContents &= $var & " " & Execute("$array" & $var) & @CRLF  ;Evaluate array dimension string and append contents to result string
        $aDims[UBound($aDims)-1][0] += 1   ;Increment last dimension element in tracking array
        For $iY = UBound($aDims)-2 To 1 Step -1   ;Increment dimension element in tracking array
            If $aDims[$iY+1][0] = $aDims[$iY+1][1] Then
                $aDims[$iY+1][0]=0
                $aDims[$iY][0]+=1
            EndIf
        Next
    Until $aDims[1][0]=$aDims[1][1]   ;Loop until Source array element enumeration is complete
    Return $sArrayContents
EndFunc

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

Edited by spudw2k
updated example for clarity and efficiency
Link to comment
Share on other sites

Thank you sir, a fine example.

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...