mIRC Homepage
Well, I'm not sure why but for some reason I can't get this working. I had it working on my old computer using just

Code:
msg # $read(file.txt)


But now it's not working. It reads everything right up until the "$" that is inside (no there's no way of changing that, unfortunately) after the $ it output's random letters and numbers.

I've tried everything in the help file...
$read(file.txt, t)
$read(file.txt, 1)
$read(file.txt, t, 1)

and a bunch of others even if it didn't seem like it would work (waste of time but I wanted to make sure I exhausted myself before asking help...)

Any help is appreciated at this point. Thanks guys. You're the best smile
By default, $read will evaluate the text it reads as if it was mSL code. To prevent this behavior you must use the n switch. Unless you specifically want the text file to contain mSL code, you should make a habit of using -n when using $read to prevent abuse.

https://forums.mirc.com/ubbthreads.php/topics/248713/Re:_Donation_goal_tracker?#Post248713
I did that. Still didn't work. And even without that, last week just plain msg # $read(file.txt) was working. I have changed absolutely nothing about the portion of the script I am using. It just, stopped working.
Did you?

I suggest you reread Belhifet's answer as many times as needed until you really do understand it but I'll state again:

Without the 'n' switch, lines are evaluated when read, which is why you were talking about getting random stuff after the '$', that's because it was an identifier, which got evaluated.

We didn't say $read(file.txt) doesn't work, it worked last week and it will work tomorrow, just not the way you want, use the 'n' switch.
Plain "msg # $read(file.txt)" will never work as you want it to. What you need is the 'n' to prevent $1 from being evaluated into msl code from the text file.

Take a look at this simple example:
Code:
alias Bramzee {
  echo -a You just wrote $iif($1,$1,nothing) 
  if ($1) write -c file.txt $1
  var %read $read(file.txt,n)
  echo -a Inside file.txt there's currently: %read
}

Example usage: /Bramzee $1
Quote:
You just wrote $1.50
Inside file.txt there's currently: $1.50
You just wrote nothing
Inside file.txt there's currently: $1.50
You just wrote $99.99
Inside file.txt there's currently: $99.99
You just wrote nothing
Inside file.txt there's currently: $99.99
You just wrote $1
Inside file.txt there's currently: $1
You just wrote nothing
Inside file.txt there's currently: $1
You just wrote $2
Inside file.txt there's currently: $2
You just wrote nothing
Inside file.txt there's currently: $2
thank you nillen. I've got it working. didn't think to use a var for this (I gotta quit attempting to fix things only when I'm tired. Maybe if I tried when I was actually awake I might do something decent lol)
Making it into a variable has nothing to do with it. I simply made the variable use '$read(file.txt,n)' which was the fix.

My personal style of scripting uses a lot of local variables to keep it clean. For instance I'd normally use %donation for $read(file.txt,n) if it was what I was looking for. And normally I'd also use %file for file.txt - This is all to keep it simpler, faster (to type) and nicer for long codes. It has nothing at all to do with the way mSL interprets it.
Well, I'm still "new" to all this. But the variable worked for some reason. When I had just msg # $read(file.txt,n) nothing worked. I switched it to

if (%1 == file.txt) {
var %readdonation $read(file.txt,n)
msg # %readdonation
}

and it worked.


Either way, thanks for the help smile
It's working now and I guess that's what matters :P
© mIRC Discussion Forums