mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
While this code works properly for me, the person I wrote it for states that it's not writing to the ini file.
I've run out of ideas as to why it might not be. I don't know if this is something that can be handled via the script or not, but in case it can, I have included the script here
Code:
alias askq { 
  if ($1) { 
    var %a = $($+(%,questioncounter,$1),2) 
    if $read("c:\mircstats\stats questions.txt",%a) { 
      msg $1 $ifmatch 
      timerask $+ $1 0 30 askq $1 
    } 
    else {
      .msg $1 Thanks for taking part
      dontask $1
    } 
  } 
} 
alias dontask { 
  if ($1) { 
    $+(.timer,ask,$1) off 
    unset  $+(%,questioncounter,$1) 
    unset $+(%,chan,$1)
  } 
  else { 
    .timerask* off 
    unset  %questioncounter* 
  } 
} 
on *:TEXT:*:*: { 
  if (!stop* iswm $1) { dontask $nick } 
  elseif ($target ischan) { 
    if (!addnick* iswm $1) { 
      .msg $nick Please answer the questions in this pm window 
      .msg $nick If you don't have an answer or don't want to answer a question, just enter a dummy response..NOTE: Hitting Enter/Return alone will not work. 
      .msg $nick I regret that this is necessary, however, I was unable to allow for a null (empty) response. 
      set $+(%,chan,$nick) $chan 
      set $+(%,questioncounter,$nick)  1 
      askq $nick 
    } 
  } 
  else {
    if $($+(%,chan,$nick),2) {
      .writeini c:\mircstats\Stats.ini $nick $($+(%,questioncounter,$nick),2) $1-
      inc $+(%,questioncounter,$nick)
      askq $nick
    } 
  }
} 
on *:EXIT: { dontask } 
on *:PART:#: { 
  if $chan == $($+(%,chan,$nick),2) && $timer(ask $+ $nick) { dontask $nick } 
} 
on *:QUIT: { 
  if ($timer(ask $+ $nick)) { dontask $nick } 
} 
on *:nick:{ 
  if ($timer(ask $+ $nick)) { dontask $nick | askq $newnick } 
} 


Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031
Are they using Windows Vista ?

Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
It's unlikely, but if the file has reached a certain size you will need to use the -n switch to write to the file. Worth a shot.

Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
@Rock: Already thought of that, and the answer is no.
@hixxy: This is occurring even if the file doesn't already exist, but only for the original requester.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Are you positive the user has this folder:

c:\mircstats\

I've run into people who *think* they have it, but it isn't spelled correctly.


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
When I write scripts for other people to use and they involve files in folders, I put the folder in my mirc folder. Also, my personal taste, I don't put mirc in its own folder. It is in a folder and in that folder would be other folders. Scripts folder holds my misc. scripts. Sounds holds my sound files. This is where I would personally put your stats folder.

Using mirc as I have described, now I just say:

\mircstats\file.ini

You can even go as far as creating the directory with /mkdir.

It doesn't matter what directory they have this in or where in the directory. I've used $mircdir but I tend to get errors if there are any spaces in the file path, no I've switched back to doing it as I've explained. I hope I've made sense.

Joined: Apr 2004
Posts: 759
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
If you distribute scripts that depend on files use $scriptdir then it doesnt matter where the users loads the zip to.

I have no clue why it wouldn't write though if its not any of the above. Maybe send him a debug alias to see if that folder is a dir the file is a file and wheter all the vars are set ?


$maybe
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
My scripts end up in their own folders inside mIRC's, but I rarely ever use $mircdir. As mentioned, $scriptdir is more helpful. If the user wants the stats in its own folder as shown, then there isn't any reason why that cannot be done.

As far as spaces in filenames... if you use an identifier, spaces don't matter. Otherwise, they do and you'll want to use $qt() or else $+(",whatever,") to deal with it.


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
Well I didn't like $scriptdir. I'll tell you why.

It seemed to me that the $scriptdir identifier pointed to whatever folder my script editor was set to. My main code is in its own folder with its dependent files. This folder is located in the main script folder that holds mirc.exe, scripts folder, sounds folder, etc.

Ok so I open the script editor for the first time and it opens to the main directory that mirc.exe is in. Now I want to load my main files which are in their own directory. I personally use ctrl + L to load files, way faster than typing. SO I browse to them and load them. Now when I open my script editor and go to load it automatically points to this subdirectory that has my main script files in it. Now, from my experience, $scriptdir points to this directory and not my main folder that has mirc.exe in it. Make sense? This has been my experience and why I do not use $scriptdir.

Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Quote:
Now, from my experience, $scriptdir points to this directory and not my main folder that has mirc.exe in it.

- Yes, $scriptdir isn't meant to point the mIRC installation directory, it's meant to point to the directory containing the currently executing script.

$mircdir points to the location of your mIRC settings (not necessarily the mirc.exe!). IMO $mircdir (or more specifically a subdirectory of it) is ideally the one that scripters should use for saving settings.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
To be compliant with windows it should ideally save settings in a mIRC\<script name subfolder>\ folder in the application data folder.

Personally I always save settings to the script's directory, because I find nothing more annoying than extracting a script to a folder on my desktop but having its config appear in my mIRC directory. The mIRC directory is for mIRC, not for scripts to save their settings.

Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Quote:
To be compliant with windows it should ideally save settings in a mIRC\<script name subfolder>\ folder in the application data folder.
Exactly, and that's just where my $mircdir points to. And as of the next version of mIRC it'll be the place everyone else's will point to aswell unless they explicitly specify otherwise.

By contrast it could entirely be possible that an administrator on a system would install mIRC scripts to a subdirectory of the mIRC installation folder which may or may not be writeable by any other user, making $scriptdir a risky proposition.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
The same could be said about $mircdir though, unless the ability to use a mirc.ini from anywhere you like is removed and you're forced to have it in the appdata folder.

If an administrator installs mIRC to c:\program files\mIRC\, then a non-admin would probably not be able to use files in that directory.

I think the only way to ensure your settings are stored in a writeable location is to store them in appdata no matter where mIRC itself is, in which case an $appdata identifier would be useful.

Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Yeah but if mirc.ini is in a non-writeable location then the user's already got problems, so it kind of stands to reason that it wouldn't be a big deal if the script fails at that point also.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
That's a good point actually.

I still think an $appdata identifier would be useful though. Or even better, a built-in way to save/load script settings. savesetting topic item data $getsetting(topic,item) (would automatically read a setting for $script - you could also optionally supply a script name you want to read settings for as your first parameter). This could all be done in memory and then saved when mIRC exits in the appdata folder.

Joined: Apr 2004
Posts: 759
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
$nofile($mircini) ? :P

I still prefer $scriptdir dont like scripts putting stuff where i don't expect them to pop up.


$maybe
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
I meant that $appdata would return the application data folder for the current user (usually C:\Documents And Settings\<username>\Application Data)

Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Quote:
Are you positive the user has this folder:

c:\mircstats\


Yes, I'm positive, since the text file with the questions is in that directory, and it reads the questions correctly. If the name was spelled incorrectly, then the bot wouldn't be asking the questions.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Well, I guess I'd echo this:

$($+(%,chan,$nick),2)

right before that IF line. See what it's echoing. That is most likely where it's failing.


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
Yeah, also

echo -a $file(c:\mircstats\Stats.ini) $nick $($+(%,questioncounter,$nick),2) $1-


About the $mircdir/$scriptdir debate.

I choose to not use $scriptdir because it is not stable. It can change. I do not use $mircdir because it doesn't support a file path with spaces. I receive errors like

"C:/Documents" no file (example, not exact error msg)

The script I am developing I have named SoulFly. So the main folder is named SoulFly_v1. In this folder is my mirc.exe file with it's neccesary .ini support files. Logs & Sounds folder is also in my SoulFly_v1 directory. My personal scripts neccesary files are in their own folder called SoulFly. SoulFly.mrc and SoulFly.ini are two files for example.

I was having issues with mdx and other dll's using $mircdir when people wanted to run the script from their desktop "C:Documents and Settings\USER\Desktop\" or from My Documents or Program Files. Now I point to the dll's like this:

Quote:
SoulFly\dll\mdx.dll


Now users may put my script wherever they like and it works.

This is my personal experience and solution. Sorry to go off topic, I just wanted to be clear about errors I have found using $mircdir and $scriptdir and why I do not suggest using them.

Page 1 of 2 1 2

Link Copied to Clipboard