|
|
|
Joined: Mar 2004
Posts: 111
Vogon poet
|
OP
Vogon poet
Joined: Mar 2004
Posts: 111 |
Ok, basicly iv got a loop that creates vars along with doing other things. It needs to create the var names from reading a ini file. Basicly at the end of the loop it might have 10 temp var's with the names all coming from ini "items". Now i have a problem doing this, for reading the var it works fine like.. [ [ $+($chr(37),$readini(blah.dat,Blah,Blah)) ] ] What happends is in the end result, like in a msg or something, it returns the value of the variable. No biggie right? But when i use that for /var it does not like it. Im sure since it works like i posted for every other use im using it in, that im evaling it a wrong amount. But what would the right amount be? i tried 1 and 2 sets, and no sets of eval brackets. But what am i doing wrong? Here is more facts if you will.. Keep in mind im not posting from my comp so i cant copy paste the code. Basicly i want to make a variable with the name "%valuesname" as shown in the example of an ini file below. Blah.ini [GroupName] ItemName=ValuesName what iv done to read this variable is "[ [$+($chr(37),$readini(blah.ini,GroupName,ItemName)) ] ]" and that works fine. But i cant make /var make that variable. How do i do this? Thanks and sorry for my ramblin, im doin a buncha dif things at once lol. So forgive any miscommunication plz :tongue:
|
|
|
|
Joined: Feb 2004
Posts: 714
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 714 |
I am not sure if I undertood your issue correctly. Are you using the /var command in a script? Or is it in a command line? If it is from a command line (the editbox where you write your chat text), you should try using //var - this will first evaluate all the variable and identifiers for then set the temporary variable. If that is not what your problem is, sorry, I misunderstood it :P Zyzzyx
"All we are saying is give peace a chance" -- John Lennon
|
|
|
|
Joined: Aug 2004
Posts: 42
Ameglian cow
|
Ameglian cow
Joined: Aug 2004
Posts: 42 |
var % $+ [ $readini(blah) ] = whatever
|
|
|
|
Joined: Mar 2004
Posts: 111
Vogon poet
|
OP
Vogon poet
Joined: Mar 2004
Posts: 111 |
"var % $+ [ $readini(blah) ] = blah" Does NOT work, heck even if i use the variable sign "%" it says the readini is invalid. however if i change % to $chr(37) it atleast does not show an error. It just does not work as intented, the var command does not make the correct variable. but as i said even with "$chr(37) $+ [ $readini(Blah) ] = blah" it does not work. Im getting very stummped as to why this is not working. i can get it to read the var being created no prob but getting it to make a "var" persay is not working. What is happening in the loop is that its not being made with the /var command and instead being made by the "inc" command via the part i posted above. and by doing so it is creating a none temp variable. just like the set command does. Here is an example of my code below. It is trying to list a ini files groups basicly, and organize the groups. Sorry this wasent posted befor but im starting to think its needed so i trasnfered it from my comp via floppy magic! :tongue:
var %x = $ini(Dat\Items.dat,0)
while %x {
if [ [ $+($chr(37),$readini(Dat\Items.dat,$ini(Dat\Items.dat,%x),Type)) ] ] == $null { msg =Zeus wee $+($chr(37),$readini(Dat\Items.dat,$ini(Dat\Items.dat,%x),Type))
; var $chr(37) $+ [ $readini(Dat\Items.dat,$ini(Dat\Items.dat,%x),Type) ] = 0
var [ [ $+($chr(37),$readini(Dat\Items.dat,$ini(Dat\Items.dat,%x),Type)) ] ]
}
inc [ [ $+($chr(37),$readini(Dat\Items.dat,$ini(Dat\Items.dat,%x),Type)) ] ]
msgc $1 $readini(Dat\Items.dat,$ini(Dat\Items.dat,%x),Type) [ [ $+($chr(37),$readini(Dat\Items.dat,$ini(Dat\Items.dat,%x),Type)) ] ] $+ : $ini(Dat\Items.dat,%x)
dec %x
}
keep in mind the msg Zeus junk is just for testing reasons, and i know theres a var command behind a comment. I didnt wanna delete it atm :tongue:. Anyway plz help this tiny thing is driving me nuts!! (Btw any coding improvement notes are happily accepted 
Last edited by Zeusbwr; 23/08/04 05:23 AM.
|
|
|
|
Joined: Aug 2004
Posts: 42
Ameglian cow
|
Ameglian cow
Joined: Aug 2004
Posts: 42 |
var [ [ $+($chr(37),$readini(Dat\Items.dat,$ini(Dat\Items.dat,%x),Type)) ] ]
if the value in your items.dat = "test", then your var statement is [ %test ], which would probably be $NULL
change it to:
var [ $+($chr(37),$readini(Dat\Items.dat,$ini(Dat\Items.dat,%x),Type)) ]
(you are evaluating once too many times)
Remove one surrounding set of [] with your inc statement too
|
|
|
|
Joined: Aug 2004
Posts: 1
Mostly harmless
|
Mostly harmless
Joined: Aug 2004
Posts: 1 |
set $+(%,$readini(blah.ini,GroupName,ItemName)) value_of_the_string
|
|
|
|
Joined: Aug 2003
Posts: 314
Fjord artisan
|
Fjord artisan
Joined: Aug 2003
Posts: 314 |
mIRC seems to have a problem with attaching variables/identifiers to other parts of a variable name in /var declarations, you can see this with simply:
//var -s % $+ $me = test
The value becomes "= test" instead of the expected "test". You could remove the = of course but this leads to problems when using identifiers with a variable as a second or onwards parameter:
//var -s %i = 1 , % $+ $me $gettok(string,%i,32)
As you can see you get an invalid format error, because the variable preceeded by a comma confuses mIRC since this is the method used to declare multiple local variables. The best way to accomplish what you want, so you are able to use a value without any possible errors is to use:
//set -l % $+ $readini(Dat\Items.dat,$ini(Dat\Items.dat,%x),Type) value
Which seems to be exactly what you want. /set -l creates a local variable so it still expires at the end of the process. There's no need to escape the % with $chr(37), you may even join more parts of the variable name with $+() such as $+(%,$readini(...),.,etc.)
|
|
|
|
Joined: Mar 2004
Posts: 111
Vogon poet
|
OP
Vogon poet
Joined: Mar 2004
Posts: 111 |
Yes!!! Thank you "Sigh"!! So were dealing with a bug not a coding error? And troyboy i tried only evaling it once like that, it still didnt work. The only way i got it to work is by simply replace the text "var" with "set -l" and WOOHOO IT WORKS. And i should restate myself, this could not be a bug and more of a "working almost as intended" lol. but its all good, it works and yay! Ty!
|
|
|
|
Joined: Aug 2004
Posts: 101
Vogon poet
|
Vogon poet
Joined: Aug 2004
Posts: 101 |
set -l is undocumented strangely enough! I think it's far too usefull to be left out of the help file...
Maybe I wake up one day to notice that all my life was just a dream!
|
|
|
|
Joined: Mar 2004
Posts: 111
Vogon poet
|
OP
Vogon poet
Joined: Mar 2004
Posts: 111 |
lol really? i got an updated mirc help file so its in mine. I just dont know all the so called problems with /var. http://www.mircscripts.org/comments.php?cid=2445thats the link for the updated help file, i havent needed to use many of the undocumented stuff but none the less its a nice little update. Enjoy
|
|
|
|
Joined: Aug 2004
Posts: 42
Ameglian cow
|
Ameglian cow
Joined: Aug 2004
Posts: 42 |
//var -s % $+ [ test ] = 1 | //echo -s %test = 1 //var -s % $+ [ test ] 1 | //echo -s %test 1 I found that I had run into this problem 2 years ago (mirc 5.91) when I scripted my TBserv file sharing script. my code was: var %namecount [ $+ [ %count ] ] 1 And it still works in mirc 6.16. As for "set -l", where is the updated documentation? I couldnt find it in the link from the previous post.
|
|
|
|
Joined: Aug 2003
Posts: 314
Fjord artisan
|
Fjord artisan
Joined: Aug 2003
Posts: 314 |
I explained why it was important to be able to include the = sign: //var -s %i = 1 , % $+ $me $gettok(string,%i,32)
As you can see you get an invalid format error, because the variable preceeded by a comma confuses mIRC since this is the method used to declare multiple local variables.
Of course with /set that = sign isn't needed which is why /set -l is better to declare local variables of this nature. But if you stick to your method you don't even need evaluation brackets, //var %namecount $+ %count 1 is fine
|
|
|
|
|
|
|
|