mIRC Home    About    Download    Register    News    Help

Print Thread
#103441 21/11/04 03:50 AM
Joined: Sep 2004
Posts: 129
W
Wragg Offline OP
Vogon poet
OP Offline
Vogon poet
W
Joined: Sep 2004
Posts: 129
in help file says:

The -l# switch specifies the line number where the text is to be written.

/write -l5 c:\info.txt This line will overwrite the 5th line in the file


i done this:

//write -l10 test.txt line ten

and mirc wrote this text to line 1
then i used -il10 switch that INSERTS instead overwrite and it does same thing...

why ?

i tried on mirc 6.03 and 6.16 and same bs happens....
is this bug ?

#103442 21/11/04 10:25 AM
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
For /write -ln to work correctly there must be at least n lines in the file already, otherwise it'll write to the end of the file.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
#103443 21/11/04 10:34 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
I suppose mIRC can't write to a number that is higher than the current amount of lines + 1. So in an empty file, it would be impossible to specify a line number.

Usage: /writeline <file> <line nr.> <data>

Code:
alias writeline {
  if $2 &lt;= $lines($1) { write -l $+ $2 $1 $$3- }
  else { write $1 $str($lf,$calc($2 - $v2 - 1)) $+ $$3- }
}

I was able to write to line 922 in an empty file. More than that isn't possible in the current way, due to the string too long issue. If you want to write even past 922 lines without anything preceeding it, let me know. Btw, the alias will act like the regular /write -l, if you specify a line number equal to or smaller than the current number of lines.

Enjoy.


Gone.
#103444 21/11/04 10:47 AM
Joined: Sep 2004
Posts: 129
W
Wragg Offline OP
Vogon poet
OP Offline
Vogon poet
W
Joined: Sep 2004
Posts: 129
this is excelent code !

but it has some bug (imo)
i specified that "line 20" is written on line 20 :P

and i get this in .txt file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

line 20


(numbers from 1-20 i wrote myself AFTER)
so as you can see there are some skiiped lines...
and even if it starts with line 0-xx again there is 1 line skipped...

and i made test:

/writeline test.txt 5 line 5
/writeline test.txt 6 line 6
/writeline test.txt 7 line 7

result is:

only "line 6" and "line 7" were written...

any way to fix all this ?
btw i love this code; coz mirc's handeling with /write sux :P
and IMO it should be working as you programmed this code...

should this be in feature suggestions maybe ?

Last edited by Wragg; 21/11/04 10:51 AM.
#103445 21/11/04 11:05 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Odd.

I tested it prior to posting.

Test 1 on an empty file:

/writeline test.txt 20 line 20
--> wrote line 20 on line number 20, no skipped lines

Test 2: put numbers 1-20 in the file then:

/writeline test.txt 20 line 20
/writeline test.txt 5 line 5
/writeline test.txt 6 line 6
/writeline test.txt 7 line 7

Result:

1
2
3
4
line 5
line 6
line 7
8
9
10
11
12
13
14
15
16
17
18
19
line 20

Test 3 : empty file

/writeline test.txt 10 line 10
/writeline test.txt 5 line 5
/writeline test.txt 15 line 15

All were written on the appropriate lines.

By any chance, was the first line in your test.txt a space? Like perhaps there was a space as first line that you didn't notice? Because if i put a space as the first line, then indeed I get what you are getting. Delete test.txt and try again.

If that isn't the issue, I'll look into it, or someone else who feels like it.

Greets

EDIT: Remember, if you specify a line number lower or equal to the current number of lines, my code uses the built in /write -l command. Btw this code is meant for mIRC 6.16, because of the $v2 identifier.

Last edited by FiberOPtics; 21/11/04 11:18 AM.

Gone.
#103446 21/11/04 01:45 PM
Joined: Sep 2004
Posts: 129
W
Wragg Offline OP
Vogon poet
OP Offline
Vogon poet
W
Joined: Sep 2004
Posts: 129
hmm, maybe it sux at me coz i use 6.03 frown


coz on all your test it failed, especially on last one where
line 10 is written on line 12 and line 15 on line 29 (weird)

any hance it can be "modified" for 6.03 that does not support this $v2 thing ?


Last edited by Wragg; 21/11/04 01:50 PM.
#103447 21/11/04 01:47 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Code:
alias writeline {
  var %a = $lines($1)
  if $2 &lt;= %a { write -l $+ $2 $1 $$3- }
  else { write $1 $str($lf,$calc($2 - %a - 1)) $+ $$3- }
}


Gone.
#103448 21/11/04 01:53 PM
Joined: Sep 2004
Posts: 129
W
Wragg Offline OP
Vogon poet
OP Offline
Vogon poet
W
Joined: Sep 2004
Posts: 129
hehe, now on test 3 (empty file)

it write line 5 and 15 correct but 10 is again on line 12.

and on test 1 aslo everything is good exept line 20 is on line 22

like it always skips 2 lines shocked
and it seems this happens only to 1x10 numbers (20 30 40)

edit: and this happens only on empty file... when i wrote numbers 1-23 and tested, it made coorect lines, but on empty file it didnt...

Last edited by Wragg; 21/11/04 01:58 PM.
#103449 21/11/04 02:01 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hehe,

sorry I can't help you, all works well over here.


Gone.
#103450 21/11/04 02:06 PM
Joined: Sep 2004
Posts: 129
W
Wragg Offline OP
Vogon poet
OP Offline
Vogon poet
W
Joined: Sep 2004
Posts: 129
it is okay, i am very gratefull on your help, this is only minor "bug" but far more better functionality than mirc's own code.

so i thank you and i will give this to features forum.

#103451 21/11/04 02:09 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Try using it with mIRC 6.16, although I don't see why it would be any different, since the code isn't using any non 6.03 commands/identifiers.

Just try it, even if you don't like 6.16.

Also, you're not using any custom /write alias, right? Type //echo -a $isalias(write)

I have not yet run into any bug, and I've done all the same things you have. This is a fresh copy of mIRC 6.16, no scripts installed.

Greets


Gone.
#103452 21/11/04 02:16 PM
Joined: Sep 2004
Posts: 129
W
Wragg Offline OP
Vogon poet
OP Offline
Vogon poet
W
Joined: Sep 2004
Posts: 129
i get "$false" as answer

and i tested too on fresh copy of 6.16 (downloaded it last night)

but i cant use 6.16 coz my script is 6.03 compatible smile

#103453 21/11/04 03:06 PM
Joined: Aug 2004
Posts: 237
L
Fjord artisan
Offline
Fjord artisan
L
Joined: Aug 2004
Posts: 237
Scripts for 6.03 will work on a 6.16 too I think, I suppose there is backward compatibility.
(Tell me if I'm wrong!)

#103454 21/11/04 07:20 PM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
I have found out what is causing the unrequired output: mIRC 6.03

I'm at my own place now, tried the snippet with 6.16, and still worked perfectly.

Downloaded 6.03 from mIRC Scripts dot com, tried the snippet, and I got the exact results as you.

When I left $v2 (unsupported in 6.03) in the code, I got the results you got:

Line 5 was on line 5.
Line 10 was on line 12.
Line 15 was on line 29.

When I changed the snippet to work with 6.03, so using %a, I also got what you got:

Line 5 was on line 5.
Line 10 was on line 12.
Line 15 was on line 15.

I can conclude, that for the first results, it was because of $v2 not being supported in 6.03, and for the second results, the snippet also not working because of 6.03.

However, in 6.16 it works exactly as it should.

Even if Khaled would add this feature, it would still mean you have to update to a higher version than 6.03 though.

Greets


Gone.

Link Copied to Clipboard