MrVietA2 Posted December 19, 2011 Share Posted December 19, 2011 (edited) Hi ! I would like to get text from the random line to the last line of a text file. My example of text file here : Hello My name is Viet I'm a student I love autoit In this example, I would like to get text from the line 2 to the last line (line 5), so it's like this : My name is Viet I'm a student I love autoit Could you tell me how can I do it ? Thanks so much ! Edited December 19, 2011 by MrVietA2 Link to comment Share on other sites More sharing options...
enaiman Posted December 19, 2011 Share Posted December 19, 2011 Easy, look here: #Include <File.au3> Global $text Global $result = "" _FileReadToArray("your file here", $text) $RandomLine = Random(1, $text[0], 1) For $i = $RandomLine To $text[0] $result &= $text[$i] Next MsgBox(0, "result", $result) MrVietA2 1 SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
MrVietA2 Posted December 19, 2011 Author Share Posted December 19, 2011 (edited) Hi enaiman ! Thanks for your exampleBut I would like to get the text from the line 2 (or line 3 or line 4) to the last line (with all random text file). If a text file have 10 lines or 20 lines or 30 lines so what should I do ? Edited December 19, 2011 by MrVietA2 Link to comment Share on other sites More sharing options...
enaiman Posted December 19, 2011 Share Posted December 19, 2011 Just alter "Random" expression to get the results you want. MrVietA2 1 SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
MrVietA2 Posted December 19, 2011 Author Share Posted December 19, 2011 Could you give me an example enaiman ? Thank you ! Link to comment Share on other sites More sharing options...
Blue_Drache Posted December 19, 2011 Share Posted December 19, 2011 he did. MrVietA2 1 Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
Malkey Posted December 19, 2011 Share Posted December 19, 2011 he did. You call that an example? Now this is an example. #include <File.au3> Global $aArray Global $sResult = "" _FileReadToArray("MrVietA2File.txt", $aArray) $RandomLine = Random(2, $aArray[0], 1) ; Starting random line somewhere between line 2 and last line of text file. $sResult = "Starting at line number " & $RandomLine & ". :-" & @LF & @LF For $i = $RandomLine To $aArray[0] $sResult &= $aArray[$i] & @LF Next MsgBox(0, "result", $sResult) MrVietA2 1 Link to comment Share on other sites More sharing options...
MrVietA2 Posted December 19, 2011 Author Share Posted December 19, 2011 Perfect example, thanks Malkey ! I can run my program automatic when windows start but can't run when have Internet connected. I have a question and would like to ask you : " How could I run my program when have internet connect ?" Thanks, Link to comment Share on other sites More sharing options...
Blue_Drache Posted December 19, 2011 Share Posted December 19, 2011 (edited) You call that an example? Now this is an example. #include <File.au3> Global $aArray Global $sResult = "" _FileReadToArray("MrVietA2File.txt", $aArray) $RandomLine = Random(2, $aArray[0], 1) ; Starting random line somewhere between line 2 and last line of text file. $sResult = "Starting at line number " & $RandomLine & ". :-" & @LF & @LF For $i = $RandomLine To $aArray[0] $sResult &= $aArray[$i] & @LF Next MsgBox(0, "result", $sResult) No .. that's spoon-feeding someone code. Edited December 19, 2011 by Blue_Drache Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
Exit Posted December 19, 2011 Share Posted December 19, 2011 Waiting for Internet: While Not Ping("google.de") WEnd MrVietA2 1 App: Au3toCmd       UDF: _SingleScript()                 Link to comment Share on other sites More sharing options...
MrVietA2 Posted December 19, 2011 Author Share Posted December 19, 2011 Waiting for Internet:While Not Ping("google.de")WEndSo could you tell me how can I check Internet connection and run my program after that ? Link to comment Share on other sites More sharing options...
Exit Posted December 19, 2011 Share Posted December 19, 2011 Place your code AFTER my code MrVietA2 1 App: Au3toCmd       UDF: _SingleScript()                 Link to comment Share on other sites More sharing options...
MrVietA2 Posted December 19, 2011 Author Share Posted December 19, 2011 Thanks forumer100 Link to comment Share on other sites More sharing options...
enaiman Posted December 19, 2011 Share Posted December 19, 2011 (edited) @Blue_Drache Thanks, you understood perfectly what I was trying to do. I have seen his post where he was asking for an example and I decided to not answer and to give him a chance to understand what I did there. Unfortunately for him, somebody else took the nanny role. I can see that my "example" was good enough for Malkey because he only changed it just a little bit Edited December 19, 2011 by enaiman MrVietA2 1 SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
Blue_Drache Posted December 19, 2011 Share Posted December 19, 2011 @Blue_DracheThanks, you understood perfectly what I was trying to do.I have seen his post where he was asking for an example and I decided to not answer and to give him a chance to understand what I did there. Unfortunately for him, somebody else took the nanny role.I can see that my "example" was good enough for Malkey because he only changed it just a little bit If you give a man a fire, he's warm for a day.If you set a man on fire, he's warm for the rest of his life. MrVietA2 1 Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
Malkey Posted December 20, 2011 Share Posted December 20, 2011 @Blue_DracheThanks, you understood perfectly what I was trying to do.I have seen his post where he was asking for an example and I decided to not answer and to give him a chance to understand what I did there. Unfortunately for him, somebody else took the nanny role.I can see that my "example" was good enough for Malkey because he only changed it just a little bit @enaimanSorry, I thought I was helping you by correcting the silly mistakes in your cleverly disguised spoon-feeding example.I hope your "Teaching by Bad Example" method does not catch on.nanny Malkey. Link to comment Share on other sites More sharing options...
enaiman Posted December 20, 2011 Share Posted December 20, 2011 @Malkey I fail to see what are my "silly mistakes" but ... whatever floats your boat. The OP got his answer and there is absolutely no point in further discussions. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) 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