Jump to content

array with if statement help


acana007
 Share

Recommended Posts

#include <file.au3>
Dim $aRecords
If _FileReadToArray("all.lst",$aRecords) < 8 Then
   _FileWriteFromArray("all3.lst",$aRecords)
   Exit
EndIf

this just copys the file but what i want it to do is only copy if the line has 8 or more characters

Edited by acana007
Link to comment
Share on other sites

this just copys the file but what i want it to do is only copy if the line has 8 or more characters

If you meant copy the whole file if it has 8 or more lines:
#include <file.au3>

Dim $aRecords
_FileReadToArray("all.lst", $aRecords)
If @error = 0 And $aRecords[0] >= 8 Then _FileWriteFromArray("all3.lst", $aRecords, 1)

If you meant copy each line, if it has 8 or more characters:

#include <file.au3>

Dim $aRecords
_FileReadToArray("all.lst", $aRecords)
If @error = 0 Then
    For $n = 1 To $aRecords[0]
        If StringLen($aRecords[$n]) >= 8 Then FileWriteLine("all3.lst", $aRecords[$n])
    Next
EndIf

Else explain what you really meant.

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

ok i want the script to copy the lines that are in that file that have 8 characters or more to the new file if it has less then 8 characters then skip them

Then PsaltyDS' second example should be what you need.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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

  • Recently Browsing   0 members

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