mIRC Homepage

this code read only first line in filetext

Posted By: An0o

this code read only first line in filetext - 27/12/19 06:47 PM

This code reads only the first line of the file
and not read The second line and the following lines

I want to fix it to search all the lines of the file

if ($read(do.txt, w, *, %........) isin %.......) {

Code
on :............: {
  var %...... = $address($nick,2)
  var %........ = $remove($gettok($gettok(%.............,2,33))  
  if ($read(do.txt, w, *, %........) isin %.......) {
    ban -u77200 # $address($nick,2)
  }
  else {
    dec %...................
  }
}
Posted By: maroon

Re: this code read only first line in filetext - 27/12/19 07:43 PM

in your effort to remove info from your variable names, you've made it unreadable. you have nested gettok's without the delimiter and token for the outer one. also, the 4th parm of your wildcard read is for the line number to begin searching, and we have no way of knowing what's contained in your variable placed in that location.
also reminder that you should always use the 'nt' switches with $read unless you have a specific reason for not doing so.
Without the 't' switch, if line#1 is a number, it uses that as if it's the total number of lines in the file.
Without the 'n' switch, it evaluates %word and $word found in the line
Posted By: An0o

Re: this code read only first line in filetext - 27/12/19 11:45 PM

Thanks maroon
This is code

Code
ON !*:JOIN:#: {
  var %domain = $address($nick,2)
  var %ident = $remove($gettok($gettok(%fullhost ,2,33))  
  if ($read(do.txt, w, *, %domain ) isin %domain ) {
    ban -u77200 # $address($nick,2)
  }
  else {
    dec %domain 
  }
}


The code read one first line only in filetext(do.txt)
, not search in all lines in the filetext

In need read or search all lines numbers in the filetext,
If there is a match of the number in one of the lines, execute the command
Posted By: maroon

Re: this code read only first line in filetext - 28/12/19 01:37 AM

Your code doesn't make sense. Are you posting the actual code you're using, or a sanitized version of it.
As I said before, you've wrapped the $gettok identifier around another $gettok, but the outer doesn't have a delimiter or a token#. And then on top of that, you're using $remove without any parameter pairs for removing stuff, and without a closing parenthesis - 3 open + 2 closing.

You define %ident then proceed to not use it. As I said before, the 4th parameter is an optional line number to start searching from if you don't want to start at 1. If %domain contains 123456, then it's starting at line 123456. Luckily, your %domain contains a text string, which $read evaluates as the number zero, so it starts at line 1 since 0 is an invalid line#.

You're not using the 'nt' switches, so if line#1 is a number, then $read thinks that's how many lines there's supposed to be in the file, and if the line contains %word or $word then it tries to evaluate them into variables or identifiers.

By doing a wildcard search for "*" of course it's going to match on the 1st line it encounters, even a blank line.

You can use the -s switch when creating the /var to send an info message to status window showing what string is created, or use echo -s to show the value of variables at different $scriptline's
© 2020 mIRC Discussion Forums