square_eyes
square_eyes

Reputation: 1271

Add Result of Function to String As Variable - SAM Broadcaster

I have a function to grab a random 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;

I have a string being compiled...

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;

Where $FUNCTION_OUTPUT_VARIABLE is above, I need the random URL to be included. How to I call the function and then insert the output on each pass of the code?

Many thanks!

Edit:

Here's the solution I went with using the above function.

{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;

Upvotes: 0

Views: 419

Answers (1)

user2468462
user2468462

Reputation:

I do not know the language PAL, here are two variants of how it would work in Delphi:

First:

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

    update(statusmessage);
  end;
end;

Second:

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

    update(statusmessage);
  end;
end;

Upvotes: 2

Related Questions