Sign in to follow this  
Followers 0
acana007

array with if statement help

5 posts in this topic

#1 ·  Posted (edited)

#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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Edited by dmob

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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.

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