pintas Posted May 15, 2011 Share Posted May 15, 2011 Can i read between strings in different lines? For example: $Numbers "1" => array("name" => "number 1", "2" => array("name" => "number 2", "3" => array("name" => "number 3", $Letters "1" => array("name" => "Letter 1", "2" => array("name" => "Letter 2", "3" => array("name" => "Letter 3", How can i get the reading all the contents of the second string (Letters)? I'm trying to put an example like this in a GUICtrlCreateCombo, but i'm finding it very difficult. Can anyone point me in the right direction please? Link to comment Share on other sites More sharing options...
martin Posted May 15, 2011 Share Posted May 15, 2011 Can i read between strings in different lines? For example: $Numbers "1" => array("name" => "number 1", "2" => array("name" => "number 2", "3" => array("name" => "number 3", $Letters "1" => array("name" => "Letter 1", "2" => array("name" => "Letter 2", "3" => array("name" => "Letter 3", How can i get the reading all the contents of the second string (Letters)? I'm trying to put an example like this in a GUICtrlCreateCombo, but i'm finding it very difficult. Can anyone point me in the right direction please? I would need a better explanation of what you are trying to do before I could make any sensible suggestions, so can you try to explain what you want to do in a more detailed way? What is the text you showed? Is it the contents of a file? Is what you posted something that you read from a file? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
pintas Posted May 15, 2011 Author Share Posted May 15, 2011 (edited) I would need a better explanation of what you are trying to do before I could make any sensible suggestions, so can you try to explain what you want to do in a more detailed way? What is the text you showed? Is it the contents of a file? Is what you posted something that you read from a file? You are right, i didn't explain myself very well. I have a file with several users, like this: $Numbers "1" => array("name" => "number 1"), "2" => array("name" => "number 2"), "3" => array("name" => "number 3"), $Users "1" => array("name" => "John"), "2" => array("name" => "Patrick"), "3" => array("name" => "Susan"), I want to extract the user names to put in a combobox (with a GUICtrlCreateCombo), so the combobox shows John, Patrick and Susan in it. Is this possible? Thanks for your reply. Edited May 15, 2011 by pintas Link to comment Share on other sites More sharing options...
martin Posted May 15, 2011 Share Posted May 15, 2011 You are right, i didn't explain myself very well. I have a file with several users, like this: $Numbers "1" => array("name" => "number 1"), "2" => array("name" => "number 2"), "3" => array("name" => "number 3"), $Users "1" => array("name" => "John"), "2" => array("name" => "Patrick"), "3" => array("name" => "Susan"), I want to extract the user names to put in a combobox (with a GUICtrlCreateCombo), so the combobox shows John, Patrick and Susan in it. Is this possible? Thanks for your reply. Usually I don't write anything for people who have showed no effort at writing any code, or showed no evidence of it. In general I expect many others do the same, so for faster help, and to help yourself learn faster, try something yourself and show what you have tried if it doesn't work and you don't understand why not. expandcollapse popup#cs numbernames.txt $Numbers "1" => array("name" => "number 1"), "2" => array("name" => "number 2"), "3" => array("name" => "number 3"), $Users "1" => array("name" => "John"), "2" => array("name" => "Patrick"), "3" => array("name" => "Susan"), #ce ;method 1, but stringregexpr is not th esimplest to understand #include <array.au3> $slist = fileread("numbernames.txt");read the whole file to one long string $slist = stringtrimleft($slist,stringinstr($slist,"$Users") + stringlen("$Users"));get rid of anything before $Users $res = stringregexp($slist,'(?:\"\d*\" => array\(\"name\" => \")(.*)(?:\")',3) if isarray($res) then _ArrayDisplay($res) ;method 2 other ways are simpler but often longer #include <file.au3> Local $alist _filereadtoarray("numbernames.txt",$alist) $res = '' if isarray($alist) and $alist[0] > 0 Then $il = 1 $line = '' while $line <> "$Users" $line = stringstripws($alist[$il],3) $il += 1 if $il > $alist[0] then ExitLoop wend for $n = $il - 1 to $alist[0] $p = stringtrimleft($alist[$n],stringinstr($alist[$n],'array("name" => "') + stringlen('array("name" => "') - 1) $p = stringreplace($p,'"),','') $res &= $p & @CRLF Next MsgBox(262144,"reult",$res) EndIf There are many other ways. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
pintas Posted May 15, 2011 Author Share Posted May 15, 2011 $res = stringregexp($slist,'(?:\"\d*\" => array\(\"name\" => \")(.*)(?:\")',3)Yeah, you lost me there But the rest i fully understand.I've search for string related commands in AutoIt, but i didn't go very far.But i did try before i asked any help, and searched the forums, but found nothing working for what i wanted.Thank you so much, I can move on now.Great help! Link to comment Share on other sites More sharing options...
pintas Posted May 15, 2011 Author Share Posted May 15, 2011 Yeah, you lost me there But the rest i fully understand.I've search for string related commands in AutoIt, but i didn't go very far.But i did try before i asked any help, and searched the forums, but found nothing working for what i wanted.Thank you so much, I can move on now.Great help!I'm still trying to understand with AutoIt help how you did to find the end of the name lol Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 15, 2011 Moderators Share Posted May 15, 2011 (edited) Maybe it would have simpler to understand using Martins first method if it looked something like: ;method 1, but stringregexpr is not th esimplest to understand #include <String.au3> #include <array.au3> $slist = fileread("numbernames.txt");read the whole file to one long string $slist = stringtrimleft($slist,stringinstr($slist,"$Users") + stringlen("$Users"));get rid of anything before $Users $res = _StringBetween($slist, '=> array("name" => "', '")') if isarray($res) then _ArrayDisplay($res) Edited May 15, 2011 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
pintas Posted May 15, 2011 Author Share Posted May 15, 2011 Maybe it would have simpler to understand using Martins first method if it looked something like: ;method 1, but stringregexpr is not th esimplest to understand #include <String.au3> #include <array.au3> $slist = fileread("numbernames.txt");read the whole file to one long string $slist = stringtrimleft($slist,stringinstr($slist,"$Users") + stringlen("$Users"));get rid of anything before $Users $res = _StringBetween($slist, '=> array("name" => "', '")') if isarray($res) then _ArrayDisplay($res) Nice and easy. Damn... i've used that _StringBetween some months ago, i completely forgot. But then again all my AutoIt sources were accidentally deleted... Thanks man! Very helpful! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now