mIRC Home    About    Download    Register    News    Help

Print Thread
#2674 20/12/02 06:40 AM
Joined: Dec 2002
Posts: 9
D
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Dec 2002
Posts: 9
I've got my own mIRC script I'm writing, learning as I go.

One thing I've stumbled over... I'm using a right click menu action to re-write portions of another script and then unload/reload it.

Thus far one major holdup. I don't see any way to force /write to NOT interpret what it's writing.

Here's what I'm testing with, it's a menu entry on a script...
.Add $gettok($1,5,32):{ $read(test.txt,w,*test*) | write -i$readn test.txt if $chr(36) $+ address == $$2 }

Trying to output to file, litereally "if $address == $$2". However, I get the error saying IF Unknown Command because mIRC is trying to interpret the "if $chr" part as if it were a script.

Someone clue me in on how to format the /write statement so mIRC just dumps it without trying to execute it. I've tried using $chr for the i and f, but even that returns the same error hehe. Quoting the written text also didn't help.

I'm assuming there has to be some format like the $read, whereby you could do (write,test.txt,if blablabla) so that mIRC would not try to execute the text it should be writing.

Thanks in advance. smile :tongue:

#2675 20/12/02 11:29 AM
Joined: Dec 2002
Posts: 774
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Dec 2002
Posts: 774
write -i $+ $readn "test.txt" if ( $!address == $$!2 )

seems to work


Code:
//if ( khaled isgod ) echo yes | else echo no
#2676 20/12/02 11:29 AM
Joined: Dec 2002
Posts: 2,985
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 2,985
1. There should be a space between -1 and $read.
2. "if" statements go before commands not after them.
3. Even though it works without them I think using parentheses is a good idea as it makes the structure of the script easier to read. I'd also avoid the use of pipes. You should be able to put each command on it's own line in a popup, just as you would ina remote script.

#2677 20/12/02 12:32 PM
Joined: Dec 2002
Posts: 9
D
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Dec 2002
Posts: 9
Here's the thing... I don't want to USE the "if".

The point of that command is to write to a file, specifically to write...

"if $address == $$2" to test.txt

I want the "If" to be output to the file, not interpreted as a command. The command works fine, it's executed properly and fills the variables properly. The problem is instead of writing "if" to the file, it's trying to interpret it as a command (as in, like your example, it's expecting an actual IF statement being used).

$$2 in this example is a usererid @ address pulled from a list box. Right click the name, you are presented options. One of those adds the entry to a cross referenced file maintaining permenant bans and statistics surrounding that.

The commands intent is to search an existing script full of entries like this...
on *:join: {
if $address == blablabla @ blablabla { goto 1 }
if $address == blablabla @ blablabla { goto 2 }
else return
:1
blabla
:2
blabla
}
The desired result is to right click one of the entries in the list box, and have the script create a new "if $address == blablabla { goto #}" entry at the top of the list of them after the on join.

The seek works, right clicking the list box fills the variables properly, but I cannot find any method of making it add a line "if $address == blablabla" because it's trying to interpret the IF statement instead of just dump it to file.

Hope this makes more sense now.

I will try seperating the -i$readn but I don't think that will help. frown

As for "if" usage, trust me I understand haha. I've got more than 5,000 lines of script into my little project thus far. smile

Last edited by Dark_Sky; 20/12/02 12:34 PM.
#2678 20/12/02 04:06 PM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
Like everyone else, your explanation just confused me. However, I have a couple of ideas for you to try. Assume %N is your new number to goto.

If you want to write the string literal to the text, use: write test.txt if ($ $+ address == $ $+ 2) goto %N
If you want just the $2 to be resolved and written but not the $address portion, use: write test.txt if ($ $+ address == $2) goto %N
If you want them both resolved, leave out the $+'s entirely: write test.txt if ($address == $2) goto %N


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
#2679 21/12/02 03:21 AM
Joined: Dec 2002
Posts: 332
C
Fjord artisan
Offline
Fjord artisan
C
Joined: Dec 2002
Posts: 332
i dont know that i understand completly what your doing but i think you actually want to write the word "if" to the file not use it as any sort of command ? if so mebbie try $chr(105) for i and $chr(102) for f ?

man i need glasses as i see you allready tryed that now sorry .

Last edited by Cheech; 21/12/02 03:23 AM.
#2680 21/12/02 05:13 AM
Joined: Dec 2002
Posts: 9
D
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Dec 2002
Posts: 9
Cheech is on to it. And I tried that Cheech, it still tries to interpret the "if" even if you use two $chr() $+ statements. Bizzare, maybe this is a bug?

Here's the scenario. Two scripts, seperate from eachother. Script 1 takes a right click on a known address and writes it to script 2.

The statement in script 2 needs to be (literally, open the file and output this) "if $address == whatever @ whatever { goto 1 }"

What I'm getting right now is "$address == whatever @ whatever { goto 1 }" and an error regarding the if.

It writes the statement but pulls the IF out.

For example, in script2.mrc what will be added is this:
$address == addressfrom$$2here

Notice no IF in front?

.Add $gettok($1,5,32):{ echo -s Test Fire Porn List Add for $$2 | $read(test.txt,w,*porn*) | write -il $+ $readn test.txt if $chr(36) $+ address == $$2 | echo -s readn $readn $$2 }

That's what I'm actually executing. What happens is I get an error regarding the IF, and the rest (chr36 address == etc) is actually written to the file. It puts the line in the right place (below the on join at the top of the valid list) but instead of writing the word "if" to the file it just writes everything behind it.

All the echo -s are just for testing, I always put those in my new stuff so I can understand better what mIRC is actually seeing.

Do you think it's the == that's causing it to try to interpret the IF? Maybe I should use chr(#) for those as well?

Last edited by Dark_Sky; 21/12/02 05:23 AM.
#2681 21/12/02 05:26 AM
Joined: Dec 2002
Posts: 9
D
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Dec 2002
Posts: 9
Ok, made some progress...

.Add $gettok($1,5,32):{ echo -s Test Fire Porn List Add for $$2 | $read(test.txt,w,*porn*) | write -il $+ $readn test.txt $chr(105) $+ $chr(102) $chr(36) $+ address == $$2 $chr(123) goto porn $chr(125) | echo -s readn $readn $$2 }

This outputs the proper line... output line in test.txt is...

if $address == addressfrom$$2here { goto porn }

So at least it's functional and being put on the right line etc, but I STILL get...

IF Unknown command

Every time it's run. Haha, thanks Cheech for at least getting it to output right. But it's still trying to interpret that IF. Any clues on how to stop that? Getting an eroneous error every time I run it is a pain. laugh

Along these same lines, part of this, is there a way to make a listbox scroll to the bottom automatically? I've got an on-join listbox but it just fills up below and you have to scroll down manually as people join. Is there a way to make it always stay on the newest line? Thanks again smile

Last edited by Dark_Sky; 21/12/02 05:31 AM.

Link Copied to Clipboard