Jump to content
Sign in to follow this  
brodie28

This script to edit a text file is driving me crazy!

Recommended Posts

Could that be changed so that it does not delete lines that are only spaces?

I added a StringIsSpace if statement but it didn't work.

Have you ever seen a StringIsSpace statement before? I haven't :D...
#include <File.au3>
Local $sFilePath = @ScriptDir & '\locals.txt'
Local $nArray = '', $sStore
If Not _FileReadToArray($sFilePath, $nArray) Then MsgBox(64, 'Info:', 'Error reading File')
For $iCount = 1 To UBound($nArray) - 1
    If StringInStr($nArray[$iCount], 'Civilian') Or _
        StringInStr($nArray[$iCount], 'Thug') Or _
        StringStripWS($nArray[$iCount], 8) = '' Then
        $sStore &= $nArray[$iCount] & @CRLF
    EndIf
Next

$hOpen = FileOpen($sFilePath, 2)
FileWrite($hOpen, $sStore)
FileClose($hOpen)

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.

Share this post


Link to post
Share on other sites

If you run a string that contains only " " (whitespaces) this may work:

StringRegExp($StringToCheck," *")

Untested.

Read up on white space. Carriage Returns, Line Feeds, Horizontal Tabs, Vertical Tabs.... :D

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  

×
×
  • Create New...