mIRC Home    About    Download    Register    News    Help

Topic Options
#144793 - 14/03/06 03:39 PM writing variables in .txt
TKS Offline
Nutrimatic drinks dispenser

Registered: 14/03/06
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

Top
#144794 - 14/03/06 05:09 PM Re: writing variables in .txt
Pap Offline
Ameglian cow

Registered: 02/03/03
Posts: 32
try

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

Top
#144795 - 14/03/06 05:22 PM Re: writing variables in .txt
hixxy Offline
Hoopy frood

Registered: 06/09/05
Posts: 2876
The only time that should happen is if you typed /write from the commandline.

Top
#144796 - 14/03/06 06:09 PM Re: writing variables in .txt
TKS Offline
Nutrimatic drinks dispenser

Registered: 14/03/06
Posts: 9
Quote:
The only time that should happen is if you typed /write from the commandline.


well I don't cool

Top
#144797 - 14/03/06 06:15 PM Re: writing variables in .txt
TKS Offline
Nutrimatic drinks dispenser

Registered: 14/03/06
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

Top
#144798 - 14/03/06 08:31 PM Re: writing variables in .txt
Pap Offline
Ameglian cow

Registered: 02/03/03
Posts: 32
Could you paste your entire script please?

Top
#144799 - 14/03/06 08:33 PM Re: writing variables in .txt
Pap Offline
Ameglian cow

Registered: 02/03/03
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?

Top
#144800 - 14/03/06 08:34 PM Re: writing variables in .txt
mIRCManiac Offline
Hoopy frood

Registered: 05/02/05
Posts: 681
Loc: Your dreams ;)
Worked here 6.17
_________________________
mIRCManiac

Top
#144801 - 14/03/06 08:58 PM Re: writing variables in .txt
TKS Offline
Nutrimatic drinks dispenser

Registered: 14/03/06
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 -


Edited by TKS (14/03/06 09:00 PM)

Top
#144802 - 14/03/06 09:00 PM Re: writing variables in .txt
MikeChat Offline
Hoopy frood

Registered: 12/12/02
Posts: 1245
Loc: California, doooood
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)

Top
#144803 - 14/03/06 09:03 PM Re: writing variables in .txt
hixxy Offline
Hoopy frood

Registered: 06/09/05
Posts: 2876
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]
  }
}

Top
#144804 - 14/03/06 09:04 PM Re: writing variables in .txt
TKS Offline
Nutrimatic drinks dispenser

Registered: 14/03/06
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

Top
#144805 - 14/03/06 09:09 PM Re: writing variables in .txt
MikeChat Offline
Hoopy frood

Registered: 12/12/02
Posts: 1245
Loc: California, doooood
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 -_

Top
#144806 - 14/03/06 09:18 PM Re: writing variables in .txt
MikeChat Offline
Hoopy frood

Registered: 12/12/02
Posts: 1245
Loc: California, doooood
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


Edited by MikeChat (14/03/06 09:22 PM)

Top
#144807 - 14/03/06 09:50 PM Re: writing variables in .txt
TKS Offline
Nutrimatic drinks dispenser

Registered: 14/03/06
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?

Top
#144808 - 14/03/06 09:56 PM Re: writing variables in .txt
TKS Offline
Nutrimatic drinks dispenser

Registered: 14/03/06
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

Top
#144809 - 14/03/06 11:20 PM Re: writing variables in .txt
MikeChat Offline
Hoopy frood

Registered: 12/12/02
Posts: 1245
Loc: California, doooood
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)

Top
#144810 - 15/03/06 04:11 AM Re: writing variables in .txt
DaveC Offline
Planetary brain

Registered: 26/09/03
Posts: 4230
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 )

Top
#144811 - 21/03/06 06:00 PM Re: writing variables in .txt
TKS Offline
Nutrimatic drinks dispenser

Registered: 14/03/06
Posts: 9
Thank you for your detailed info, was exactly what I needed! cool

Top