Скрипт для сравнения 2 частей кода
Страница 1 из 1
Скрипт для сравнения 2 частей кода
Скопируйте код в Alt+R
- Код:
;begin Typos Code Comparison
menu * {
-
<[Typos Code Comparison]>:compare
-
}
alias compare dialog $iif($dialog(compare),-ev,-md) Compare Compare
dialog Compare {
title "Typos Code Comparison"
size -1 -1 191 256
option dbu
button "Paste Code 2", 3, 77 112 40 12
button "Done", 4, 78 239 37 12, default ok cancel
button "Paste Code 1", 5, 76 26 40 12
button "Compare Codes", 6, 75 198 42 12
edit "", 1, 4 40 183 64, multi return autohs autovs hsbar vsbar
edit "", 2, 4 126 183 64, multi return autohs autovs hsbar vsbar
box "", 9, 2 20 187 87
box "", 10, 2 106 187 87
box "", 11, 2 192 187 41
text "Enter the codes to be compared into each box and then press the compare button. Using the paste button will not erase the text first.", 12, 12 5 166 13, center
text "Pressing Compare Codes will replace this text with information about the differences in the codes.", 7, 15 214 161 13, center
box "", 16, 14 209 164 20
button "{ }", 17, 176 26 10 12
button "{ }", 18, 176 112 10 12
button "Stay On Top", 19, 5 243 39 8
edit "", 39, 4 25 183 154, hide disable read
text "", 40, 6 66 179 74, hide disable center
box "", 41, 2 20 187 173, hide disable
button "OK", 42, 77 179 37 12, hide disable
box "", 43, 9 0 172 21
box "", 44, 2 237 46 17
box "", 45, 75 233 43 21
box "", 46, 143 237 46 17
button "Erase all fields.", 47, 146 243 39 8
}
on *:dialog:compare:sclick:3:{
var %tmpcbnum $cb(0), %tmpnum = 1
while (%tmpnum <= %tmpcbnum) {
did -az compare 2 $iif(%tmpnum > 1,$crlf) $+ $cb(%tmpnum)
inc %tmpnum
}
}
on *:dialog:compare:sclick:5:{
var %tmpcbnum $cb(0), %tmpnum = 1
while (%tmpnum <= %tmpcbnum) {
did -az compare 1 $iif(%tmpnum > 1,$crlf) $+ $cb(%tmpnum)
inc %tmpnum
}
}
on *:dialog:compare:sclick:6:{
if ($did(compare,1).lines == 1) && (!$did(compare,1,1).text) || ($did(compare,2).lines == 1) && (!$did(compare,2,1).text) {
noop $input(You must enter a code in both code entry boxes before trying to compare them.,ouwd,Error! Nothing to compare!)
return
}
filter -gifc compare 1 tempcompare.tmp /[^(?:^$)]/
var %tmplines1 $lines(tempcompare.tmp), %tmpsize1 $calc($file(tempcompare.tmp).size - 2)
filter -gifc compare 2 tempcompare.tmp /[^(?:^$)]/
var %tmplines2 $lines(tempcompare.tmp), %tmpsize2 $calc($file(tempcompare.tmp).size - 2)
var %tmpcompmsg1 $remove($calc(%tmpsize1 - %tmpsize2),-), %tmpcompmsg2 $remove($calc(%tmplines1 - %tmplines2),-)
did -raz compare 7 Thats %tmpsize1 byte $+ $iif(%tmpsize1 > 1,s) in %tmplines1 line $+ $iif(%tmplines1 > 1,s) versus %tmpsize2 bytes in %tmplines2 lines for a difference of %tmpcompmsg1 byte $+ $iif(%tmpcompmsg1 > 1,s) and %tmpcompmsg2 line $+ $iif(%tmpcompmsg2 > 1,s) $+ .
.remove tempcompare.tmp
}
on *:dialog:compare:sclick:17:{ $checkbrackets(1) }
on *:dialog:compare:sclick:18:{ $checkbrackets(2) }
on *:dialog:compare:sclick:19:{
dialog - $+ $iif($did(compare,19) == Stay On Top,o,n) compare
did -a compare 19 $iif($did(compare,19) == Stay On Top,Undo On Top,Stay On Top)
}
on *:dialog:compare:sclick:42:{
did -hb compare 39-42
did -ve compare 1-3,5,9-10,17-18
}
on *:dialog:compare:sclick:47:{
did -r compare 1-2,7
did -a compare 7 Pressing Compare Codes will replace this text with information about the differences in the codes.
}
alias checkbrackets {
var %tmpdola1 = $1, %leftbracketcntfull = 0, %leftbracketcnt = 0, %rightbracketcntfull = 0, %rightbracketcnt = 0
if ($did(compare,%tmpdola1).lines == 1) && (!$did(compare,%tmpdola1,1).text) {
noop $input(You must enter a code before trying a bracket check.,ouwd,Error! Nothing to check!)
return
}
var %dlines $did(compare,%tmpdola1).lines
while (%dlines ) {
if ($regex($did(compare,%tmpdola1,%dlines).text,/((?::|\s|^){(?:\s|$))/g)) { inc -u2 %leftbracketcnt $regml(0) }
if ($chr(123) isin $did(compare,%tmpdola1,%dlines).text) { inc -u2 %leftbracketcntfull $count($v2,$chr(123)) }
dec %dlines
}
var %dlines $did(compare,%tmpdola1).lines
while (%dlines) {
if ($chr(125) isin $did(compare,%tmpdola1,%dlines).text) { inc -u2 %rightbracketcntfull $count($v2,$chr(125)) }
dec %dlines
}
var %tmpcnt $did(compare,%tmpdola1).lines, %rightbracketcnt = 0
while (%tmpcnt) {
tokenize 32 $did(compare,%tmpdola1,%tmpcnt)
if ($1-) { var %tmpnumba $iif($2- != $null,$numtok($1-,32),1) }
while (%tmpnumba) {
if ($ [ $+ [ %tmpnumba ] ] == $chr(125)) { inc %rightbracketcnt }
dec %tmpnumba
}
dec %tmpcnt
}
if (%leftbracketcnt == %rightbracketcnt) { var %tmpmsg = Your brackets appear to be all matching up. $crlf, %tmpnotright = yes }
else { var %tmpmsg = %tmpmsg You have a bracket mismatch. $crlf }
if (%rightbracketcnt != %rightbracketcntfull) || (%leftbracketcnt != %leftbracketcntfull) { var %tmpmsg = %tmpmsg There seems to be $calc((%leftbracketcntfull - %leftbracketcnt) + (%rightbracketcntfull - %rightbracketcnt)) brackets that mirc will not recognize as valid. This doesn't always mean there is an error as sometimes you might use $chr(125) in the code itself like the $chr(125) found in $!regex($1-,/}/). }
elseif (%tmpnotright == yes) || (%leftbracketcntfull) && (%leftbracketcnt) && (%rightbracketcntfull) && (%rightbracketcnt) { var %tmpmsg = No bracket errors detected. }
var %tmpmsg = %tmpmsg $crlf $crlf $crlf Press OK to to return to the code entry boxes.
did -hb compare 1-3,5,17-18,9-10
did -ev compare 39-42
did -b compare 39
did -a compare 40 %tmpmsg
}
;end Typos Code Comparison
Похожие темы
» RAW скрипт на русском языке.
» Скрипт антирекламы
» Скрипт "албанского" языка
» скрипт антиреклама
» Скрипт - Winamp
» Скрипт антирекламы
» Скрипт "албанского" языка
» скрипт антиреклама
» Скрипт - Winamp
Страница 1 из 1
Права доступа к этому форуму:
Вы не можете отвечать на сообщения
|
|