Jump to content

Stringsplit in "for each $var[$i]" & CreateLabel for every [$i]


Skorm92
 Share

Go to solution Solved by Skorm92,

Recommended Posts

So, Im trying to let my software create a label for each user found

Current Code:

$defaultfriendsize = "67"

        For $i = 1 To $onlinevriendraw[0]
            ;MsgBox($MB_SYSTEMMODAL, "test", "online: " & $onlinevriendraw[$i])
            MsgBox(64, "test2", $onlinevriendraw[$i])
            $usernumber = +1
            GUICtrlCreateLabel($onlinevriendraw[$i], 5, $usernumber*$defaultfriendsize, 195, 35)
        Next
EndIf

The software pulls the Username and Userid in a string (Username,1 - OtherUsername,2)

The msgbox puts out the retreived data fine, However when I want to create a label for each it creates them all on the same spot... (with the code above I hoped it would calculate a different position for each [$i] found)

Other than that, I wanted to split the Username from the ID by using stringsplit

For $i = 1 To $onlinevriendraw[0]
    $onlinevriend =  $onlinevriendraw[$i]
            For $i = 1 To $onlinevriend[0]
            $onlineuser = StringSplit($onlinevriend[$i], ",")
            MsgBox(64, "SplStr Test", $onlineuser[$i])
        Next

It only returns the first one, as in $onlinevriendraw[1]

 

How can I achive to create a unique label position for each user found, and also split their data by using "," to split?

Thank you very much in Advance!

Link to comment
Share on other sites

maybe this?

$defaultfriendsize = StringSplit("67", "") ; if you use ',', then StringSplit("67", ",")
        For $i = 1 To $onlinevriendraw[0]
            ;MsgBox($MB_SYSTEMMODAL, "test", "online: " & $onlinevriendraw[$i])
            MsgBox(64, "test2", $onlinevriendraw[$i])
            $usernumber = +1
            GUICtrlCreateLabel($onlinevriendraw[$i], 5, $usernumber*$defaultfriendsize, 195, 35)
        Next
EndIf
Edited by Detefon

Visit my repository

Link to comment
Share on other sites

We're going to need more than just a couple snippets of code.

A reproducer or your full script will help us help you out immensely. ;)

EDIT: As you can see, people are shooting from the hip. :)

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

 

maybe this?

$defaultfriendsize = StringSplit("67", "") ; if you use ',', then StringSplit("67", ",")
        For $i = 1 To $onlinevriendraw[0]
            ;MsgBox($MB_SYSTEMMODAL, "test", "online: " & $onlinevriendraw[$i])
            MsgBox(64, "test2", $onlinevriendraw[$i])
            $usernumber = +1
            GUICtrlCreateLabel($onlinevriendraw[$i], 5, $usernumber*$defaultfriendsize, 195, 35)
        Next
EndIf

 

GUICtrlCreateLabel($onlinevriendraw[$i], 5, $i*$defaultfriendsize, 195, 35)

BTW :

$usernumber = +1   =>  $usernumber += 1

 

Somewhat of a combination of these worked for me, Thank you!

 

For the split string,

The output given now is

First Label:                   Username, ID1

Label x pixels below it: Username2, ID2

I want to split the ID from the username to show with @CRLF below it.

So the end result would be:

First Label:                   Username, ID1

                                     ID1

Label x pixels below it: Username2

                                    ID2

But again, If I use stringsplit on "$onlinevriendraw[$i]" it only splits the first entry ([1]) and creates a label for it.

The others are not showing up.

Edited by Skorm92
Link to comment
Share on other sites

For $i = 1 To $onlinevriendraw[0]
    $onlinevriend =  $onlinevriendraw[$i]
            For $i = 1 To $onlinevriend[0]
            $onlineuser = StringSplit($onlinevriend[$i], ",")
            MsgBox(64, "SplStr Test", $onlineuser[$i])
        Next

If you have a loop within a loop, make sure the itterators are unique...the second For loop can use something like $j (or anothing NOT = $i)

Not a fix for your issue, just something that popped out at me.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Something like this ?

For $i = 1 To $onlinevriendraw[0]
      $onlineuser = StringSplit($onlinevriendraw[$i], ",")
     ; MsgBox(64, "SplStr Test", $onlineuser[1] & @crlf & $onlineuser[2])
      GUICtrlCreateLabel($onlineuser[1], 5, $i*70, 195, 35)
      GUICtrlCreateLabel($onlineuser[2], 5, $i*70+35, 195, 35)
Next
Edited by mikell
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

×
×
  • Create New...