mIRC Home    About    Download    Register    News    Help

Topic Options
#241252 - 31/03/13 06:15 PM $read and $reade suggestion
westor Offline
Hoopy frood

Registered: 27/12/08
Posts: 1511
Loc: Greece
Hello,

I wanna suggest something very usefull, as the $read has abillity to start reading from the BEGIN to END of the file, if there is anyway to add an $reade to start reading the file from the END to BEGIN.

- Thanks!
_________________________
Need Online mIRC help or an mIRC Scripting Freelancer? -> http://westor.ucoz.com/contact <-

Top
#241258 - 31/03/13 07:55 PM Re: $read and $reade suggestion [Re: westor]
hixxy Offline
Hoopy frood

Registered: 06/09/05
Posts: 2876
How would this work? $read(xyz,1) reads the first line. Are you saying $reade(xyz,1) should read the last line? $reade(xyz,2) should read the 2nd to last line.

Etc?

Top
#241259 - 31/03/13 08:00 PM Re: $read and $reade suggestion [Re: hixxy]
westor Offline
Hoopy frood

Registered: 27/12/08
Posts: 1511
Loc: Greece
I am trying to say that for example using $read(text.txt) it starts from the BEGGGING and get random item, i suggest something to start reading from the BOTTOM to the START of the file, eg: $reade(text.txt)
_________________________
Need Online mIRC help or an mIRC Scripting Freelancer? -> http://westor.ucoz.com/contact <-

Top
#241262 - 01/04/13 01:00 AM Re: $read and $reade suggestion [Re: westor]
hixxy Offline
Hoopy frood

Registered: 06/09/05
Posts: 2876
$read(text.txt) reads a random line, it doesn't start from the beginning or end.

I don't understand what you're asking for.

Top
#241263 - 01/04/13 02:12 AM Re: $read and $reade suggestion [Re: westor]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
Random is random. It will be just as random regardless which way the file is read. About the only thing starting at the end might accomplish is if you want to search for text from the end instead of from the beginning. An example might be if you wanted to search a log file for the most recent time someone said something. I don't know how often someone would actually have need of that, though. And if we wanted to support something like that, a parameter would probably be far better than a new identifier.

Another improvement to $read that could go along with this is the ability to search from a given line in either direction. So if I want to find the first line up or down from line 50 that has "word" in it, you could use some parameter or something that will start the search at line 50 and search up or down based on your parameter for the word you're looking for. This can be useful in certain cases and would work well in combination with the ability to do a reverse search of a file.

I really don't see much need for either option, but I still see some value.
_________________________
Invision Support
#Invision on irc.irchighway.net

Top
#241266 - 01/04/13 01:50 PM Re: $read and $reade suggestion [Re: Riamus2]
westor Offline
Hoopy frood

Registered: 27/12/08
Posts: 1511
Loc: Greece
I know the wildcards for $read, forget the random was my silly example, take my post to make an option in $read identifier to start reading the file from END to START , i post this because exists users that using this option and since now the only way is loop so why not an identifier with a simple option like (e) do this?

- Thanks!
_________________________
Need Online mIRC help or an mIRC Scripting Freelancer? -> http://westor.ucoz.com/contact <-

Top
#241268 - 01/04/13 02:54 PM Re: $read and $reade suggestion [Re: westor]
hixxy Offline
Hoopy frood

Registered: 06/09/05
Posts: 2876
Right but how should it work; do you want it to work as I suggested in post #2?

Do you know you can just do this to read a file backwards:

Code:
var %i = $lines(file.txt)
while (%i) {
  ; do something with $read(file.txt,n,%i)
  dec %i
}

Top
#241269 - 01/04/13 03:54 PM Re: $read and $reade suggestion [Re: hixxy]
westor Offline
Hoopy frood

Registered: 27/12/08
Posts: 1511
Loc: Greece
Originally Posted By: hixxy

Code:
var %i = $lines(file.txt)
while (%i) {
  ; do something with $read(file.txt,n,%i)
  dec %i
}


Like this exactly !
_________________________
Need Online mIRC help or an mIRC Scripting Freelancer? -> http://westor.ucoz.com/contact <-

Top
#241270 - 01/04/13 03:56 PM Re: $read and $reade suggestion [Re: westor]
hixxy Offline
Hoopy frood

Registered: 06/09/05
Posts: 2876
This already works! Try it smile

Top
#241271 - 01/04/13 04:01 PM Re: $read and $reade suggestion [Re: hixxy]
westor Offline
Hoopy frood

Registered: 27/12/08
Posts: 1511
Loc: Greece
I know, i've already talk about loops..
_________________________
Need Online mIRC help or an mIRC Scripting Freelancer? -> http://westor.ucoz.com/contact <-

Top
#241272 - 01/04/13 04:19 PM Re: $read and $reade suggestion [Re: westor]
hixxy Offline
Hoopy frood

Registered: 06/09/05
Posts: 2876
So how do you think $reade should work? I don't understand...

Top
#241273 - 01/04/13 07:33 PM Re: $read and $reade suggestion [Re: hixxy]
TRT Offline
Babel fish

Registered: 22/06/03
Posts: 81
He just wants to save a few bytes of code. laugh
_________________________
My full script pieces: (COM addons)

Top
#241274 - 01/04/13 08:49 PM Re: $read and $reade suggestion [Re: TRT]
hixxy Offline
Hoopy frood

Registered: 06/09/05
Posts: 2876
What I'm trying to say is that he hasn't said what it should actually DO.

"read a file backwards" doesn't make a lot of sense because you can already do that with $read.

What would the format of the identifier actually be?

Does he mean it should iterate through a file and pass each line to a /command like $hfind(), $findfile() etc?

For example:

Code:
noop $reade(file.txt,n,echo -a $1-)


I think more details are needed!

Top
#241276 - 02/04/13 02:24 AM Re: $read and $reade suggestion [Re: hixxy]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3496
Loc: France
As far as I understand him, he wants to be able to gives another switch to $read to change the way it reads: by reading from the end of the file (mirc currently reads from the beginning).
A very nice suggestion, but what about the N parameter? Assuming the switch is 'e' and the content of a file is:
Code:
a
mirc
b
c
e
f
mirc
g
h


would $read(file,e,2) look for the second line from the end? ("g" here)

$read(file,we,*mirc*,1) and then $readn, would $readn return 7 or 2?
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#241277 - 02/04/13 03:08 PM Re: $read and $reade suggestion [Re: Wims]
westor Offline
Hoopy frood

Registered: 27/12/08
Posts: 1511
Loc: Greece
Yes, Wims that's one i mean.

in that : $read(file,we,*mirc*,1) and then $readn, would $readn return 7 or 2?

will return 7 because it starts reading for wildcard from the end of the file to start so if the wildcard of $read is in the text that starting reading with the 'e' parameter so will return in $readn the 7 line.
_________________________
Need Online mIRC help or an mIRC Scripting Freelancer? -> http://westor.ucoz.com/contact <-

Top
#241280 - 02/04/13 04:25 PM Re: $read and $reade suggestion [Re: westor]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3496
Loc: France
Yeah, that looks like the ideal behavior for me too.

So the suggestion is about adding a new behavior to $read:
whenever $read starts looking for something from the beginning of the file (using the r/s/w switches with or without a line number N, or just the line number N), $read will now doing the search 'backward', starting from the end of the file.
The N parameter is also affected by the behavior, the line number N is relative from the end of the file.
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#241281 - 02/04/13 09:29 PM Re: $read and $reade suggestion [Re: westor]
hixxy Offline
Hoopy frood

Registered: 06/09/05
Posts: 2876
Now that we've established the suggested implementation it sounds good to me!

Top