mIRC Home    About    Download    Register    News    Help

Print Thread
#174509 08/04/07 11:47 PM
Joined: Apr 2007
Posts: 6
D
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Apr 2007
Posts: 6
Hello; I just joined the MIRC forums and am happy to be here =). Anyway getting to the problem, I am having a problem with a variable. I am trying to remove the first word in a variable called %readtext and its from a text file (Code Below):

Code:
/output {
  //set %file C:\Westwood\RenegadeFDS\Server\renlog_ $+ $date(m-d-yyyy) $+ .txt
  set %lines $lines(%file)
  if (%lines >= 4) {
    set %readline $calc(%lines - 2)
    //readlog
  }
  if (%lines <= 4) {
    set %readline 0
    //readlog
  }
}
/readlog {
  if (%readline != $calc(%lines + 1)) {
    //set %readtext $remove($read(%file,%readline),$1)
    //msg %normalchannel 4[RR] $remove(%readtext,[ $+ [ $1 ] ])
    //set %lines $lines(%file)
    //inc %readline
    //checklines
  }
  if (%readline == $calc(%lines + 1)) {
    //checklines
  }
}
/checklines {
  if (%readline == $calc(%lines + 1)) {
    //checklines2
  }
  if (%readline != $calc(%lines + 1)) {
    //readlog
  }
}
/checklines2 {
  if (%readline == $calc(%lines + 1)) {
    //.timerchecklines 0 0.1 //checkfinal
  }
  if (%readline != $calc(%lines + 1)) {
    //readlog
  }
}
/checkfinal {
  if (%readline == $calc(%lines + 1)) {
    //set %lines $lines(%file)
  }
  if (%readline != $calc(%lines + 1)) {
    //.timerchecklines off
    //readlog
  }
}
 


IF there is any way I can remove $1 from %readtext, then can someone tell me.


Please, Thanks, and Reguards;
~Rexs8



Thanks and Reguards;
Rexs8
Joined: Feb 2007
Posts: 27
S
Ameglian cow
Offline
Ameglian cow
S
Joined: Feb 2007
Posts: 27
set %variable $remtok(%variable,1,32)


Joined: Dec 2002
Posts: 155
S
Vogon poet
Offline
Vogon poet
S
Joined: Dec 2002
Posts: 155
You mean "$deltok(%variable,1,32)".

Joined: Apr 2007
Posts: 6
D
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Apr 2007
Posts: 6
Ah. Thank you. Haven't used token commands/stuff yet and wow it is interesting. Thank again!



Thanks and Reguards;
Rexs8
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Here's a slight rewrite for you.

Code:
output {
  set %file $+(C:\Westwood\RenegadeFDS\Server\renlog_,$date(m-d-yyyy),.txt)
  set %lines $lines(%file)
  if (%lines >= 4) {
    set %readline $calc(%lines - 2)
    readlog
  }
  else {
    set %readline 0
    readlog
  }
}
readlog {
  if (%readline != $calc(%lines + 1)) {
    set %readtext $remove($read(%file,%readline),$1)
    msg %normalchannel 4[RR] $remove(%readtext,[ $+ [ $1 ] ])
    set %lines $lines(%file)
    inc %readline
    checklines
  }
  else {
    checklines
  }
}
checklines {
  if (%readline == $calc(%lines + 1)) {
    checklines2
  }
  else {
    readlog
  }
}
checklines2 {
  if (%readline == $calc(%lines + 1)) {
    .timerchecklines 0 0.1 checkfinal
  }
  else {
    readlog
  }
}
checkfinal {
  if (%readline == $calc(%lines + 1)) {
    set %lines $lines(%file)
  }
  else {
    .timerchecklines off
    readlog
  }
}


A couple of things...

Code:
readlog {
  if (%readline != $calc(%lines + 1)) {
    set %readtext $remove($read(%file,%readline),$1)
    msg %normalchannel 4[RR] $remove(%readtext,[ $+ [ $1 ] ])
    set %lines $lines(%file)
    inc %readline
    checklines
  }


All of your /readlog commands do not include a $1. So I'm unsure why you're using $1 here unless you also call the alias manually or from some other script not shown here. Also, why are you removing $1 twice from it? Once would be enough. I left those lines as they were so you could decide what you wanted to do with them.

Another thing... this readlog alias sets the %lines variable inside the IF statement that already checks the %lines variable. If it wasn't already set to $lines(%file) before the IF statement, then it wouldn't be checking it correctly. You would be better off having that /set command before the IF.

Also, unless you need to store every variable, you can use /var for some of these. From what you're showing here, you don't need a variable such as %readtext except while inside the alias, for example. For any variables that the /set, you should make sure that they are unique. A variable such as %lines could be used by other scripts you may want to install and that could cause a conflict. Try using variables such as %log.lines or something more unique for any /set variables. /var variables don't matter because they are used only in that one script and then get unset.

I'm also unsure why you're looping through the log the way you are. There are a couple of better choices for doing so... /play would probably be the best. And, if not /play, then WHILE would be good in the readlog alias.


Invision Support
#Invision on irc.irchighway.net
Joined: Apr 2007
Posts: 6
D
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Apr 2007
Posts: 6
Hello, Riamus2;
I made the script loop because it reads a text file from a program that outputs the game information. (Server pages, Server messages, Server Actions, Kicks, Bans, Purchases, etc...) /play really doesn't work for me because I need myself to read the script with an on INPUT. I have no idea what WHILE does, lol.

The text gets placed into the text file so when its update it, it automatically inputs it into the channel. I didn't have a clue what I was doing with $1, so I was just toying with it. I used the $deltok to remove $1 in %readtext because it showed the annoying time and I wanted to remove it without editing the file >.>.

I hope this makes more sense to you and thank you for rewriting it and I really appreciate the help and quick learning paragraph!
Reguards;
Rexs8



Thanks and Reguards;
Rexs8
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Ah, I missed what you said about removing the first word in there. Yeah, just use $deltok as mentioned in there. You'll only want to do it one time, though.

WHILE is a way to loop. /help while

Here's an example:

Code:
alias Count_to_10 {
  var %counter = 1
  while (%counter <= 10) {
    echo -a %counter
    inc %counter
  }
}


That will let you loop through something. In your case, you'd just do something like:

Code:
while (%readline <= %lines) {
  do stuff
  inc %readline
}


What that would do is to loop until %readline > %lines without the need of aliases.


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard