|
Joined: Sep 2003
Posts: 3
Self-satisified door
|
OP
Self-satisified door
Joined: Sep 2003
Posts: 3 |
Hi, I am beginning to learn the techniques of mIRC scripting, but yet at the same time I consider myself a veteran of the C programming language. As I was browsing through the mIRC help file, reading about variables, I found something that could be considered a very good suggestion, and let me tell you In C, you can modify the alignment of variables within a string by using numbers before the statement, such as:
strlen (buf, "Hello %-14s!");
I think it would be really cool to see alignment variables such as so in mIRC, such as when you do something like this:
alias hello_world {
var %i = world
echo -a Hello %-14i !
}
I understand it would probably be hard to do something like this, but I think it would be a very cool feature, especially with those MTS theme things and custom layouts and so forth. Any opinions?
Last edited by Mavric; 20/02/04 07:52 PM.
|
|
|
|
Joined: Mar 2003
Posts: 1,271
Hoopy frood
|
Hoopy frood
Joined: Mar 2003
Posts: 1,271 |
You means: you set a variable to a certain value, and then use that variable in another sentence? At least as I understand it, your scriptlet is suppoed to echo Hello world !
This already works in mIRC, in the exact way you pasted it. If you put that code in your remotes and type /hello_world it will echo exactly that....
DALnet #Helpdesk I hear and I forget. I see and I remember. I do and I understand. -Confucius
|
|
|
|
Joined: Sep 2003
Posts: 3
Self-satisified door
|
OP
Self-satisified door
Joined: Sep 2003
Posts: 3 |
No, What I meant is not implemented in mIRC in any way right now. In C, you have string descriptors, which are %s (for strings), %d (for integers), %ld (for long integers), %c (for characters), and %f (for floats). All of these can be used inside of a string such as so:
char $world[30];
$world = "World!"
sprintf(buf, "Hello %s!", $world);
You can add numbers to these formatting codes to introduce alignment. So therefor if you did this:
sprintf(buf, "Hello %-15s!", $world);
It would turn out like this: This is used to align fixed-length fonts so you can make pretty boxes and stuff. I think this would be cool to see in mIRC one day. Only a programmer in C would probably know what I am talking about. But anyways, good day!
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
you could never implement it like this
echo -a Hello %-14i !
as %-14i is a valid variable name.
create this alias for what you want
alias padder { return $2- $+ $str($chr(32) $+ ,$calc($1 - $len($2-))) $+ }
echo -a Hello $padder(14,%i) !
|
|
|
|
Joined: Jan 2003
Posts: 3,012
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 3,012 |
As dave said, it's not very likely to have such a thing in the mirc language, but you can use such a snipplet to space out values by padding it with other characters. I wrote this snipplet a while go for making columns and tables and such, but can be used for your implimentation. (To keep the formatting, copy to wordpad first (start>>Run>>"wordpad") then copy from wordpad to mirc)
; -------------------------------------------------------------------------------------------------
; $pad(string, width, align, [pad_chr])
; align is assumed left if unspecified, otherwise use left,right,center
;
; exaple:
; /echo -a $pad(Name, 16, center) $pad(Mail, 32, center) $pad(url, 50, center)
; /echo -a $pad(KingTomato, 16) $pad(kingtomato@kingtomato.com, 32) $pad(www.kingtomato.com, 50)
;
; you can also use another pad character, other than character 160 (default) by specifying
; it after the alignment. This char can be either the numerical value for the character,
; the character itself, or a string of characters (such as doing [bold][space][bold])
;
; example:
; /echo -a $pad(Table Of Contents, 25) Page
; /echo -a $pad(Introduction, 25, left, .) 1
; /echo -a $pad(Chapter 1, 25, left, .) 4
; /echo -a $pad(Chapter 2, 25, left, .) 15
; -------------------------------------------------------------------------------------------------
/pad {
var %padChr = $iif($4, $iif($4 isnum, $chr($4), $4), $chr(160))
if ($2 <= $len($1)) return $1
if ($3 == right) return $+($str(%padChr,$calc($2 - $len($1))), $1)
else if ($3 == center) {
var %left = $int($calc(($2 - $len($1)) / 2))
return $+($str(%padChr,%left), $1, $str(%padChr,$calc(($2 - $len($1)) - %left)))
}
return $+($1, $str(%padChr,$calc($2 - $len($1))))
}
; eof - KingTomato
; -------------------------------------------------------------------------------------------------
-KingTomato
|
|
|
|
Joined: Jan 2004
Posts: 24
Ameglian cow
|
Ameglian cow
Joined: Jan 2004
Posts: 24 |
I also have a code which is very similar to this if you'd like to use a 30 line alias Table Format
<]dD[Makaveli> where can i get a clanboy (08:57 pm) <]dD[Makaveli> clanbot
|
|
|
|
|