Jump to content

Arrays... Grrr


 Share

Recommended Posts

Ok, I'm being honest here... I've literally tried for hours... What I'm trying to do, is create a function to play M3U files. It's pretty easy, only if there's one song in the file, but since obviously, most people do not have just one song in a M3U file, I need to create an array. So, here's my 1,023, 678 attempt at it:

#include <File.au3>
Func _PlayM3U($M3UFilePath)
   $File = FileOpen($M3UFilePath, 0)
   Dim $lines
   $lines = _FileCountLines($M3UFilePath)
   For $n = 1 to $lines
       $linestext = FileReadLine($M3UFilePath, $n)
   Next
   For $i = 1 to $linestext[$lines]
       MsgBox(0, "Debug", $linestext[$i])
   Next
EndFunc  ;==>_PlayM3U

_PlayM3U(@DesktopDir & "\m3utest.m3u")

Now please, instead of re-writing this for me, could you just tell me what I am doing wrong? Because this is for someone, and I need to oficially call it mine... So if someone would point out my errors, that would be great!

Thanks a bunch! :)

EDIT: I know, I could use, _FileReadToArray... But I'd like to not_use as much of others peoples work as possible...

Edited by layer
FootbaG
Link to comment
Share on other sites

you never dimmed $linestext as an array just set the subscripts to how many lines are in the file

Edited by Xenogis

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Link to comment
Share on other sites

Ejoc, he specificly said not to post code

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Link to comment
Share on other sites

Thanks... I've looked at Ejoc's code, and I now understand a lot more about arrays then I did 10 minutes ago! :) There's still one thing I don't get, is why, did you have to do this:

Dim $linestext[$lines+1]

Why was the "+1" inside the brackets, necassary?

FootbaG
Link to comment
Share on other sites

Because Arrays start at 0 not 1 so and array of 3:

Dim $array[3]

Would be $array[0], $array[1] and $array[2]

Since you are using the line number of the file(which starts at 1) you would then try to access $array[3] which isnt valid.

Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs
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...