Jump to content
Sign in to follow this  
n9mfk9

how to remove spaces from an array

Recommended Posts

n9mfk9

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

Share this post


Link to post
Share on other sites
rasim

#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

Share this post


Link to post
Share on other sites
SmOke_N

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.

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  

×