Jump to content

how to remove spaces from an array


n9mfk9
 Share

Recommended Posts

Hi all

here my code

#include <file.au3>

Dim $aRecords

$ext =".mp3"

If Not _FileReadToArray("names.txt",$aRecords) Then

MsgBox(4096,"Error", " Error reading log to Array error:" & @error)

Exit

EndIf

For $x = 1 to $aRecords[0]

If $x <= 9 Then

$name="en00"

ElseIf $x >= 10 Then

$name="en0"

EndIf

Msgbox(0,$name & $x,$aRecords[$x]&$ext)

MsgBox(0,"", @ScriptDir&"\"& $name&$x&$ext&""& @ScriptDir&"\"&$aRecords[$x]&$ext)

Next

here my names.txt

You've Lost That Lovin' Feelin'

Unchained Melody

(You're My) Soul And Inspiration

Ebb Tide

Just Once In My Life

The White Cliffs Of Dover

He

Hung On You

Little Latin Lupe Lu

Go Ahead And Cry

See That Girl

On This Side Of Goodbye

How can i remove spaces array

I getting the name .mp3 i went name.mp3

thanks Beau

Link to comment
Share on other sites

#include <file.au3>

Dim $aRecords
$ext =".mp3"

If Not _FileReadToArray("names.txt",$aRecords) Then
    MsgBox(4096,"Error", " Error reading log to Array error:" & @error)
    Exit
Else
    For $i = 1 To $aRecords[0]
        $aRecords[$i] = StringStripWS($aRecords[$i], 2)
    Next
EndIf

For $x = 1 to $aRecords[0]
    If $x <= 9 Then
        $name="en00"
    ElseIf $x >= 10 Then
        $name="en0"
    EndIf
    Msgbox(0, $name & $x, $aRecords[$x] & $ext)
    MsgBox(0, "", @ScriptDir &"\"& $name & $x & $ext &""& @ScriptDir &"\"& $aRecords[$x]&$ext)
Next

Link to comment
Share on other sites

  • Moderators

Or...

#include <array.au3>

$aMyArray = _ClearMySpaceBeforeMP3Array("whatever.txt")
_ArrayDisplay($aMyArray)

Func _ClearMySpaceBeforeMP3Array($hFile)
    Return StringSplit(StringStripCR(StringRegExpReplace(FileRead($hFile), "(?s)(?i)\s+.mp3", ".mp3")), @LF)
EndFunc

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.

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