2011-12-23 84 views
0
function queue_instructions(){ 
     var input_message = "Commands 
    w? Shows whos on the waitlist 
    w+ Adds yourself to the waitlist 
    w- Removes yourself from the waitlist 
    w++ Moves yourself down one spot on the waitlist 
    -mods Shows a list of available moderators 
    -plays Shows how many songs each DJ has played 
    -promote Requests a vote from everyone for you to be moved to 1st on the list 
    -pull [#] Requests a vote from everyone to pull that DJ off the booth Number of DJ is  what number spot he is on the booth Numbers read from left to right 
    -remove [#] Removes that number DJ from the waitlist Must be a moderator 
    -votekick [username] Requests a vote from everyone to kick the user 
    Type -help [command] for more info on a command (ie. -help w?)"; 
     deliver_chat(input_message); 

我收到了一個語法錯誤,在我的Javascript控制檯上Google chrome上出現意外的非法行爲。有任何想法嗎?Javascript語法錯誤意外令牌非法

回答

3

您必須關閉這些報價在每行,並與+串聯到下一行:

var input_message = "Commands " + 
    "w? Shows whos on the waitlist " + 
    "w+ Adds yourself to the waitlist " + 

你想換行與每一行插入?如果是這樣,您可以使用\n

var input_message = "Commands\n" + 
    "w? Shows whos on the waitlist\n" + 
    "w+ Adds yourself to the waitlist\n" + 
0

您的語法不正確。您需要將整個字符串放在一行中,或者在每行中關閉引號a a +來連接下一行。

1

當你分割多行字符串,你需要+來連接像這樣

var input_message = "Commands"+ 
"w? Shows whos on the waitlist"+ 
"w+ Adds yourself to the waitlist"+ 
"w- Removes yourself from the waitlist"+ 
"w++ Moves yourself down one spot on the waitlist"+ 
"-mods Shows a list of available moderators"+ 
"-plays Shows how many songs each DJ has played"+; 

而且也是在你的代碼中,我沒有找到的那個右大括號}功能。

function queue_instructions() 
{ 
    //Stuff here. 
} 

你需要包括它。

+1

那麼你是誰花時間編輯這個問題,所以一+1我我至少可以做到:) – 2011-12-23 05:05:43

0

或者你這樣做:

var input_message = [ 
    "Commands", 
    "w? Shows whos on the waitlist", 
    "w+ Adds yourself to the waitlist", 
    "w- Removes yourself from the waitlist", 
    "w++ Moves yourself down one spot on the waitlist", 
    "-mods Shows a list of available moderators", 
    "-plays Shows how many songs each DJ has played", 
    "-promote Requests a vote from everyone for you to be moved to 1st on the list", 
    "-pull [#] Requests a vote from everyone to pull that DJ off the booth Number of DJ is what number spot he is on the booth Numbers read from left to right", 
    "-remove [#] Removes that number DJ from the waitlist Must be a moderator", 
    "-votekick [username] Requests a vote from everyone to kick the user", 
    "Type -help [command] for more info on a command (ie. -help w?)" 
].join("\n");