mIRC Home    About    Download    Register    News    Help

Print Thread
writing variables in .txt #144793 14/03/06 03:39 PM
Joined: Mar 2006
Posts: 9
T
TKS Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Mar 2006
Posts: 9
Hello all,

I'm trying to write in an .txt file. So far everything goes well. The problems start when trying to write different variables in one line. Simple said, when I look at the .txt is shows the TEXT %var1, instead of the value of %var1 (can be both text and non-text) Simple said my script looks like this:

Code:
on text
set %var1 -
set %var2 -
set %var3 -
write test.txt %var1 $+ _ $+ %var2 $+ _ $+ %var3

When I open the .txt it shows %var1_%var2_%var3 and NOT
-_-_-

So actually what i want to know is how to write the value of a variable in a .txt and not the name smirk

Thanks for an reply's grin

Re: writing variables in .txt #144794 14/03/06 05:09 PM
Joined: Mar 2003
Posts: 32
P
Pap Offline
Ameglian cow
Offline
Ameglian cow
P
Joined: Mar 2003
Posts: 32
try

write test.txt $eval(%var1 $+ _ $+ %var2 $+ _ $+ %var3)

Re: writing variables in .txt #144795 14/03/06 05:22 PM
Joined: Sep 2005
Posts: 2,876
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,876
The only time that should happen is if you typed /write from the commandline.

Re: writing variables in .txt #144796 14/03/06 06:09 PM
Joined: Mar 2006
Posts: 9
T
TKS Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Mar 2006
Posts: 9
Quote:
The only time that should happen is if you typed /write from the commandline.


well I don't cool

Re: writing variables in .txt #144797 14/03/06 06:15 PM
Joined: Mar 2006
Posts: 9
T
TKS Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Mar 2006
Posts: 9
Quote:
try

write test.txt $eval(%var1 $+ _ $+ %var2 $+ _ $+ %var3)


Tried but doesn't work. The variables ARE valid, IE they show up in the remote.ini file

Re: writing variables in .txt #144798 14/03/06 08:31 PM
Joined: Mar 2003
Posts: 32
P
Pap Offline
Ameglian cow
Offline
Ameglian cow
P
Joined: Mar 2003
Posts: 32
Could you paste your entire script please?

Re: writing variables in .txt #144799 14/03/06 08:33 PM
Joined: Mar 2003
Posts: 32
P
Pap Offline
Ameglian cow
Offline
Ameglian cow
P
Joined: Mar 2003
Posts: 32
Oh, I have an idea/suggestion: don't use "%var1" "%var2", etc. try using meaningful variable names. Maybe mIRC is having issues with those names?

Re: writing variables in .txt #144800 14/03/06 08:34 PM
Joined: Feb 2005
Posts: 681
M
mIRCManiac Offline
Fjord artisan
Offline
Fjord artisan
M
Joined: Feb 2005
Posts: 681
Worked here 6.17

Re: writing variables in .txt #144801 14/03/06 08:58 PM
Joined: Mar 2006
Posts: 9
T
TKS Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Mar 2006
Posts: 9
Quote:
Could you paste your entire script please?


Code:
on 1:TEXT:!add*:#: {
  if (($chan == %chan) && ($2 != $null)) {
    set % $+ $2 $+ .name -
    set % $+ $2 $+ .surname -
    set % $+ $2 $+ .address -
    set % $+ $2 $+ .phone -
    set % $+ $2 $+ .spend -
    set % $+ $2 $+ .advance -
    set % $+ $2 $+ .coffee -
    set % $+ $2 $+ .final -
    write template.txt % $+ $2 $+ .name _ % $+ $2 $+ .surname _ % $+ $2 $+ .address _ % $+ $2 $+ .phone _ % $+ $2 $+ .spend _ % $+ $2 $+ .advance _ % $+ $2 $+ .coffee _ % $+ $2 $+ .final
  }
}


So what I want is a line written in my .txt which shows -_-_-_(etc). May look strange, but the - are editable when the script continues, the _ are seperators for my php site.

Anyway, the var
Code:
 % $+ $2 $+ .phone 
is beiing set, so this var will be named %Eric.phone and has a value of -

Last edited by TKS; 14/03/06 09:00 PM.
Re: writing variables in .txt #144802 14/03/06 09:00 PM
Joined: Dec 2002
Posts: 1,245
M
MikeChat Offline
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
the only thing i can think of is they have an alias that is /write -n
or some other /write alias that is replacing the %variable with $+(%,variable)

Re: writing variables in .txt #144803 14/03/06 09:03 PM
Joined: Sep 2005
Posts: 2,876
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,876
Code:
on 1:TEXT:!add*:#: {
  if (($chan == %chan) && ($2 != $null)) {
    set % $+ $2 $+ .name -
    set % $+ $2 $+ .surname -
    set % $+ $2 $+ .address -
    set % $+ $2 $+ .phone -
    set % $+ $2 $+ .spend -
    set % $+ $2 $+ .advance -
    set % $+ $2 $+ .coffee -
    set % $+ $2 $+ .final -
    write template.txt [color:red]$eval([/color]% $+ $2 $+ .name _ % $+ $2 $+ .surname _ % $+ $2 $+ .address _ % $+ $2 $+ .phone _ % $+ $2 $+ .spend _ % $+ $2 $+ .advance _ % $+ $2 $+ .coffee _ % $+ $2 $+ .final[color:red],2)[/color]
  }
}

Re: writing variables in .txt #144804 14/03/06 09:04 PM
Joined: Mar 2006
Posts: 9
T
TKS Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Mar 2006
Posts: 9
Quote:
the only thing i can think of is they have an alias that is /write -n
or some other /write alias that is replacing the %variable with $+(%,variable)


Running plain mIRC 6.17 confused

Re: writing variables in .txt #144805 14/03/06 09:09 PM
Joined: Dec 2002
Posts: 1,245
M
MikeChat Offline
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
Quote:
Quote:
Could you paste your entire script please?


Code:
on 1:TEXT:!add*:#: {
  if (($chan == %chan) && ($2 != $null)) {
    set % $+ $2 $+ .name -
    set % $+ $2 $+ .surname -
    set % $+ $2 $+ .address -
    set % $+ $2 $+ .phone -
    set % $+ $2 $+ .spend -
    set % $+ $2 $+ .advance -
    set % $+ $2 $+ .coffee -
    set % $+ $2 $+ .final -
    write template.txt % $+ $2 $+ .name _ % $+ $2 $+ .surname _ % $+ $2 $+ .address _ % $+ $2 $+ .phone _ % $+ $2 $+ .spend _ % $+ $2 $+ .advance _ % $+ $2 $+ .coffee _ % $+ $2 $+ .final
  }
}


you went through the trouble of making the vars, and then didnt use them.

try
Code:
    write template.txt $(% $+ $2 $+ .name $+  _ ,2)

Or $eval($+(%,$2,.name,_),2)


see if it writes correctly -_

Re: writing variables in .txt #144806 14/03/06 09:18 PM
Joined: Dec 2002
Posts: 1,245
M
MikeChat Offline
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
or maybe
Code:
on 1:TEXT:!add*:#: {
  if ($chan == %chan) {
    set %nick $$2
    set %nick $+ .name - 
    set %nick $+ .surname -
    set %nick $+ .address -
    set %nick $+ .phone -
    set %nick $+ .spend -
    set %nick $+ .advance -
    set %nick $+ .coffee -
    set %nick $+ .final -
    write template.txt %nick.name _ %nick.surname _ %nick.address _ %nick.phone _ %nick.spend _ %nick.advance _ %nick.coffee _ %nick.final
  }
}


on 1:TEXT:!add*:#: {
if ($chan == %chan) {

could be
Code:
on 1:TEXT:!add*:#yourchannel: {
  set %nick $$2
  set %nick $+ .name - 
  set %nick $+ .surname -
  set %nick $+ .address -
  set %nick $+ .phone -
  set %nick $+ .spend -
  set %nick $+ .advance -
  set %nick $+ .coffee -
  set %nick $+ .final -
  write template.txt %nick.name _ %nick.surname _ %nick.address _ %nick.phone _ %nick.spend _ %nick.advance _ %nick.coffee _ %nick.final
  unset %nick.*
}


unless the channel name needs to be dynamic

Last edited by MikeChat; 14/03/06 09:22 PM.
Re: writing variables in .txt #144807 14/03/06 09:50 PM
Joined: Mar 2006
Posts: 9
T
TKS Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Mar 2006
Posts: 9
Quote:


you went through the trouble of making the vars, and then didnt use them.

try
Code:
    write template.txt $(% $+ $2 $+ .name $+  _ ,2)

Or $eval($+(%,$2,.name,_),2)


see if it writes correctly -_


it works smile

but what do you mean with not using the vars?

Re: writing variables in .txt #144808 14/03/06 09:56 PM
Joined: Mar 2006
Posts: 9
T
TKS Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Mar 2006
Posts: 9
Quote:
or maybe
Code:
on 1:TEXT:!add*:#: {
  if ($chan == %chan) {
    set %nick $$2
    set %nick $+ .name - 
    set %nick $+ .surname -
    set %nick $+ .address -
    set %nick $+ .phone -
    set %nick $+ .spend -
    set %nick $+ .advance -
    set %nick $+ .coffee -
    set %nick $+ .final -
    write template.txt %nick.name _ %nick.surname _ %nick.address _ %nick.phone _ %nick.spend _ %nick.advance _ %nick.coffee _ %nick.final
  }
}


on 1:TEXT:!add*:#: {
if ($chan == %chan) {

could be
Code:
on 1:TEXT:!add*:#yourchannel: {
  set %nick $$2
  set %nick $+ .name - 
  set %nick $+ .surname -
  set %nick $+ .address -
  set %nick $+ .phone -
  set %nick $+ .spend -
  set %nick $+ .advance -
  set %nick $+ .coffee -
  set %nick $+ .final -
  write template.txt %nick.name _ %nick.surname _ %nick.address _ %nick.phone _ %nick.spend _ %nick.advance _ %nick.coffee _ %nick.final
  unset %nick.*
}


unless the channel name needs to be dynamic


yes chan needs to be dynamic wink

and somehow your solution is not working. It writes though, but the vars (needed for further editing) are named %nick.address etc. So not the unique one's i need like %eric.address or %myla.address

Re: writing variables in .txt #144809 14/03/06 11:20 PM
Joined: Dec 2002
Posts: 1,245
M
MikeChat Offline
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
Quote:
yes chan needs to be dynamic wink

and somehow your solution is not working. It writes though, but the vars (needed for further editing) are named %nick.address etc. So not the unique one's i need like %eric.address or %myla.address


oh ok, the nick ($2) being kept as a var wasn't obvious from what i saw, even though you had shown each var having the value of - (which I took to be a substitute for what you are really setting it to)

Re: writing variables in .txt #144810 15/03/06 04:11 AM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
I think for a start u might have missed a point about dynamicly named vars (then again my head started to hurt trying to read this thread)

//set % $+ $2 $+ .name -
//echo $(% $+ $2 $+ .name -,2)

more preferably
//set $+(%,$2,.name) -
//echo $($+(%,$2,.name),2)

The reason for this is, in the SET your not evaluating the var name at all the word SET well cause mirc to go "oh wow i better not get the contents of this since im setting something into it.
aka
//SET %blah frog
//SET %blah dog
it would be no good if in the second line mirc went "well %Blah is frog, so we have //SET frog dog"

And in any access of the var, mirc needs to be told, it needs to evaluate this twice instead of once, becuase the first evaluation puts the var name together, the second then evalautes it for its contents.
//echo $+(%,bl,ah)
%blah
//echo $($+(%,bl,ah),2)
dog

Try this ** Im assuming this is example code, as you might as well just /write template.txt -_-_-_-_-_-_-_- **
Code:
on 1:TEXT:!add*:#: {
  if (($chan == %chan) && ($0 >= 2)) {
    set $+(%,$2,.name) - 
    set $+(%,$2,.surname) -
    set $+(%,$2,.address) -
    set $+(%,$2,.phone) -
    set $+(%,$2,.spend) -
    set $+(%,$2,.advance) -
    set $+(%,$2,.coffee) -
    set $+(%,$2,.final) -
    write template.txt $+( $($+(%,$2,.name),2) , _ , $($+(%,$2,.surname),2) , _ , $($+(%,$2,.address),2) , _ , $($+(%,$2,.phone),2) , _ , $($+(%,$2,.spend),2) , _ , $($+(%,$2,.advance),2) , _ , $($+(%,$2,.coffee),2) , _ , $($+(%,$2,.final),2) )
  }
}


just to be clear $($+(%,$2,.name),2) is accessing the dynamic var, around that is $+( var , _ , var , _ , etc etc )

Re: writing variables in .txt #144811 21/03/06 06:00 PM
Joined: Mar 2006
Posts: 9
T
TKS Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Mar 2006
Posts: 9
Thank you for your detailed info, was exactly what I needed! cool