mIRC Home    About    Download    Register    News    Help

Print Thread
About the new file handling #61558 23/11/03 12:51 PM
Joined: Dec 2002
Posts: 44
G
GodGell Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Dec 2002
Posts: 44
hey again smile
the new file handling is supercool. smile but it is a new feature, i'm sure that's why it still has a few bugs. smile first, that i've mentioned in another forum, that as i see /fopen tryes to open the file for reading and writing both, and that causes failure when trying to open a read-only file. i'd suggest to add a -rw switch. my idea: if no -rw is specified, then use read & write opening smile if -r is specified, then open for reading, if -w, then for writing, so if -rw, then for read & write smile
the another thing:
sometimes $eof and $fopen().eof returns $false and waits until the position reaches the file's size + 1 byte. that caused much problem with my mirc webserver, i had to set a variable that checks file size, and if $eof == $false, but $fopen().pos >= $file().size, then it forces to act like if $eof == $true smile i hope i was understandable laugh
another thing, that it is great that now $file can return file attributes either, but it'd be good to write down what letters mean what attributes, for example, if it returns "a", i can only hardly think it means archiveable or what smile and a file attributes _changing_ command, for example /attr file attribs would be good either smile

AND:
$read has great searching functions, but it opens and closes the file in every call, is slow, and fails if it cant open the file, but sometimes i sill have to use it because if i'd go through a file with a while cicle, it would add a lot of errors and should be much more slower.. but $read is dangerous laugh so i suggest, that with the new filehandling, $read would have an option to make us capable of using $read's search-toys on already opened files, without the danger of our script halts smile

and if you have wrote a brand new, and much better filehandling, you should do the same with directory handling. i dont know much about how does Window§ handle this, but i think u have to open directories aswell to get a filelist or something. like $read crawls through the file, fopen speeds over it smile $findfile and $finddir are slow either, i'm sure because the $read, it opens & close directories in every call, well i dont know, u know the answer, khaled smile so i'd love /dopen /dclose /dseek... commands, just like the new filehandling, but for directory listing.

and $ferr and $fopen().ferr should return an error message if possible, n ot only true/false smile or to let the already wrote for truefalse scripts work, you should add a .emsg or somethinglikethat property to $fopen, that'd give an error message if any. smile


sorry for my bad english
watch out when you're in front of my scalar howitzer smile

Punks not dead!
Re: About the new file handling #61559 24/11/03 06:25 PM
Joined: Jul 2003
Posts: 33
B
Bilge Offline
Ameglian cow
Offline
Ameglian cow
B
Joined: Jul 2003
Posts: 33
Can you please use more smileys when you post. I need to have a snapshot of what your face looked like at least 3 times per sentece, even if it still looks the same, otherwise it becomes impossible to guage what kind of a response to give.

Re: About the new file handling #61560 24/11/03 08:06 PM
Joined: Jul 2003
Posts: 742
MTec89 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jul 2003
Posts: 742
ill help you with that:

mad mad mad mad mad mad mad mad mad mad
mad mad mad mad mad mad mad mad mad mad
mad mad mad mad mad mad mad mad mad mad
mad mad mad mad mad mad mad mad mad mad
mad mad mad mad mad mad mad mad mad mad


http://MTec89Net.com
irc.freenode.net #MTec89Net
Re: About the new file handling #61561 25/11/03 01:09 PM
Joined: Jul 2003
Posts: 33
B
Bilge Offline
Ameglian cow
Offline
Ameglian cow
B
Joined: Jul 2003
Posts: 33
Thank you kindly. However, I failed to state one other piece of criteria. It is not acceptible to do a smily summary at the end of your passage, you must intersperse the faces amongst your text. It is only in doing so that what you are typing becomes legible. It is commonly accepted that replacing punctuation with faces helps as well.

Re: About the new file handling #61562 28/11/03 04:42 AM
Joined: Oct 2003
Posts: 10
T
topscriptz Offline
Pikka bird
Offline
Pikka bird
T
Joined: Oct 2003
Posts: 10
Anyone with programming experience will already understand how these commands work. Because tbey'd have read about it in their programming books.

When you /fopen a file for writing, the contents of the file SHOULD be erased or "unlinked" to prevent corruption and /fopen to a certain position in a file could cause a lot buggy scripts. And /write with regular expressions would still be the fastest way to write to the file reliably.
Also, /fopen puts a "lock" on a file to prevent any other programs from writing to it. You cannot use a /write while the file is /fopen.

And try using $feof instead of $eof and see if it fixes that +1 thing.

You are wrong about $read being slow or dangerous. Within $read() you can specify the line number to start at, so you wont have to $read from the beginning of the file twice in a row. Similar to /fseek function, but better.

Now, for the file attribute letters. Those are retrieved from the operating system mirc is running on. You need to consult your operating systems documentation (google.com) to see which letters mean what and what letters are available to your files.

If you want to see if you've reached the end of a file you MUST check the $feof identifier right away because /fwrite commands wont halt a script when failing.

I recommened reading some documents on Fwrite and fseek command sets.

Re: About the new file handling #61563 28/11/03 06:18 PM
Joined: Dec 2002
Posts: 44
G
GodGell Offline OP
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Dec 2002
Posts: 44
Light!


Quote:
You are wrong about $read being slow or dangerous. Within $read() you can specify the line number to start at, so you wont have to $read from the beginning of the file twice in a row. Similar to /fseek function, but better.[


Hey, i think you're missing my point smile
$read and /write are slow, because in every call they open then read then close the file. they are dangerous, because if they fail to open the file, they halt the entire script without warning. but $read & /write's features are cool, so i think it shouldn't be so hard to write them a switch to work on an already opened file. in mirc script (just for everyone to understand), it'd be something like that:

var %filehandle = openfile_temp-blaah
if (-*o* iswm %switches) %filehandle = %o
else fopen %filehandle %file

...

if (-*o* iswm %switches) return
else fclose %filehandle


i hope everyone understands what i mean smile the code could remain the same, just cutting off the file closes and opens if that switch and opened file handle is given. BAH! a long post again! laugh


sorry for my bad english
watch out when you're in front of my scalar howitzer smile

Punks not dead!