mIRC Home    About    Download    Register    News    Help

Print Thread
Acronym replacer (reading from file) #29190 11/06/03 06:30 PM
Joined: May 2003
Posts: 23
Q
Qwaka Offline OP
Ameglian cow
OP Offline
Ameglian cow
Q
Joined: May 2003
Posts: 23
I am completing an acronym replacer script and have all of the dialogs and front end business as I desire. However I can not seem to complete the cod that woudl read from the file, and replace the acronym with the whole word(s). (example LOL should equal Laughs Out Loud).
As I mentioned I have the creation of the file, and editable through dialog. The file looks like this:
Code:
[Inputs]
N1=stfu
N2=heh
N3=lol

[Outputs]
N1=4Shut the F*ck Up
N2=4Grins
N3=4Laughs Out Loud

So far all I can complete is the following:
Code:
on *:INPUT:?,#:{ if ($1- isin ($readini -n $mircdiracronyms\acronyms.ini Inputs)) { set %Acrotext  ($readini -n $mircdiracronyms\acronyms.ini Outputs)


but that doesnt seem right, and I'm not certian how to display it. Thanks for any help.

Re: Acronym replacer (reading from file) #29191 11/06/03 06:32 PM
Joined: Jan 2003
Posts: 3,012
KingTomato Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
Why not use
[Acronym]
lol=Laughing Out Load
rofl=Rolling On Floor Laughing

then cycle through the words in your input trigger. If the word exists in the ini file, replace it >:D


-KingTomato
Re: Acronym replacer (reading from file) #29192 11/06/03 06:38 PM
Joined: May 2003
Posts: 10
L
LeperMessiah Offline
Pikka bird
Offline
Pikka bird
L
Joined: May 2003
Posts: 10
Why not just use $replace($1-,lol,Laugh Out Loud)? :|

Re: Acronym replacer (reading from file) #29193 11/06/03 06:42 PM
Joined: Jan 2003
Posts: 3,012
KingTomato Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
because then your stuck with just the list in remotes. With an ini, you can make a dialog and the user can add and remove them easily, without having to touch a single line of code >:D


-KingTomato
Re: Acronym replacer (reading from file) #29194 11/06/03 06:45 PM
Joined: May 2003
Posts: 10
L
LeperMessiah Offline
Pikka bird
Offline
Pikka bird
L
Joined: May 2003
Posts: 10
Ah, I see now. Sorry for me butting in. blush

Re: Acronym replacer (reading from file) #29195 11/06/03 06:54 PM
Joined: May 2003
Posts: 23
Q
Qwaka Offline OP
Ameglian cow
OP Offline
Ameglian cow
Q
Joined: May 2003
Posts: 23
Thanks for replies. King Tomato - I can certianly format the .ini file that way (I prefer the current format but whatver works is acceptable). but, I stil am not certain how I would script this to work.
Code:
on *:INPUT:?,#:{ if ($1- isin ($readini -n $mircdiracronyms\acronyms.ini Acronyms)) 

I cant think of where to go from there. sorry for my lack of scripting ability.

Re: Acronym replacer (reading from file) #29196 11/06/03 06:54 PM
Joined: Jan 2003
Posts: 3,012
KingTomato Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
np, your entitile to questioning something thats how ya learn >:D


-KingTomato
Re: Acronym replacer (reading from file) #29197 11/06/03 07:30 PM
Joined: May 2003
Posts: 23
Q
Qwaka Offline OP
Ameglian cow
OP Offline
Ameglian cow
Q
Joined: May 2003
Posts: 23
Why isnt this working: (Im using my exisintg ini file format, I have not udpated to the way you suggested KT as I dont know how to implement that either)

Code:
alias Acronyms.read { return $readini -n " $+ acro.ini $+ " $1 $2 } 

on *:input:*: {
  if ($left($1,1) == /) || ($left($1,1) == :) { return }
  else {
      var %Acronyms.temp = 0
      :Acrocheck
      inc %Acronyms.temp 1
      if ($1- isin $Acronyms.read(Inputs,%Acronyms.temp)) { set %Acrotext $Acronyms.read(Outputs,%Acronyms.temp) | goto Acrotalk }
      if ($Acronyms.read(Inputs,%Acronyms.temp) != $null) { goto Acrocheck }
      :Acrotalk
        set %acrotmp $Acronyms.read(Inputs,%Acronyms.temp)
        say $replace($1-,%Acrotmp,%tmp) | halt
        }
}

Re: Acronym replacer (reading from file) #29198 11/06/03 07:45 PM
Joined: Dec 2002
Posts: 2,809
C
codemastr Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
Try changing:
alias Acronyms.read { return $readini -n " $+ acro.ini $+ " $1 $2 }
to:

alias Acronyms.read { return $readini(acro.ini,n,$1,N $+ $2) }

Re: Acronym replacer (reading from file) #29199 11/06/03 08:02 PM
Joined: May 2003
Posts: 23
Q
Qwaka Offline OP
Ameglian cow
OP Offline
Ameglian cow
Q
Joined: May 2003
Posts: 23
No it didnt seem to make a difference. my problem is pry in my output: say $replace($1-,%Acrotmp,%tmp)

I dont know, im a little frustrated wiht it now, I'm going to take a break and work on it later.

Re: Acronym replacer (reading from file) #29200 11/06/03 08:40 PM
Joined: Dec 2002
Posts: 1,922
O
Online Offline
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
acro.ini
Code:
[acro]
lol=laughing out loud
brb=be right back
afk=away from keyboard

Remote,
Code:
On *:input:#:{
  if /* iswm $1 || $ctrlenter { return }
  var %i = 1, %total = $0, %word, %string
  while %i <= %total {
    %word = $ [ $+ [ %i ] ]
    if $readini(acro.ini,acro,%word) {
      %string = %string $ifmatch
    }
    else %string = %string %word
    %i = %i + 1
  }
  say %string
  halt
}


Doing a several $readini for every input slows down.
I would store my acronyms in a hash table (faster)
and use $hget(table,%word) instead of $readini().

Re: Acronym replacer (reading from file) #29201 12/06/03 02:04 PM
Joined: May 2003
Posts: 23
Q
Qwaka Offline OP
Ameglian cow
OP Offline
Ameglian cow
Q
Joined: May 2003
Posts: 23
Thank You, that small bit of script worked. (you should have seen the spaghetti I was turning it into). The only other hurdle I need to try to get over is that it doesn display formatting and colors, for example
Code:
[Acro]
lol=4laughs

rather than displaying as laughs
It shows as 4laughs. Can I get around this somehow ?

Re: Acronym replacer (reading from file) #29202 12/06/03 04:07 PM
Joined: Jan 2003
Posts: 3,012
KingTomato Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
INI's don't save color codes. If u used /writeini to write a color to the ini, it was stripped. You need to use comething like replace to change ^c into something like <c>, ^b = <b>, etc. Then when you read it, replace <c> -> ^cm <b> --> ^b, etc.


-KingTomato
Re: Acronym replacer (reading from file) #29203 12/06/03 06:07 PM
Joined: Dec 2002
Posts: 1,527
_
_D3m0n_ Offline
Hoopy frood
Offline
Hoopy frood
_
Joined: Dec 2002
Posts: 1,527
very good point ..... your better off the just saving it to a .mrc and reading it from that ..... saving your color codes


D3m0nnet.com
Re: Acronym replacer (reading from file) #29204 12/06/03 09:52 PM
Joined: Dec 2002
Posts: 1,922
O
Online Offline
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
As Tomato suggested, here's color replacement aliases,

alias rini { echo return $replacecs($$readini($1,$2,$3),^B,$chr(2),^K,$chr(3),^O,$chr(15),^R,$chr(22),^U,$chr(31)) }
alias wini { !writeini $1-3 $replacecs($4-,$chr(2),^B,$chr(3),^K,$chr(15),^O,$chr(22),^R,$chr(31),^U) }

//wini test.ini a b 10colorboldunderlinereverse
//echo -a $rini(test.ini,a,b)

In our example it would become: $rini(acro.ini,acro,%word)

The inability of storing colors in ini files is one of the reasons why I prefer hash tables.