mIRC Home    About    Download    Register    News    Help

Print Thread
#39702 04/08/03 10:48 PM
Joined: Feb 2003
Posts: 33
G
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Feb 2003
Posts: 33
Hellow I'm working on a script that translates mIRC code to VBB code
like exp:
Code:
0T7elenet-0S7tats 0U7p 0T7o 0[702/08/030]

to :
Code:
[b][/COLOR][COLOR=white]T[/b][/COLOR][COLOR=orange]elenet-[/COLOR][COLOR=white][b]S[/b][/COLOR][COLOR=orange]tats[/COLOR][COLOR=white][b]U[/b][/COLOR][COLOR=orange]p[/COLOR][COLOR=white][b]T[/b][/COLOR][COLOR=orange]o[/COLOR][COLOR=white][b][[/COLOR][COLOR=orange][/b]02/08/03[/COLOR][COLOR=white][b]][/b]


But there are some Problems With the Color Code Like u c.
In vbb when you want to use a new color tag the older color tag must be closed (ex: [color=orange]text [ /color] )
like you see in my script (the last 20 - 40 lines
u c alot of $replace's
whell now my question:

How can i do a $replace for just 1 time so not in the whole sentence but like the $reptok command,
ex: 7Hellow4whassup4How are you
$replace(7Hellow4whassup7How are you
,7,[COLOR=orange])
it would give:
Code:
 [COLOR=orange]Hellow4whassup7How are you

And Not:
Code:
 [COLOR=orange]Hellow4whassup[COLOR=orange]How are you

i need this becous with this i can know if I already used a color command so i know i need to write a [ /color] command or not ...

i hope its clear what i want ?
else reply what you don't understand and i would like to explain it wink

btw, here is my script:


Code:
dialog irctovbb {
  title "mIRC Code To VBBcode Translator"
  size -1 -1 378 255
  option dbu
  edit "", 1, 13 25 163 200, multi return autohs autovs hsbar vsbar
  edit "", 2, 195 25 163 200, read multi return autohs autovs hsbar vsbar
  button "Transform To VBBcode", 3, 15 239 71 12
  box "mIRC Code", 4, 10 14 176 215
  box "VBB code", 5, 187 14 178 215
  button "Options", 8, 89 239 37 12
  button "Close / Ok", 6, 130 239 37 12, ok
}

on *:dialog:irctovbb:sclick:*:{
  if ($did == 3) { 
    unset %vbb.lijnedited
    set %vbbc 1
    while (%vbbc <= $did(irctovbb,1).lines) {
      set %line.vbb $did(irctovbb,1, %vbbc )
      set %beginu 1
      set %underline 1
      set %bold 1 
      set %underlinec 1
      while (%underlinec <= $len(%line.vbb)) {
        if ($mid(%line.vbb , %beginu , 1) == $chr(31)) {
          if (%underline == 1) {
            set %vbb.lijnedited %vbb.lijnedited $+ [u]
            set %underline 0
          }
          elseif (%underline == 0) { 
            set %vbb.lijnedited %vbb.lijnedited $+ [/u]
            set %underline 1 
          }
        }
        if ($mid(%line.vbb , %beginu , 1) == $chr(2)) {
          if (%bold == 1 ) { 
            set %vbb.lijnedited %vbb.lijnedited $+ [b]
            set %bold 0
          }
          elseif (%bold == 0) { 
            set %vbb.lijnedited %vbb.lijnedited $+ [/b]
            set %bold 1 
          }
        }
        else {
          /set %vbb.lijnedited %vbb.lijnedited $+ $mid(%line.vbb , %beginu , 1)
        }
        inc %beginu
        inc %underlinec
      }
      set %vbb.lijnedited $replace(%vbb.lijnedited,15,[/COLOR][COLOR=#8C8C8C])
      set %vbb.lijnedited $replace(%vbb.lijnedited,14,[/COLOR][COLOR=silver])
      set %vbb.lijnedited $replace(%vbb.lijnedited,12,[/COLOR][COLOR=blue])
      set %vbb.lijnedited $replace(%vbb.lijnedited,13,[/COLOR][COLOR=deeppink])
      set %vbb.lijnedited $replace(%vbb.lijnedited,11,[/COLOR][COLOR=cyan])
      set %vbb.lijnedited $replace(%vbb.lijnedited,10,[/COLOR][COLOR=teal])
      set %vbb.lijnedited $replace(%vbb.lijnedited,00,[/COLOR][COLOR=white])
      set %vbb.lijnedited $replace(%vbb.lijnedited,01,[/COLOR][COLOR=BLACK])
      set %vbb.lijnedited $replace(%vbb.lijnedited,02,[/COLOR][COLOR=darkblue])
      set %vbb.lijnedited $replace(%vbb.lijnedited,03,[/COLOR][COLOR=green])
      set %vbb.lijnedited $replace(%vbb.lijnedited,04,[/COLOR][COLOR=red])
      set %vbb.lijnedited $replace(%vbb.lijnedited,05,[/COLOR][COLOR=darkred])
      set %vbb.lijnedited $replace(%vbb.lijnedited,06,[/COLOR][COLOR=purple])
      set %vbb.lijnedited $replace(%vbb.lijnedited,07,[/COLOR][COLOR=orange])
      set %vbb.lijnedited $replace(%vbb.lijnedited,08,[/COLOR][COLOR=sandybrown])
      set %vbb.lijnedited $replace(%vbb.lijnedited,09,[/COLOR][COLOR=limegreen])
      set %vbb.lijnedited $replace(%vbb.lijnedited,0,[/COLOR][COLOR=white])
      set %vbb.lijnedited $replace(%vbb.lijnedited,1,[/COLOR][COLOR=BLACK])
      set %vbb.lijnedited $replace(%vbb.lijnedited,2,[/COLOR][COLOR=darkblue])
      set %vbb.lijnedited $replace(%vbb.lijnedited,3,[/COLOR][COLOR=green])
      set %vbb.lijnedited $replace(%vbb.lijnedited,4,[/COLOR][COLOR=red])
      set %vbb.lijnedited $replace(%vbb.lijnedited,5,[/COLOR][COLOR=darkred])
      set %vbb.lijnedited $replace(%vbb.lijnedited,6,[/COLOR][COLOR=purple])
      set %vbb.lijnedited $replace(%vbb.lijnedited,7,[/COLOR][COLOR=orange])
      set %vbb.lijnedited $replace(%vbb.lijnedited,8,[/COLOR][COLOR=sandybrown])
      set %vbb.lijnedited $replace(%vbb.lijnedited,9,[/COLOR][COLOR=limegreen])
      set %vbb.lijnedited $replace(%vbb.lijnedited,,[/COLOR])
      did -o irctovbb 2 %vbbc %vbb.lijnedited
      unset %vbb.lijnedited
      inc %vbbc
    }
  }
  if ($did == 6) { /dialog -c irctovbb }
  if ($did == 8) { /dialog -m irctovbbopt irctovbbopt }
}


Last edited by Gods_Hell; 04/08/03 10:50 PM.

Joined: May 2003
Posts: 730
S
Hoopy frood
Offline
Hoopy frood
S
Joined: May 2003
Posts: 730
u can use $regsub
for example
var %x
.echo -q $regsub(7Hellow4whassup7How are you
,7,\[COLOR=orange\],%x)
the result will be stored in %x




Joined: Feb 2003
Posts: 33
G
Ameglian cow
OP Offline
Ameglian cow
G
Joined: Feb 2003
Posts: 33
:s
never used Regular Expressions

weird [censored] :s smile

but i have found a other methode
wich i think will work fine to

but it will make the script bigger



Link Copied to Clipboard