Skip to content
MSN Addons

Code for this text file

A TG007 community discussion started by nyt1972.

Discussion 52 posts
Page 2 of 3
Open
Topic #5787 · 52 published posts · 4,065 views

was posting at same time

My code does NOT have bugs. It just develops random features.

Thankyou Angelia, TGK, and Ozzy,

 

my text file is like this.

 

HEADING1

My text goes here. My text goes here.My text goes here.My text goes here.My text goes here.My text goes here.My text goes here.My text goes here.

 

HEADING2

My text goes here. My text goes here.My text goes here.My text goes here.My text goes here.My text goes here.My text goes here.My text goes here.

 

 

I want the command like this

 

!quote HEADING2

i think if you do it the way i put it, and just put heading2 at the front, it should work fine.

 

Meaning, if you put

 

HEADING1 My text goes here. My text goes here.My text goes here.My text goes here.My text goes here.My text goes here.My text goes here.My text goes here.

 

HEADING2 My text goes here. My text goes here.My text goes here.My text goes here.My text goes here.My text goes here.My text goes here.My text goes here.

 

and then done, !quote heading2

 

it should return

 

My text goes here. My text goes here.My text goes here.My text goes here.My text goes here.My text goes here.My text goes here.My text goes here.

Thanx TGK for your help, I wrote this code and it works, but mine is very simple as I am learning now.

on *:TEXT:!show *:*: {
 msg $nick $read(abc.txt, s, $2)
}

 

 

abc.txt is like this

 

Heading1 some text here. some text here.some text here.some text here.some text here.some text here.

 

Heading2 some text here. some text here.some text here.some text here.some text here.some text here.

 

Heading3 some text here. some text here.some text here.some text here.some text here.some text here.

 

 

Now I want to ask you that can I do it with mulitple paragrpah. I mean if there are 2 or 3 para under Heading1 or Heading2 etc.

Edited Jan 16, 2006 11:00 AM by nyt1972

yea it probably can be done, but it would get tricky, you would need to set up a special reading system so that it checks when it hits the next header.

Thats trick I want to know, if I cud do that I wud have done that without asking u. LOL

just out of curiosity, why do you want to do exactly the same thing with a text document as an ini file? it's more effort, takes longer and requires far more coding.

People are like slinkies; they're generally boring until you push them down stairs

angelia, with large peices of text, reads are faster than inis. The way i would do it is set it up similar to an ini file, but without all the this = that stuff.

 

So for example

 

[header1]

This is example1.

I can do this.

And you can't :P

[header2]

You stink.

We all know it.

HAHAHAHA.

[header3]

You need a life.

Why do you talk here.

:P:P:P

 

Then with a $read, you would do this.

; mq and mdeq by Pete®tje 2004, used for slowing messages via queueing them
alias mq { 
 inc %mq_pointer 
 /hadd -m mq %mq_pointer $1- 
 %mq = $addtok(%mq,%mq_pointer,32) 
 if (!$timer(mq)) { .timermq -m 1 $iif(%delay_mq,%delay_mq,400) /mdeq } 
} 
alias mdeq { 
 if ($hget(mq,0).item == 0) { unset %mq* } 
 else { 
   var %item = $gettok(%mq,1,32) 
   %mq = $deltok(%mq,1,32) 
   /msg $hget(mq,%item) 
   hdel mq %item 
   if (%mq) { .timermq -m 1 $iif(%delay_mq,%delay_mq,400) /mdeq } 
   else { unset %mq_pointer } 
 } 
} 
on *:TEXT:!show *:*: {
 var %r = $read(abc.txt, s, [ $+ $2 $+ ]) , %l = $calc($readn + 1)
 while ($read(abc.txt,%l)) {
   %r = $ifmatch
   if ([*] !iswm %r) mq $target %r
   else break
   inc %l
 }
}

 

The code does require the two aliases to run to ensure you don't disconnect yourself.

Now if you wanted to do it ini style, you would do this.

 

[header1]

1=This is example1.

2=I can do this.

3=And you can't :P

[header2]

1=You stink.

2=We all know it.

3=HAHAHAHA.

[header3]

1=You need a life.

2=Why do you talk here.

3=:P:P:P

 

Then with a $readini, you would do this.

; mq and mdeq by Pete®tje 2004, used for slowing messages via queueing them
alias mq { 
 inc %mq_pointer 
 /hadd -m mq %mq_pointer $1- 
 %mq = $addtok(%mq,%mq_pointer,32) 
 if (!$timer(mq)) { .timermq -m 1 $iif(%delay_mq,%delay_mq,400) /mdeq } 
} 
alias mdeq { 
 if ($hget(mq,0).item == 0) { unset %mq* } 
 else { 
   var %item = $gettok(%mq,1,32) 
   %mq = $deltok(%mq,1,32) 
   /msg $hget(mq,%item) 
   hdel mq %item 
   if (%mq) { .timermq -m 1 $iif(%delay_mq,%delay_mq,400) /mdeq } 
   else { unset %mq_pointer } 
 } 
} 
on *:TEXT:!show *:*: {
 var %r = %l = 1
 while ($ini(abc.ini,$2,%l)) {
   mq $target $read(abc.ini,$2,$ifmatch)
   inc %l
 }
}

 

Please note that with the ini one, it doesn't really matter what you have for the 1=, 2=, and that stuff, provided it has the = to indicate what you want to send out.

 

So as you can see, the code does not vary much in size, just requires more in the ini file. Because of all the 1=, 2= and what not. So It's up to you how you want it. I gave you the code for both, so you can use either. Don't remove the two aliases within the code because they are a real help to ensure you don't disconnect yourself from the server while sending the messages.

Edited Jan 16, 2006 11:03 PM by The Gate Keeper

he wanted an on text event:

on *:text:!quote*:#:{ msg $chan Quote $2 - $readini(quotes.ini,$2,1) }

[heading 1]

1=quoting text

 

[heading 2]

1=quoting more text

if it can be done simply, keep it simple.

People are like slinkies; they're generally boring until you push them down stairs

lol, the read is the exact same, except you don't need all the = stuff, just the header bit. And as i said, both ways have virtually the same coding, so how is it not simple? And besides, he said that he wanted chucks of text sent out, not just 1 line. with 1 line, i covered that before. But yea, $readini, and $read can do virtually the same thing.

Edited Jan 17, 2006 6:24 AM by The Gate Keeper

Thanx TGK, this code is working fine but I need an year to learn it or may be more. :)

I modified these two lines to make it read from different files. Am I right?

 

[

var %r = $read($2 $+ .txt, s, [ $+ $2 $+ ]) , %l = $calc($readn + 1)
 while ($read($2 $+ .txt,%l)) {

arr, i wouldn't really do that.

 

if you want to read for all different files, what you should do then is go through and replace $2 with $3, then fine all the abc in the code, and replace it with $2. But yea, you are getting there. But just remember to replace $2 with $3 before doing the $2 $+ .txt

ok thanx for replying, but actually I was trying like this:

 

!show Heading1

or

!show Heading2

 

suppose these are long topics ad are in different files saved with the heading's name.

 

I mean the topic Heading1 is in a file Heading1.txt.

put all the text files that you have in say the file name List.txt

 

So in List.txt you would have

 

abc.txt

hehe.txt

why.txt

 

and so on, then use this code. (This is modded off the read method, not the readini method. It can be done similarly with the readini method.

 

; mq and mdeq by Pete®tje 2004, used for slowing messages via queueing them
alias mq { 
inc %mq_pointer 
/hadd -m mq %mq_pointer $1- 
%mq = $addtok(%mq,%mq_pointer,32) 
if (!$timer(mq)) { .timermq -m 1 $iif(%delay_mq,%delay_mq,400) /mdeq } 
} 
alias mdeq { 
if ($hget(mq,0).item == 0) { unset %mq* } 
else { 
var %item = $gettok(%mq,1,32) 
%mq = $deltok(%mq,1,32) 
/msg $hget(mq,%item) 
hdel mq %item 
if (%mq) { .timermq -m 1 $iif(%delay_mq,%delay_mq,400) /mdeq } 
else { unset %mq_pointer } 
} 
} 
on *:TEXT:!show *:*: {
 var %ll = 1
 while ($read(list.txt,%ll)) {
   var %f = $ifmatch , %r = $read(%f, s, [ $+ $2 $+ ]) , %l = $calc($readn + 1)
   while ($read(%f,%l)) {
     %r = $ifmatch
     if ([*] !iswm %r) mq $target %r
     else break
     inc %l
   }
   inc %ll
 }
}

Ok thats great, thanx a lot, I will try this.

I changed this line of code

while ($read(list.txt,%ll)) {

 

with this

while ($read(mydir\list.txt,%ll)) {

 

I want to read ths list.txt from mydir and all the related files are in mydir. but its not working.

it's set to work from the default mIRC directory, you need to put mydir\ infront of all the read peices and that.

 

on *:TEXT:!show *:*: {
var %ll = 1
while ($read(mydir\list.txt,%ll)) {
var %f = $ifmatch , %r = $read(mydir\ $+ %f, s, [ $+ $2 $+ ]) , %l = $calc($readn + 1)
while ($read(mydir\ $+ %f,%l)) {
%r = $ifmatch
if ([*] !iswm %r) mq $target %r
else break
inc %l
}
inc %ll
}
}

 

don't forget the two aliases above, i wasn't bothered to copy it.

No need to copy that, I am already bothering you much, but now I want to bother you more :) and thats is if I want to stop the topic in middle or at any time, what to do.

naw, feel free to keep asking. Maybe put a full description of what you want, how you want it, and i'll see what i can do about it.