mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: May 2010
Posts: 36
R
Ameglian cow
OP Offline
Ameglian cow
R
Joined: May 2010
Posts: 36
I'm looking for a way to tell if a users or variables file has been loaded. I can see how to tell if the file exists, how to tell if a specific section exists in a file, but not how to tell if the file has actually been loaded.

Thanks in advance

Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Having never done this I couldn't think of an identifier that would do this. The idea that did come to mind would be, if these are custom files, put a marker in the file. For instance, in the variable file, have a variable in it. "%varfile $true"
If it returns $true, then the file is loaded. Same with users. You can use $ulist to check for an entry in the file.

Sorry I'm not much help. I have always used the one variables file and I don't use mirc user levels.

Joined: Feb 2006
Posts: 546
J
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
you can only have a single variables and a single users file loaded at any one time. the users file is n0 under [rfiles] in mirc.ini, the variables file is n1.


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
Joined: May 2010
Posts: 36
R
Ameglian cow
OP Offline
Ameglian cow
R
Joined: May 2010
Posts: 36
having a marker of some sort, such as a special variable name, requires access to the files to place it there...

what I'm intending is to automate a setup script where I do not have access to the mirc environment at all, so there is no way to do this.

I have worked out a way to make the additions without first knowing if a file is loaded... took a few hours of experimentation to work out the procedure, but so far it seems pretty bulletproof.

Joined: May 2010
Posts: 36
R
Ameglian cow
OP Offline
Ameglian cow
R
Joined: May 2010
Posts: 36

you're correct, but an entry in mirc.ini does NOT convey any information about its state: not existence, size, or if it is currently loaded.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Originally Posted By: Richard_B

you're correct, but an entry in mirc.ini does NOT convey any information about its state: not existence, size, or if it is currently loaded.


You only asked to know if it's loaded. If the file is currently loaded, it's listed in mIRC.ini. If it's unloaded, it is not. That was what you asked about. The only way that isn't correct is if mIRC itself isn't running, or if someone edits mIRC.ini while mIRC is running (not usually a good idea), or if you are checking the wrong mIRC.ini file.

If you want to know if the file exists or the size, you'd have to use commands either in mIRC or through Windows to determine that information. From within mIRC, $file(filename.ini) will return the size (in bytes) if the file exists or NULL if it doesn't. That solves both of your secondary questions.


Invision Support
#Invision on irc.irchighway.net
Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Riamus suggestion is the best one. Check mirc.ini for a matching file name.

$readini(mirc.ini,rfiles,n0)

$readini(mirc.ini,rfiles,n1)

Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
mirc.ini isn't always in the mIRC directory. You may as well use the $mircini identifier to retrieve the path to mirc.ini, especially as it's the same number of characters smile

Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
I leave the path up to the script writers. My example was only an example. Personally, I try to use a static path whenever possible.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Originally Posted By: DJ_Sol
Personally, I try to use a static path whenever possible.


Static paths are fine for scripts you use, but if you plan to share the script with someone, it's better to use something like $mircini, $mircdir, or $scriptdir to get to where you want regardless where the person has mIRC installed and how they have it installed and where they put the script.

Btw, "mirc.ini" is actually relative. c:\mirc\mirc.ini is static. smile


Invision Support
#Invision on irc.irchighway.net
Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Do you really want to nitpick? It was an example.

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
This is not nitpicking. Using a hardcoded "mirc.ini" in there is just bad practice (using static paths is even worse). Your code is not "just an example" - it is a specific solution to a specific problem (the code corresponding to jaytea's suggestion) and thus the OP is likely to use it as is. hixxy and Riamus are aware of this possibility, hence their warning comments.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com

Link Copied to Clipboard