mIRC Home    About    Download    Register    News    Help

Print Thread
#84314 27/05/04 09:36 PM
Joined: Feb 2003
Posts: 38
C
cvic Offline OP
Ameglian cow
OP Offline
Ameglian cow
C
Joined: Feb 2003
Posts: 38
I have a text file called file.txt with one line.
The line looks like this: foo=%bar

The variable %bar contains some text.

If I read from the = character with this code:
//echo -a $gettok($read(file.txt,1),2,61) the result will be %bar.

Is it possible to retrieve what the variable contains?

#84315 27/05/04 09:41 PM
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
$eval($gettok($read(file.txt,1),2,61),2)


Spelling mistakes, grammatical errors, and stupid comments are intentional.
#84316 27/05/04 10:13 PM
Joined: Feb 2003
Posts: 38
C
cvic Offline OP
Ameglian cow
OP Offline
Ameglian cow
C
Joined: Feb 2003
Posts: 38
Thank you.

Didn't know about $eval actually.

$eval(text,N)
Evaluates the contents of text N times. If N isn't specified, the default is N = 1. If N is zero, text is not evaluated.


But I don't get why we should use "2" here...?

#84317 27/05/04 10:39 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hi,

the second parameter N in the $eval identifier, determines how many times you want the 1st parameter evaluated.

--------------------------------------------------------------------------------------------

In your example:

$eval($gettok($read(file.txt,1),2,61),0)

--> Evaluates your input 0 times. Result: $gettok($read(file.txt,1),2,61)


$eval($gettok($read(file.txt,1),2,61),1)

--> Evaluates your input 1 time. Result: %bar


$eval($gettok($read(file.txt,1),2,61),2)

--> Evaluates your input 2 times. In other words, it firsts evaluates once, which returns %bar, and then it evaluates again, in other words it evaluates %bar, which will be the value that
%bar contains.



--------------------------------------------------------------------------------------------

So the N determines how many times you want the input parameter evaluated.

Hope this helped you understand the functionality of $eval.


Greets


Edit: Another example regarding $eval can be found here


Last edited by FiberOPtics; 27/05/04 10:52 PM.

Gone.
#84318 28/05/04 02:39 PM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
Another example:

//tokenize 32 $!2 2 | echo -a $eval($1,0) $eval($1,1) $eval($1,2)

$!2 means that $2 is not evaluated, same as $eval($2,0)

In this example:

$1 evaluated zero times is $1
$1 evaluated once is $2 ($2 not evaluated)
$1 evaluated twice is 2 ($2 evaluated)

It will echo $1 $2 2


New username: hixxy

Link Copied to Clipboard