mIRC Home    About    Download    Register    News    Help

Print Thread
need help with script options #116262 03/04/05 06:09 PM
Joined: Aug 2004
Posts: 423
C
clutz1572 Offline OP
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Aug 2004
Posts: 423
hello again,

i'm kinda in need of some additional help with this.. i figured out my problem in my last post but, i'm now working on options for this script of mine. what i'm trying to add the abilities of bold,underlining and italics into the script. in otherwards i don't have a clue.. i could probaly use aliases to do this, but i don't know how i could incorparate that and make it work correctly..
if someone could help me out with an example so i can see how it could be done that would be great!
here's the code being used here:
Code:
on *:INPUT:*:{ if ( $left($1,1) != / ) { acro $1- } }
alias -l acro { var %i = $getacro($1-) | if (%i) { echo %i | halt } }
alias -l getacro { 
  if !$hget(amacros) { return $1- }
  var %i = 1, %r
  while $gettok($1-,%i,32) {
    var %j = $v1
    if ($hget(amacros,%j)) {
      %j = $v1 
      if ($hget(amacroset, am_Acrocaps)) { %j = $acaps(%j) }
      if ($hget(amacroset, am_Acroccaps)) { %j = $ccap(%j) }
      if ($hget(amacroset, am_Acrorcaps)) { %j = $rccap(%j) }
      else {
        if ($hget(amacroset, am_acro)) return $1-
      }
    } 
    %r = %r %j
    inc %i
  }
  return %r
}
alias -l acaps {
  var %i = 1, %r 
  while $gettok($1,%i,32) != $null { 
    %r = %r $upper($left($v1,1)) $+ $mid($v1,2) 
    inc %i 
  } 
  return %r 
} 
alias -l ccap { 
  var %i = 1, %r 
  while $gettok($1,%i,32) != $null { 
    %r = %r %am_ac1 $+ $upper($left($v1,1)) $+ %am_ac2 $+ $mid($v1,2) $+ 
    inc %i 
  } 
  return %r 
} 
alias -l rccap { 
  var %i = 1, %r 
  while $gettok($1,%i,32) != $null { 
    %r = %r  $+ $rand(3,14) $+ $upper($left($v1,1)) $+  $+ $rand(3,14) $+ $mid($v1,2) $+ 
    inc %i 
  } 
  return %r 
}

dialog options {
  title (A)(M) OPTIONS
  size -1 -1 97 119
  option dbu
  check "Make Acros Bold", 5, 11 60 54 10
  check "Underline Acros", 6, 11 72 50 10
  check "Italisize Acros", 7, 11 85 50 10
  button "Finished", 8, 28 103 37 12, ok
  radio "Disable Acros", 1, 10 8 43 9
  radio "Activate Sel colors", 2, 10 31 53 9
  radio "Activate Rand Colors", 3, 10 42 61 9
  radio "Activate caps", 4, 10 20 43 9
}
on *:dialog:options:*:*: {
  if ($devent == init) {
    if ($hget(amacroset, am_Acroccaps)) { did -c $dname 2 } | if ($hget(amacroset, am_Acrorcaps)) { did -c $dname 3 } 
    if ($hget(amacroset, am_Acrocaps)) { did -c $dname 4 } | if ($hget(amacroset, am_Acro)) { did -c $dname 1 }
    if ($hget(amacroset, ama_bold)) { did -c $dname 5 } | if ($hget(amacroset, ama_underline)) { did -c $dname 6 }
    if ($hget(amacroset, ama_italic)) { did -c $dname 7 } 
  } 
  if ($devent == sclick) {
    if ($did isnum 1-4) { 
      if $did == 1 && $did(1).state { did -u $dname 2,3,4 } 
      elseif $did == 2 && $did(2).state { did -u $dname 1,3,4 } 
      elseif $did == 3 && $did(3).state { did -u $dname 1,2,4 }
      elseif $did == 4 && $did(4).state { did -u $dname 1,2,3 }
    } 
    if $did == 5 && $did(5).state { did -c $dname 5 }
    if $did == 6 && $did(6).state { did -c $dname 6 }
    if $did == 7 && $did(7).state { did -c $dname 7 }
    .hadd amacroset am_Acro $did(1).state | .hadd amacroset am_Acrocaps $did(4).state 
   . hadd amacroset am_acroccaps $did(2).state | .hadd amacroset am_Acrorcaps $did(3).state
   . hadd  amacroset ama_bold $did(5).state | .hadd amacroset ama_underline $did(6).state
    .hadd amacroset ama_italic $did(7).state   
  }
}


if anyone would be willing to lend a hand with this, that would be so kind..(i've searched the database and turn up nothing i though usefull on this)..

thanks in advance!

Re: need help with script options #116263 04/04/05 04:04 AM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
One point there isnt any italic, but there is reverse so i replaced italic with reverse.

I couldnt even get your code to go with out problems without alot of changes. heres the highlights of what i felt needed fixing.


on *:INPUT:*:{ if ( $left($1,1) != / ) { acro $1- } }
^ could do with a !$ctrlenter added (not a must)

alias -l acro { var %i = $getacro($1-) | if (%i) { echo %i | halt } }
^ $getacro($1-) aways returns a value so "if (%i)" is always true (excepting values of "$false" "0" "$null") so all you do is echo the text locally ?!?!?!?!

while $gettok($1-,%i,32) {
^ if the $gettok($1-,%i,32) value happend to be "$false" "0" or "$null" then the while loop ends by mistake
* using the following moves from the last word to the first
... tokenize 32 $1- used inside $identifiers as $1 maybe more than one word
... var %i = $0 , %r $0 is the number of $x identifiers
... while (%i) { loop down tell %i is zero
... ... var -s %w = $($+($,%i),2) $+($,%i) if %i was 4 makes $4 so $($4,2) evaluates it to its contents other methods may look like [ [ $+($,%i) ] ]
... ... dec %i } dec the loop counter at the end instead of increase
^ reverseing the order is as simple as var %i = 1 | while (%i <= $0) { inc %i }

if ($hget(amacroset, am_acro)) return $1-
^ this should be moved to the begining of the code as it shuts down everything

dialog options {
^ reorganize this its hard to follow and debug with numbers all over the place (not a must)

if ($hget(amacroset, am_Acroccaps)) { did -c $dname 2 } | if ($hget(amacroset, am_Acrorcaps)) { did -c $dname 3 }
^ nothing wrong with these | but it doesnt make code easy to debug (i must admit i do it myself sometimes)

if $did == 1 && $did(1).state { did -u $dname 2,3,4 }
^ unneeded state of radio buttons is changed automaticly

if $did == 5 && $did(5).state { did -c $dname 5 }
^ unneeded state of check boxes is changed automaticly


** Heres the code i ended up with, I dont promise its perfect, but it seemed to hold up to test data.

Code:
on *:INPUT:*:{ if (($left($1,1) != /) &amp;&amp; (!$ctrlenter)) { acro $1- } }
;
alias -l acro { if ($getacro($1-)) { say $v1 | halt } }
;
alias -l getacro {
  if (!$hget(amacros) || $hget(amacroset, am_acro)) { return }
  tokenize 32 $1-
  var %i = $0 , %r
  while (%i) {
    var %w = $($+($,%i),2)
    if ($hget(amacros,%w)) {
      var %w = $v1
      if     ($hget(amacroset, am_Acrocaps))  { %w = $acaps(%w) }
      elseif ($hget(amacroset, am_Acroccaps)) { %w = $ccap(%w)  }
      elseif ($hget(amacroset, am_Acrorcaps)) { %w = $rccap(%w) }
      if ($hget(amacroset, ama_Bold))      { %w = $+(,%w,) }
      if ($hget(amacroset, ama_Underline)) { %w = $+(,%w,) }
      if ($hget(amacroset, ama_Reverse))   { %w = $+(,%w,) }
    } 
    var %r = %w %r
    dec %i
  }
  return %r
}
alias -l acaps {
  tokenize 32 $1- | var %i = $0 , %r , %w
  while (%i) { %w = $($+($,%i),2) | %r = $+($upper($left(%w,1)),$mid(%w,2)) %r | dec %i } 
  return %r 
} 
alias -l ccap { 
  tokenize 32 $1- | var %i = $0 , %r , %w
  while (%i) { %w = $($+($,%i),2) | %r = $+(%am_ac1,$upper($left(%w,1)),%am_ac2,$mid(%w,2),) %r | dec %i } 
  return %r 
} 
alias -l rccap { 
  tokenize 32 $1- | var %i = $0 , %r , %w
  while (%i) { %w = $($+($,%i),2) | %r = $+(,$rand(3,14),$upper($left(%w,1)),,$rand(3,14),$mid(%w,2),) %r | dec %i } 
  return %r 
}
dialog options {
  title (A)(M) OPTIONS
  size -1 -1 97 119
  option dbu
  radio "Disable Acros",        1, 10 8 43 9
  radio "Activate caps",        2, 10 20 43 9
  radio "Activate Sel colors",  3, 10 31 53 9
  radio "Activate Rand Colors", 4, 10 42 61 9
  check "Make Acros Bold",      5, 11 60 54 10
  check "Underline Acros",      6, 11 72 50 10
  check "Reverse Acros",        7, 11 85 50 10
  button "Save",                8, 28 103 37 12, ok
}
on *:dialog:options:*:*: {
  if ($devent == init) {
    if ($hget(amacroset, am_Acro))       { did -c $dname 1 }
    if ($hget(amacroset, am_Acrocaps))   { did -c $dname 2 }
    if ($hget(amacroset, am_Acroccaps))  { did -c $dname 3 }
    if ($hget(amacroset, am_Acrorcaps))  { did -c $dname 4 } 
    if ($hget(amacroset, ama_Bold))      { did -c $dname 5 }
    if ($hget(amacroset, ama_Underline)) { did -c $dname 6 }
    if ($hget(amacroset, ama_Reverse))   { did -c $dname 7 } 
  } 
  if (($devent == sclick) &amp;&amp; ($did == 8)) {
    .hadd -m amacroset am_Acro       $did(1).state      
    .hadd    amacroset am_Acrocaps   $did(2).state 
    .hadd    amacroset am_Acroccaps  $did(3).state 
    .hadd    amacroset am_Acrorcaps  $did(4).state
    .hadd    amacroset ama_Bold      $did(5).state     
    .hadd    amacroset ama_Underline $did(6).state
    .hadd    amacroset ama_Reverse   $did(7).state   
  }
}

Re: need help with script options #116264 04/04/05 03:54 PM
Joined: Aug 2004
Posts: 423
C
clutz1572 Offline OP
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Aug 2004
Posts: 423
dave, this works well! thanks

in response to :
Quote:
alias -l acro { var %i = $getacro($1-) | if (%i) { echo %i | halt } }
^ $getacro($1-) aways returns a value so "if (%i)" is always true (excepting values of "$false" "0" "$null") so all you do is echo the text locally ?!?!?!?!

this was intentional for local testing..(i probly should've mentioned that, sorry)

and :
Quote:
I couldnt even get your code to go with out problems without alot of changes.


it did "SEEM" to work ok as it was lol, but i guess not...
(again i appreciate your help)

i appreciate your effort to help, it's pretty darn good! grin

i do have another question that has come up though, on a slightly diff subject .. it's about colors. well adding back ground colors to be exact. i have all my colors set as variables.. and i want to add a background color as a option.. but it seams that you can't use variables for such things. i've tried to do somthing like this:

.set %c1 4
.set %bg 8

then locally type this:
//echo %c1,%bgtest

but it doesn't come out.. i've tried it a few diff ways but no joy.. it either results blank or results default color.. but when i use the color codes straight like so..4,8test it works.. i know this is like mirc 101 here but what would be the way to do somthing like this??

Re: need help with script options #116265 04/04/05 04:02 PM
Joined: Dec 2002
Posts: 3,547
S
SladeKraven Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Code:
alias sk
  .set %c1 $+($chr(3),9)
  .set %bg 1
  echo -a $+(%c1,$chr(44),%bg,SladeKraven,$chr(3))
}

Re: need help with script options #116266 04/04/05 04:48 PM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Quote:

.set %c1 4
.set %bg 8

then locally type this:
//echo %c1,%bgtest


hehehe
Indulge me and type this line in
/set %c1,%bgtest whopwhop!

then try
//echo %c1,%bgtest
result "whopwhop!"

Mirc is seeing that as one big variable name (i thought it would see it as %c1<comma>%bgtest and i was going to say theres no variable called %bgtest, but its just one big variable)

try this
//echo $+(%c1,$chr(44),%bg,test)

or

//echo %c1 $+ , $+ %bg $+ test

One thing here you should ALWAYS use 2 digit color codes 00-09,10-15, if you dont know what text well be following, assume my text was "1st place wins!" and it was ment to be in color 1 you end up with "11st place wins!" and you get "st place wins!" in color 11, took me ages to track that down in a script i wrote once frown

Re: need help with script options #116267 04/04/05 04:52 PM
Joined: Dec 2002
Posts: 3,547
S
SladeKraven Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Quote:

try this
//echo $+(%c1,$chr(44),%bg,test)


Hehe, almost the same as the SK alias bove your post hehehe.

But I'd add a closing $chr(3) in the $+() because you could get the whole sentence coloured in. grin

Re: need help with script options #116268 04/04/05 05:12 PM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
I wasnt even gonna mention anything as u had answered it, untell i was how it was one big var name, i thought wow, thats one way of making your code hard to read! lol

Re: need help with script options #116269 04/04/05 05:17 PM
Joined: Dec 2002
Posts: 3,547
S
SladeKraven Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Old habbits die hard, but in my case not at all but there ya go.. wink

Re: need help with script options #116270 04/04/05 06:04 PM
Joined: Aug 2004
Posts: 423
C
clutz1572 Offline OP
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Aug 2004
Posts: 423
DOH! it didn't occured to me to use the $chr command .... i was so busy looking at everything else i kinda ignored what should have been obvious....
and yeah, your right i should be using double digits for the color codes... some how i never do though..(*SHRUGS)

thanks very much guys......

Re: need help with script options #116271 04/04/05 06:07 PM
Joined: Dec 2002
Posts: 3,547
S
SladeKraven Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
You're welcome mate. smile