This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Multiline element in array

Old posts that have not been replied to for several years.
Locked
X
Xian

Multiline element in array

Post by Xian »

Hi all!!!

Anybody know how can I use a multiline element in an array of strings?

Sample:

Code: Select all

set quote {
"\"I never forget a face, but in your case I'll make an exception (Groucho Marx)\"" }
And I want that the quote is presented in 2 separate lines on the channel:
I never forget a face,
but in your case I'll make an exception (Groucho Marx)


Can I define some NewLine char or something like this? I don't want to use two elements of the array becouse i'm using a Quote script that only works with one element at a time.

Thanks in advance, and excuse my poor english.
:roll:
I
Iridium

Post by Iridium »

The newline char is \n. therefore your code needs to be

Code: Select all

set quote { 
"\"I never forget a face\nbut in your case I'll make an exception (Groucho Marx)\"" }
The only problem is, if this is being spat out on IRC then you'll be missing the "PRIVMSG #chan whatever"

so you prolly need:

Code: Select all

set quote { 
"\"I never forget a face\nPRIVMSG #chan :but in your case I'll make an exception (Groucho Marx)\"" }
if it is used in multiple channels then you're probably screwed :)
X
Xian

Post by Xian »

Thanks a lot!!!

I will give it a try!!

:P
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Other methods are to use multi-dimentional lists (AKA lists within lists).

Code: Select all

set quote {
{{This is item 0 in list 0} {this is item 1 in list 0}}
{{This is item 0 in list 1} {this is item 1 in list 1}}
}
Somthing like this will spit a random quote.

Code: Select all

foreach a [lindex $quote [expr [rand [llength $quote]] -1]] {
  puthelp "PRIVMSG #channel :$a"
}
If the random value is 1, the following is spat out
PRIVMSG #channel :This is item 0 in list 0
PRIVMSG #channel :this is item 1 in list 0
I
Iridium

Post by Iridium »

His way is better :cry: :)
Locked