Hotstring

Platform:  mIRC
Published  Feb 06, 2009
Updated  Feb 22, 2009
HotString v0.1

Type /hotstring to start it.

This script basically acts, well like the title says, a hotstring.

I'll show a screenie so you can see it better:



On the bottom-left you can add a hotstring (No Spaces!). Click add to add it, and you should see it come up in the list on the left side.

The edit box on the right lets you change the text you want to replace. To do so, first click a hotstring and then type the text to replace.

;Hotstring v0.2
;Made by Firstmate

on 1:INPUT:#:{
if ($left($1,1) !== / && !$ctrlenter) {
if (%hs == 1) { msg $active $hs.replace($1-) | halt }
}
}
alias hotstring { dialog $iif($dialog(hs),-v,-dom) hs hs hs | if (!%hs) { set %hs 0 } }
dialog hs {
title "Hotstring v0.1"
size -1 -1 350 170
text "Hotstrings",1,5 5 50 20
list 2, 5 25 100 140
text "Text",3, 120 5 50 20
edit "",4, 120 25 200 20, authos
button "Add",5, 120 60 50 20
button "Remove",6,120 80 50 20
text "",8,180 60 150 200
text "",9, 200 150 200 20
radio "On",7,120 100 50 20, group
radio "Off",10,120 120 50 20
edit "",11,5 145 100 20
}
on *:dialog:hs:init:0: {
if ($lines($hs.txt) > 0) { hs.load 2 }
did -a hs 8 Hi, this script will automatically replace your text. To start using it, add a hotstring (editbox at bottom-left), turn it on, and then the text it will replace.
did -c hs $iif(%hs == 1,7,10)
}
on *:dialog:hs:sclick:*: {
if ($did == 2) {
did -r hs 4
var %a = $did(hs,2,$did(hs,2).sel).text
if ($read($hs.txt,s,%a)) { did -a hs 4 $read($hs.txt,s,%a) }
}
if ($did == 5) {
var %a = $did(hs,11)
if (!%a) { did -a hs 9 Please enter a hotstring }
elseif ($numtok(%a,32) !== 1) { did -a hs 9 Script doesn't support spaces }
elseif ($read($hs.txt,s,%a)) { did -a hs 9 Hotstring already exists }
else { write $hs.txt %a | hs.load 2 }
}
if ($did == 6) {
var %a = $did(hs,2,$did(hs,2).sel).text
if (!%a) { did -a hs 9 Please select a hotstring }
else { write -ds %a $qt($hs.txt) | did -a hs 9 Deleted! | hs.load 2 }
}
if ($did == 7) { set %hs 1 }
if ($did == 10) { set %hs 0 }
}
on *:dialog:hs:edit:4: {
var %a = $did(hs,2,$did(hs,2).sel).text
if (%a) {
write -ds %a $hs.txt
write $hs.txt %a $did(hs,4).text
}
}
alias hs.load {
var %i = 1, %x = $calc($lines($hs.txt) + 1)
if (%x == 1) { did -r hs $1 | halt }
else {
did -r hs $1
while (%i < %x) {
did -a hs $1 $gettok($read($hs.txt,%i),1,32)
inc %i
}
}
}
alias hs.replace {
var %a $1-
var %i = 1, %x = $calc($lines($hs.txt) + 1)
if (%x == 1) { halt }
else {
while (%i < %x) {
var %search = $+(/\b,$gettok($read($hs.txt,%i),1,32),\b/g)
var %replace = $gettok($read($hs.txt,%i),2-,32)
if (%replace) { noop $regsub(%a,%search,%replace,%a) }
inc %i
}
}
return %a
}
alias hs.txt return $qt($+($scriptdir,hs.txt))


Comments

Sign in to comment.
Eugenio   -  Feb 23, 2009
smh
 Respond  
Blitzjager   -  Feb 23, 2009
Eh, usually when I'm making a dialog I can think of what it should look like and then use DStudio to actually make it. :S
 Respond  
jonesy44   -  Feb 23, 2009
Nicely said, Firstmate, agree with that entirely. "just to get a look on things, not actually making it"
 Respond  
Firstmate   -  Feb 23, 2009
I like how Jonesy put it. I like how easy it is to use DStudio, but I just don't like it.
I would use it for the huge dialogs that I might ever need (and even then, probably just to get a look on things, not actually making it).

DStudio just helps get a better visual representation of the dialog.
 Respond  
Blitzjager   -  Feb 23, 2009
Wuuut
The IDs are the only thing that sometimes bugs me about DStudio. And it's much easier to get it pixel perfect with DStudio. :P

*Will never manually make a dialog ever again*
 Respond  
Kirby   -  Feb 23, 2009
Well, what if you were to work with excessively large dialogs?
It doesn't mess with ID's unless you were to add things in a disorganized way.
 Respond  
jonesy44   -  Feb 23, 2009
Yeah. messes with ID's etc. makes it look.. "average" then it takes ages to sort it. do it the real way (:
 Respond  
Kirby   -  Feb 23, 2009
DSTUDIO cocks it up too much?
 Respond  
jonesy44   -  Feb 23, 2009
I perfer NOT using dstudio. but taking time to (maybe a bit picky) but get it pixel perfect. i find dstudio cocks it up too much
 Respond  
Firstmate   -  Feb 22, 2009
Ahh forgot about that, thanks. I was just too lazy to type /hotstring each time to test (and too stupid to make a menu at that time), so I put /hs. Forgot to change it at end.

And yeah, I usually do dialogs like without DStudio or anything so that's why it looks a little less aesthetically pleasing :)

*Updates alias
 Respond  
jonesy44   -  Feb 22, 2009
alias "/hs" is an alias for "/msg hostserv x" on some servers. i suggest you change it (:

and btw, i disagree. i quite like the dialog, from the screenshot.
If i was to be REALLY picky, move the radios down a few px. and make them a bit closer together. and make the edit box as long as the longest part of text (:
 Respond  
Firstmate   -  Feb 07, 2009
Updated. Should fix the problem of not properly adding hotstrings.
I'll make the dialog look better later.
 Respond  
Kirby   -  Feb 07, 2009
 Respond  
Eugenio   -  Feb 07, 2009
rofl @ kirbeh ffs
why not just recode the whole thang, and stop doing a Napa however the dialog is abit f&(@#$ ;p
also you should make it so that we cant keep entering the same hotstring.....
anyhow I like this code
/me rates 7
 Respond  
Kirby   -  Feb 07, 2009
Some things I would like to note:

  • Radios
    Code
     

    You can use $did(id).state and some $iif's to see whether something is checked or not, and perform various actions on each check, without the use of variables. Also note that those variables can easily be unset. So normally, you wouldn't need to perform an action when you sclick on those $did's (radios, checkboxes, etc).

  • Aliases
    The first alias that I see is:
    Code
     

    As I said earlier, you wouldn't need variables for radios. Also, to open a dialog, you only need two dialog id's after the $iif. So you can basically recode this as:
    Code
     

    This might be my habit, but I find it awkward to have multiple aliases pertaining to the script that perform different functions.
    I see three different aliases:
    Code
     

    Kinda confused me, but I guess you can ignore me on this part and leave it alone.

  • Dialog
    No offense but, this dialog is f&(@#$.
    I am sorry, I apologize.

    You said earlier that you don't want to use DSTUDIO (for unknown reasons to me), but I'll say some things:

    • DSTUDIO makes dialogs look much nicer and it's easier to edit.
    • DSTUDIO saves you time.

    You may disagree with me because this is a small dialog, but if you were to code a larger dialog as I did with my Microsoft Agent dialog, DSTUDIO significantly lowers the time to create a dialog by several minutes...even hours.

    On the bright side, you can improve upon things.
    In my opinion, I didn't like the edit box directly underneath the list box.
    I also didn't like the initiation text event; I thought it was a little useless, and you can cut that large space out.
    This is only one opinion, and you can reject this idea if you wish.

    Below I've recoded the dialog to what fits me the best, but again, you can ignore me if you want.
    Code
     


    I just thought this made it look a little "cleaner".


That's really all I have to say.
Keep on going; I like the idea of this script.
 Respond  
Kirbeh_Pr0nz   -  Feb 07, 2009
It didnt work for me, i would type in the hotstring,
and click 'Add'
but it wouldnt add it.
plz help if you can
 Respond  
Aucun50   -  Feb 06, 2009
Looks neat and good coding
 Respond  
PuNkTuReD   -  Feb 06, 2009
lol jamiie
the sort of judgemental comments i get when i do, the comments i got when i uploaded it were quite amusing.

yea ive unloaded it now cos none of my messages are going through.
 Respond  
Firstmate   -  Feb 06, 2009
Still weird that it's having that glitch, I thought I fixed it by making it save to a .txt where the script is stored. I have the alias hs.txt for that.
 Respond  
Jamiie   -  Feb 06, 2009
Punktured, what persuaded you into getting that image? Just out of curiosity.
 Respond  
PuNkTuReD   -  Feb 06, 2009
yea i figured out how to open it by looking at the code, but some people wont be able to do so.

very neat dialog btw
 Respond  
Firstmate   -  Feb 06, 2009
lol, My bad I guess.

I fixed the glitch where the script and text are stored elsewhere...
 Respond  
Jamiie   -  Feb 06, 2009
Punktured, use /hs
 Respond  
PuNkTuReD   -  Feb 06, 2009
you should add to your description, how to open the dialog.

i cant get it to add.
no errors show
 Respond  
Jamiie   -  Feb 06, 2009
Neatly done, works great for me.


6/10+like
 Respond  
ProIcons   -  Feb 06, 2009
7/10 :D Now Answer to mine:D http://www.hawkee.com/snippet/5725/ :D lol
 Respond  
Firstmate   -  Feb 06, 2009
Dam, it submitted it twice. Please delete one of them :x
 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.