0

ランダムな URL を取得する機能があります。

FUNCTION randurl : String;
BEGIN
  // Randomize URL
  Rx2 := RandomInt(4);
  if (Rx = 0) then
    result := 'www.site1.com'
  else if (Rx2 = 1) then
    result := 'www.site2.com'
  else if (Rx2 = 2) then
    result := 'www.site3.com'
  else if (Rx2 = 3) then
    result := 'www.site4.com';
END;

コンパイル中の文字列があります...

var     Rx2 : integer;

{Declaration (Functions and Procedures)}
// Construct the GET String for the Web Script, call it and return the output
PROCEDURE update(status : String); forward;

BEGIN
    // Message to display in twitter
    statusmessage :=  '#Nowplaying ' + Song['artist'] + ' - ' + Song['title'] + ' @ ' + $FUNCTION_OUTPUT_VARIABLE + ' #' + Song['genre'];
    update(statusmessage);
  END;
END;

上記の $FUNCTION_OUTPUT_VARIABLE には、ランダムな URL を含める必要があります。関数を呼び出して、コードの各パスに出力を挿入するにはどうすればよいですか?

どうもありがとう!

編集:

上記の関数を使用して行ったソリューションを次に示します。

{Declaration (Variables)}

var     Rx2 : integer;

FUNCTION randurl : String; forward;

  BEGIN
    // Message to display in twitter
    statusmessage :=  '#Nowplaying ' + Song['artist'] + ' - ' + Song['title'] + ' @ ' + randurl + ' #' + Song['genre'];
    update(statusmessage);
  END;
END;
4

1 に答える 1

2

私は言語 PAL を知りません。Delphi でどのように機能するかの 2 つのバリエーションを次に示します。

初め:

var
  tmp: String;
begin
    tmp := randurl;
    statusmessage := '#Nowplaying ' + Song['artist'] + ' - ' + Song['title'] + 
      ' @ ' + tmp + ' #' + Song['genre'];

    update(statusmessage);
  end;
end;

2番:

begin
    statusmessage := '#Nowplaying ' + Song['artist'] + ' - ' + Song['title'] + 
      ' @ ' + randurl + ' #' + Song['genre'];

    update(statusmessage);
  end;
end;
于 2013-06-20T10:27:55.557 に答える