mIRC Homepage

Why can't mIRC write more than 64KB in ini file?

Posted By: saragani

Why can't mIRC write more than 64KB in ini file? - 12/07/03 08:33 AM

Using writeini I'm getting an error while trying to write more than 64KB into an ini file.

Then I tried to use the -n switch which suppose to let me write more than 64 KB. (The help file says "mIRC will attempt to write .....").

Is it suppose to write more than 64KB, or will it just attemp, and then do nothing??

Is there any way that I can write more than 64KB?
Posted By: Jesper

Re: Why can't mIRC write more than 64KB in ini file? - 12/07/03 12:41 PM

use /write -n

Code:
/writeini -n <inifile> <section> <item> <value>
Writes to files in the standard INI file format.

If the -n switch is specified, mIRC will attempt to write to the .ini file even if it is larger than 64k.
Posted By: feud

Re: Why can't mIRC write more than 64KB in ini file? - 12/07/03 05:10 PM

not only did you tell him to use the wrong command "/write -n" instead of "/writeini -n", you didn't even read his post. he said he has already tried that. good work.

to original poster: i'm assuming that because the help file says that /writeini will 'attempt' to write to the file, it might not work in all cases. maybe try storing your data in a different format.
Posted By: KingTomato

Re: Why can't mIRC write more than 64KB in ini file? - 12/07/03 05:54 PM

tisk tisk jesper..

anyways, i believe its a windows issue with writing to an ini file. If its not window, it may be a mirc issuaue with only allowing a 64k buffer.

What exactly are you writing to an ini to make one that large? You think of breaaking your ini's down into parts. If your using an ini for a user base, you may also consider hash tables. They are both more efficient and much easier to deal with (imo).

/help /hmake >:D
Posted By: codemastr

Re: Why can't mIRC write more than 64KB in ini file? - 12/07/03 06:04 PM

I'm looking at microsoft's documentation on how to write to ini files and I don't see any builtin limit, so it must be mIRC...
Posted By: KingTomato

Re: Why can't mIRC write more than 64KB in ini file? - 12/07/03 06:06 PM

Can you point me to the page? I'd like to learn about them while im at it laugh
Posted By: codemastr

Re: Why can't mIRC write more than 64KB in ini file? - 12/07/03 06:12 PM

Gotta find the page, I have the documentation locally :P Basically I assumed that mIRC uses the Windows function WritePrivateProfileString which is the only Windows function I know of that writes to an ini (note that this function is obsolete and the documentation says don't use ini's, use the registry). The information is really more how to write to ini's using C/C++ than in general, but if you're interested, http://msdn.microsoft.com/library/defaul...ofilestring.asp
Posted By: KingTomato

Re: Why can't mIRC write more than 64KB in ini file? - 12/07/03 06:21 PM

Thats what i wanted, was C\C++. I am getting into windows api, and just want to fool with saving also. I figure i'll save dialog information to an ini to kill two birds with one stone. laugh ty
Posted By: codemastr

Re: Why can't mIRC write more than 64KB in ini file? - 12/07/03 06:24 PM

If you are learning Windows API, I'd recommend two books to you, "Programming Windows 5th Edition" by Charles Petzold. That book is considered the bible of winapi, and "Programming Applications for Microsoft Windows" by Jeffery Richter. That one gives you info on some stuff that is very useful, like how to work with threads and things like that. They are very useful books to have (not cheap though).
Posted By: KingTomato

Re: Why can't mIRC write more than 64KB in ini file? - 12/07/03 06:31 PM

Yes, i did happen to go out and but the .net edition of windows api, but im starting to believe i need to crawl before i can walk. This book looked like it was from a beginer's standpoint, but as i go further they start with "the dialog that ate cinccinatti".. Over 20 id's >:\

I'll have to consider making a run to the good ol barns and nobles >:D
Posted By: codemastr

Re: Why can't mIRC write more than 64KB in ini file? - 12/07/03 08:14 PM

Nah, b&n rips you off on computer books, www.bookpool.com has the best prices I've found, but they only sell computer and technology books.
Posted By: KingTomato

Re: Why can't mIRC write more than 64KB in ini file? - 12/07/03 09:02 PM

One problem--im 17 and no credit card >:D Other than that, i can buy online.. heh

EDIT: Besides i think i have a free book coming to me with that book club deal watever. >:D
Posted By: Jesper

Re: Why can't mIRC write more than 64KB in ini file? - 12/07/03 11:06 PM

Oooops, my bad, am truly sorry for that. frown
Posted By: codemastr

Re: Why can't mIRC write more than 64KB in ini file? - 12/07/03 11:49 PM

You need to do like I did,

"Mom, consider this, it's 2am, I'm in the middle of nowhere, out of money, and the car just ran out of gas... Do you want me to have to wait at some run down gas station in the middle of nowhere for hours until you get there to pay for gas for me? Wouldn't it just be better to give me a credit card in case of an emergency?"

It works smile
Posted By: Jesper

Re: Why can't mIRC write more than 64KB in ini file? - 12/07/03 11:52 PM

hahah that was a good one code, does it actually work ?
Posted By: codemastr

Re: Why can't mIRC write more than 64KB in ini file? - 12/07/03 11:54 PM

Well I've had a credit card since I started driving (17), so it worked for me smile
Posted By: saragani

Re: Why can't mIRC write more than 64KB in ini file? - 13/07/03 11:49 AM

One problem that I have is that I don't know how to use hash tables.
Posted By: KingTomato

Re: Why can't mIRC write more than 64KB in ini file? - 14/07/03 02:36 AM

Well, to make one use
/hmake <name> <size>

the size is generall the square root of how many items you expct to have. For example if you expect to have 100 items, 10 is fine. So lets say we're storing acronyms for chatting. 100, is a good number, so we'll use 10

Code:
/hmake acronym 10


Okat, so now we have the hash table, now we want to add some items. Here is where /hadd come in. You simply type /hadd <hash_table> <value_name> <value>. So for example, lets add a few acrnyms to our hash table..

Code:
/hadd acronym afk Away From Keyboard
/hadd acronym brb Be Right Back
/hadd acronym lol Laughing Out Loud
/hadd acronym ttyl Talk To You Later


Okay, so not we have a had table, and four values. Now, we have the data but how do we use it? Well, for this example lets just use a simple on input event. We will take the user's input, look for our acronyms, and then replace as needed.

For matching and checking a value exists in the has table, we use $hget(hash_table, value_name) (And just $hget(<hash_table>) to see if the table exists). If it returns a value, the item is set, otherwise no value exists. Lets cycle through the words

Code:
on *:INPUT:#: {
  if ($left($1, 1) !isin $+(/,$readini($mircini,text,commandchar))) {
    ; check if the hashtable exists
    if ($hget(acronym)) {
      var %w = 1, %word, %msg
      while (%gettok($1-, %w, 32)) {
        %word = $ifmatch
        if ($hget(acronym, %word)) %text = %text $+([,$ifmatch,])
        else %text = %text %word
        /inc %w
      }
      /msg $active %msg
      /halt
    }
  }
}


Okay, so now we went through each word, found any and all matching words, and replaced them. Now, the message shoudld be like this:

Input: that was a funny joke, lol
Output: that was a funny joke, [Laughing Out Loud]

Okay, now we have all the information, but how do we save it? Well, now we get to /hsave and /hload, which will save and load our table respectivly. Okay, so say we want all the acronyms save to a file called acronyms.hsh when we close mirc. To do this, we use on EXIT, and the hsave command.

Code:
on *:EXIT: {
  ; if our table exists (was created)
  if ($hget(acronym)) {
    ; save it (-o means overwrite existing file (we don't need it anymore))
    /hsave -o acronym acronyms.hsh
  }
}


Okay, so now we made our table, we added information, we used the table and saved it--now what. Well, now what we do is load it on our next running of tribes. For this we look at on start.

Code:
on 1:START: {
  ; intialize hash table
  /hmake acronym 10
  ; now, if the file we want to load from existsa, load it..
  if ($isFile(acronyms.txt)) /hload acronym acronyms.hsh
}


And there we go. Now we have a hash table that is used to replace acronyms. Its a simple script, but is a nice little beginner's starting point. Hope this helps, and if you have any questions, thats what the forums are here for!

grin
Posted By: saragani

Re: Why can't mIRC write more than 64KB in ini file? - 14/07/03 11:48 AM

W00t grin grin grin

This is a very nice example which covers it all.

Thanks. It was realy helpfull. Now I jsu need to convert my script to a hash table based.

Thanks
Posted By: Dr4g0n

Re: Why can't mIRC write more than 64KB in ini file? - 16/07/03 03:44 PM

/help /write
Posted By: Raccoon

Re: Why can't mIRC write more than 64KB in ini file? - 17/07/03 08:11 AM

Sorry, I know I'm a bit late replying on this post... but it just caught my eye and was never addressed.

The reason INI files are limited to 64k, is because the API functions (Microsoft) are still 16bit. (Probably for compatibility, I dunno. Yes, they could have been made 32bit, but they were not.)

As such, just like old text editors, INI files are limited to 65536 bytes (2^16). This is not a limitation that Khaled created, though I'm certain there are many work arounds available today. Such work-arounds may even lift the ~950 character "Line Too Long" limit, and allow $ini() to work with >64K files.

- Raccoon
Posted By: tomalak16

Re: Why can't mIRC write more than 64KB in ini file? - 27/07/03 04:56 PM

Quote:
/help /write


Gosh, Dr4g0n, what a helpful contribution that was.
© 2021 mIRC Discussion Forums