|
Joined: Feb 2003
Posts: 282
Fjord artisan
|
OP
Fjord artisan
Joined: Feb 2003
Posts: 282 |
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?
|
|
|
|
Joined: Jan 2003
Posts: 96
Babel fish
|
Babel fish
Joined: Jan 2003
Posts: 96 |
use /write -n /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.
|
|
|
|
Joined: Dec 2002
Posts: 127
Vogon poet
|
Vogon poet
Joined: Dec 2002
Posts: 127 |
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.
------ deep down, i'm really superficial.
|
|
|
|
Joined: Jan 2003
Posts: 3,012
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 3,012 |
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
-KingTomato
|
|
|
|
Joined: Dec 2002
Posts: 2,809
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 2,809 |
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...
|
|
|
|
Joined: Jan 2003
Posts: 3,012
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 3,012 |
Can you point me to the page? I'd like to learn about them while im at it
-KingTomato
|
|
|
|
Joined: Dec 2002
Posts: 2,809
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 2,809 |
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
|
|
|
|
Joined: Jan 2003
Posts: 3,012
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 3,012 |
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. ty
-KingTomato
|
|
|
|
Joined: Dec 2002
Posts: 2,809
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 2,809 |
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).
|
|
|
|
Joined: Jan 2003
Posts: 3,012
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 3,012 |
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
-KingTomato
|
|
|
|
Joined: Dec 2002
Posts: 2,809
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 2,809 |
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.
|
|
|
|
Joined: Jan 2003
Posts: 3,012
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 3,012 |
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
-KingTomato
|
|
|
|
Joined: Jan 2003
Posts: 96
Babel fish
|
Babel fish
Joined: Jan 2003
Posts: 96 |
Oooops, my bad, am truly sorry for that.
|
|
|
|
Joined: Dec 2002
Posts: 2,809
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 2,809 |
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
|
|
|
|
Joined: Jan 2003
Posts: 96
Babel fish
|
Babel fish
Joined: Jan 2003
Posts: 96 |
hahah that was a good one code, does it actually work ?
|
|
|
|
Joined: Dec 2002
Posts: 2,809
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 2,809 |
Well I've had a credit card since I started driving (17), so it worked for me
|
|
|
|
Joined: Feb 2003
Posts: 282
Fjord artisan
|
OP
Fjord artisan
Joined: Feb 2003
Posts: 282 |
One problem that I have is that I don't know how to use hash tables.
|
|
|
|
Joined: Jan 2003
Posts: 3,012
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 3,012 |
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 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..
/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
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.
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.
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!
-KingTomato
|
|
|
|
Joined: Feb 2003
Posts: 282
Fjord artisan
|
OP
Fjord artisan
Joined: Feb 2003
Posts: 282 |
W00t 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
|
|
|
|
Joined: Jun 2003
Posts: 68
Babel fish
|
Babel fish
Joined: Jun 2003
Posts: 68 |
|
|
|
|
|