Pascal文本菜单音乐播放器

时间:2018-05-30 07:01:27

标签: pascal

我需要帮助创建我的音乐播放器,我收到同样的错误,似乎无法超越它。谢谢。 我在下面附上了我的代码,以及我的错误。

错误:

  

i386免费Pascal编译器版本2.6.4 [2014/02/26]版权所有(c)    1993至2014年由Florian Klaempfl和其他目标操作系统:Darwin for i386   编译MusicPlayer.pas

     

MusicPlayer.pas(82,37)错误:arg no的类型不兼容。 1:得到“ShortString”,预计“专辑”

     

MusicPlayer.pas(138,31)错误:arg no的类型不兼容。 1:得到了    “albumArray”,预计“专辑”

     

MusicPlayer.pas(164,44)错误:arg no的不兼容类型。 1:得到“albumArray”,预计“专辑”

     

MusicPlayer.pas(174)致命:编译模块有3个错误,   停止致命:编译中止错误:/ usr / local / bin / ppc386   返回错误exitcode(如果您没有指定源,则为正常   要编译的文件)

    program MusicPlayer;
uses TerminalUserInput;

type
    Track = record
       trackName: String;
       location: String;
    end;

    TrackArray = array of Track;

    Album = record
       albumName: String;
       artistName: String;
       genre: String;
       track: TrackArray;
       // key: Integer;
       trackNum: Integer;
       fileName: String;
    end;

    albumArray = array of Album;


function GetAlbums(): albumArray;
var
    // anAlbum: Album;
    //albums: albumArray;
    fileName: String;
    myFile: TextFile;
    numOfAlb: Integer;
    trackNum: Integer;
    i: Integer;
    j: Integer;
begin
    fileName := ReadString('Enter filename: ');
    AssignFile(myFile, fileName);
    // AssignFile(myFile, 'albums.dat');
    Reset(myFile);
    ReadLn(myFile, numOfAlb);
    setLength(result, numOfAlb);
    for i:= 0 to High(result) do
    begin
        ReadLn(myFile, result[i].albumname);
        ReadLn(myFile, result[i].artistName);
        ReadLn(myFile, result[i].genre);
        ReadLn(myFile, trackNum);
        setLength(result[i].track, trackNum);
        for j:= 0 to trackNum -1 do
        begin
            ReadLn(myFile, result[i].track[j].trackName);
            ReadLn(myFile, result[i].track[j].location);
        end;
    end;
end;

procedure DisplayAlbum(a: Album);
var
    //t: Track;
    i: Integer;

begin
    WriteLn('Album name is: ', a.albumName);
    WriteLn('Album artist name is: ', a.artistName);
    WriteLn('Album genre is: ', a.genre);
    WriteLn('Number of tracks are: ', a.trackNum);
    for i:= 0 to High(a.track) do
    begin
        WriteLn('Track name is: ', a.track[i].trackName);
        WriteLn('Album name is: ', a.track[i].location);
    end;
end;


function PrintAllGenres(albums: albumArray): albumArray;
var
    i: Integer;

begin
    for i := 0 to High(albums) do
    begin
        DisplayAlbum(albums[i].genre);
    end;

end;



procedure SelectAlbum(const albums: albumArray);
var
   val: Integer;
   i: Integer;
begin
   WriteLn('<< Welcome to the Track Player >>');
   val := ReadInteger('Enter an Album''s key number: ');
   for i := 0 to High(albums) do
   begin
     WriteLn('Album is now playing.');
   end;
   if (i > High(albums)) then
   begin
      WriteLn('Album was not found, now returning to Main Menu ');
   end;
end;

function UpdateAlbum(a: Album): Album;
begin
    a.albumName := ReadString('Please enter a new name for this album: ');
    a.genre := ReadString('Please enter a new genre for this album: ');
end;

// function UpdateAlbums(): albumArray;
// var
//    val: Integer;
//    i: Integer;
// begin
//    WriteLn('<< Album Updater >>');
//    val := ReadInteger('Enter an Album''s key number: ');
//    if (val = True) then
//         WriteLn('Album was found.')
//    else
//           WriteLn('Album was not found, now returning to Main Menu ');
// end;


procedure DisplayAlbums(albums: albumArray);
var
    val: Integer;
begin
   repeat
    WriteLn('<< Displaying Albums >>');
    WriteLn('1. Display all albums');
    WriteLn('2. Display genre');
    WriteLn('3. Return to main menu');
    val := ReadInteger('Enter a number to enter menu: ');

    case val of
        1: DisplayAlbum(albums);
        2: PrintAllGenres(albums);
    end;

  until val = 3;
end;


procedure Main();
var
    albums: albumArray;
    val: Integer;
begin
    repeat
        WriteLn('<< Text Music Player Menu >>');
        WriteLn('1. Read in Albums');
        WriteLn('2. Display Albums');
        WriteLn('3. Select an Album to play');
        WriteLn('4. Update an existing Album');
        WriteLn('5. Quit');
        val := ReadInteger('Enter a number to enter menu: ');

        case val of
            1: albums := GetAlbums();
            2: DisplayAlbums(albums);
            3: SelectAlbum(albums);
            4: albums := UpdateAlbum(albums);

        end;

    until val = 5;
end;

begin
    Main();
end.

1 个答案:

答案 0 :(得分:2)

在您编写的代码中

procedure DisplayAlbum(a: Album);

这意味着你需要将Album传递给程序,但是在第82行你已经写了

    DisplayAlbum(albums[i].genre);

genreAlbum的字段,而您应该传递整个Album

将第82行更改为

    DisplayAlbum(albums[i]);

我自己留下其他错误来解决,错误非常相似,你现在应该能够解决它们。 正如我昨天告诉你的那样,你可能希望(或实际上,需要)与你的导师交谈,以便更好地理解。