$getformat()

By Nerd on Feb 28, 2006

well... yea... my first snippet i post here :)
Usage: $getformat(TEXT)
$getformat will return the last active codes in TEXT if u want to keep the format codes of a text even if you have to wrap the code to fit into a window with $wrap for example
hard to explain, so here's an example:
Text: 3,4this is a colored text with bold underline and reverse codes in it
now you have to split the text after "reverse" and add it to a window or whatever with two /aline commands
you would get
Line1: ,4this is a colored text with bold underline and reverse
Line2: codes in it
with the 2nd line standart colors without the bold etc
so now you can use
Line2: $getformat(Line1) $+ reverse codes
what leads to
Line2: 3,4 reverse codes
this works for color, bold, underline, reverse and $chr(15)
ok i can't explain it so just go and try :)
i coded this for a bigger script and i put a lot of work into it so feel free to use it in private scripts and/or edit it how you like but if u want to use it in "public" scripts please keep the credits
enough typing now, time for copy & paste ;)

; $getformat Snippet by Nerd on #geeks.chat @ Quakenet, 2006
alias getformat {
  var %t 2, %tmax $0, %tokens $1
  while (%t <= %tmax) {
    var %tokens %tokens $+ , $+ [ [ $ $+ [ [ %t ] ] ] ]
    inc %t
  }
  tokenize 32 %tokens
  var %i 1, %bolds 0, %unders 0, %res 0, %colors 0, %color $null, %color2 $null
  while (%i <= $len($1-)) {
    if ($mid($1-,%i,1) == ) { inc %bolds | if (%bolds == 2) { var %bolds 0 } }
    if ($mid($1-,%i,1) == ) { inc %unders | if (%unders == 2) { var %unders 0 } }
    if ($mid($1-,%i,1) == ) { inc %res | if (%res == 2) { var %res 0 } }
    if ($mid($1-,%i,1) == $chr(15)) { var %bolds 0 | var %unders 0 | var %res 0 | var %color1 $null | var %color2 $null | var %color $null } 
    if ($mid($1-,%i,1) == ) {
      inc %colors
      var %color1 $null, %color $null, %x 0
      while (%x <= 15) {
        if ($mid($1-,$calc( %i +1),$len( %x )) == %x) { var %color1 %x }
        inc %x
      }
      if ($mid($1-,$calc( %i +1 + $len( %color1 )),1) == $chr(44)) { 
        var %z 0
        while (%z <= 15) {
          if ($mid($1-,$calc( %i +2 + $len( %color1 )),$len( %z )) == %z) { var %color2 %z }
          inc %z
        }
      }
    }
    if (%color1 == $null) { var %color2 $null }
    if (%color2) { var %color %color1 $+ , $+ %color2 }
    else { var %color %color1 }
    inc %i
  }
  return $iif(%colors > 0, $+ %color) $+ $iif(%bolds > 0,) $+ $iif(%unders > 0,) $+ $iif(%res > 0,)
}
; End Of Snippet

Comments

Sign in to comment.
Nerd   -  Mar 01, 2006

good to know ;)

 Respond  
QuickStep   -  Mar 01, 2006

Yes, as in a [dot] whenever the sentence ends. You can also use some html code tags to format your text (
,,,)

 Respond  
Nerd   -  Feb 28, 2006

punctuation?
i tried wraps but they got deleted :X

 Respond  
QuickStep   -  Feb 28, 2006

Ah right I figured it out...

 Respond  
QuickStep   -  Feb 28, 2006

After reading your comment twice, and trying the code, I don\'t have the slightest clue what this is supposed to do. A small hint: use punctuation marks in your description, it helps.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.