Sign in to follow this  
Followers 0
Skorm92

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

8 posts in this topic

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!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

BTW :

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

Edited by mikell

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

 

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

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

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

Turned out to be the solution, Thank you for the support!

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

  • Similar Content

    • kneze
      By kneze
      Hi
      i try to read Wlan Profiles from local Computer. First Step Command Prompt: netsh wlan show profiles >> C:\temp\test\wlan.txt.
      Second Step (here's a sample script to find a solution for my problem. Script read each line of wlan.txt and Display Name of Wireless Connection which i have set up in the past.  If i edit wlan.txt to wlan - sample.txt script works. wlan.txt containsline without : so i get error message. How can i read only lines beginning with All User Profile so i can use original file wlan.txt which i crate in the command prompt with: netsh wlan show profiles >> C:\temp\test\wlan.txt ?
      Thanks for any suggestions.
      Kneze
      $Form1 = GUICreate("Form1", 374, 268, 892, 512) $Button1 = GUICtrlCreateButton("button", 145, 35, 75, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $file = "C:\temp\test\wlan.txt" FileOpen($file, 0) For $i = 1 to _FileCountLines($file) $line = FileReadLine($file, $i) $after = StringSplit($line, ":")[2] MsgBox(262144, "Result", $after, 0) Next FileClose($file) EndSwitch WEnd  
       
      wlan - sample.txt
      wlan.txt
    • blemas
      By blemas
      The McAfee return for AV defs per "C:\Progra~1\Common~1\McAfee\SystemCore\csscan.exe -Versions" is ...
      CommonShell Command Line Scanner Lite (VSCORE.15.5.0.3960)
          Engine version: 5800.7501
          DAT version:    8450.0
          Time required:  15 milliseconds
      I want to isolate the actual DAT version as "8450.0".  There may be an easier way to get the DAT Version via other McAfee or registry methods but essentially I just want to know how to parse a string at a character or @CRLF into two separate strings for further parsing. Example:
      $string = "Name=Microsoft Windows 10 Professional |C:\windows|\Device\Harddisk0\Partition2"
      Parse into $var1 = "Name" & $var2 = "Microsoft Windows 10 Professional |C:\windows|\Device\Harddisk0\Partition2"
      From there I'd like to parse $var2 at "|" into  $var3 = "Microsoft Windows 10 Professional" and $var4 "C:\windows|\Device\Harddisk0\Partition2"
       
       
       
       
       
    • crushyna
      By crushyna
      Hello everyone!

      I've encountered a strange problem while adding files (or rather file names) to a ListView.
      Mechanics are simple:
      1. Select files to add (FileOpenDialog + Multiselect)
      2. Split selected string (filepath) into array (StringSplit)
      3. File names appear on ListView (GUICtrlCreateListViewItem)

      Writing starts from second array (since 0 is array size, and 1 is filepath).
      Problem occurs when I try to add one file. Then, no filenames are added.
      As far as I know, selecting one file generates only 2 strings (0 and 1) to split, therefore no string is written into ListView.
       
      Is there any way / workaround to make this thing work properly?

      Some code here:
      While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idAddTest $sMessage = "Select test cases to load:" $sFileOpenDialog = FileOpenDialog($sMessage, @WorkingDir & "\data\tests\", "All (*.*)", $FD_FILEMUSTEXIST & $FD_MULTISELECT) If @error Then MsgBox($MB_SYSTEMMODAL, "", "No test(s) were selected.") FileChangeDir(@ScriptDir) Else FileChangeDir(@ScriptDir) $aFileList = StringSplit($sFileOpenDialog, "|", @CRLF) For $i = 2 to $aFileList[0] MsgBox( 0, "test", $aFileList[$i]) ;just for testing purposes GUICtrlCreateListViewItem($aFileList[$i], $idTestCaseList) Next EndIf EndSwitch WEnd  
      And nothing more spectacular from ListView side:
      Global $idTestCaseList = GUICtrlCreateListView("List of Tests ", 24, 24, 225, 502, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) GUICtrlSetTip(-1, "List of test cases."& @CRLF &"Hold CTRL to select multiple lines.")  
      Any help appreciated!
    • ur
      By ur
      How to use regular expressions in StringSplit and StringInStr
    • meows
      By meows
      12 where is a simple StringSplit at delimeter example please?
      Copy to clipboard #include <MsgBoxConstants.au3> Example() Func Example() Local $aDays = StringSplit("Mon,Tues,Wed,Thur,Fri,Sat,Sun", ",") ; Split the string of days using the delimeter "," and the default flag value. #cs The array returned will contain the following values: $aDays[1] = "Mon" $aDays[2] = "Tues" $aDays[3] = "Wed" ... $aDays[7] = "Sun" #ce For $i = 1 To $aDays[0] ; Loop through the array returned by StringSplit to display the individual values. MsgBox($MB_SYSTEMMODAL, "", "$aDays[" & $i & "] - " & $aDays[$i]) Next EndFunc ;==>Example I went through Datatypes  Operators Conditional Obj Statements I had high hopes for Obj statements but it was a waste so I went to Google, Yahoo, Yandex, Sohu, and Baidu.
      All I learned is that Baidu has more mobile customers than the US has people!
      I need to separate this string at each to enter into a database
      BabyMAKERrootCIMV2:Win32_Service.Name="Apache2.4"BabyMAKERrootCIMV2:Win32_Service.Name="Apache2.4"BabyMAKERrootCIMV2:Win32_Service.Name="AppIDSvc"BabyMAKERrootCIMV2:Win32_Service.Name="AppIDSvc"BabyMAKERrootCIMV2:Win32_Service.Name="AppIDSvc"BabyMAKERrootCIMV2:Win32_Service.Name="Appinfo"BabyMAKERrootCIMV2:Win32_Service.Name="Appinfo"BabyMAKERrootCIMV2:Win32_Service.Name="asComSvc"

       
      ALL three examples are ARRAYS....  If I wanted a tree I go to the beach and catch a fish and plant it
      deep with lots of tree food. Then water it daily waiting for the day the fish turns into a tree.
      Is it a joke? I did a search array in the help(Help control 6.1) file for array and got NO RESULTS.
      I tried the trim examples and they worked great but I have no way of knowing how long each string will be at the delimeter
      so where is a simple StringSplit at delimeter example please? I know I had to miss it.