Jump to content

Recommended Posts

Posted (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 by MrVietA2
Posted (edited)

Hi enaiman ! Thanks for your example

But 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 by MrVietA2
Posted

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)
Posted

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,

Posted (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 by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Posted (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 by enaiman

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 :)

Posted

@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 :)

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.

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Posted

@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 :)

@enaiman

Sorry, 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.

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
  • Recently Browsing   0 members

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