mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Oct 2003
Posts: 64
E
Exlax Offline OP
Babel fish
OP Offline
Babel fish
E
Joined: Oct 2003
Posts: 64
BOLD, UNDERLINE, REVERSE, COLOR, etc... they aren't appearing in the ini file when I use this...

Code:
/writeini -n test.ini settings bold 

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
You can't save a control code in an ini file. You'll need to either replace them with something else and then replace them with control codes when you read them back into your script, or you can use a text file, a variable, or some other method.

Here's an example of how to replace them:

//writeini test.ini Test Data $replace(This is bold and this isn't.,,$chr(131))

//echo -a $replace($readini(test.ini,Test,Data),$chr(131),)

Just use something that you won't normally have in your text, but which is a character than an INI will accept. For example, $chr(131) isn't likely to be used in your text. Use a different character for Bold and Underline and Color.

Last edited by Riamus2; 16/09/05 07:05 PM.

Invision Support
#Invision on irc.irchighway.net
Joined: Aug 2005
Posts: 128
S
Vogon poet
Offline
Vogon poet
S
Joined: Aug 2005
Posts: 128
This is not a good ideea, what if he wants to use chr 131 too?
alias wr writeini -n $1 $encode($2,m) $encode($3,m) $encode($4-,m)
alias rr return $decode($readini($readini($1,n,$decode($2,m),$decode($3,m))),m)

/wr test.ini settings bold 
$rr(test.ini,settings,bold) returns bold.
You store the data encoded in ini, then when you read, you decode it.

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
While i find nothing at all wrong with using that, i think alot of people balk on the idea of $encode and $decode becuase of its missuse in other places.
Also I felt half the idea of an INI file is easy textual reading of it, whcih isnt so easy with encoded text.

So on that I submit these, they appear huge but its simplier than creating a loop.

either he could use...
Code:
alias wr { writeini -n $1 $2 $3 $replacex($4-,&,&38,$chr(1),&01,$chr(2),&02,$chr(3),&03,$chr(4),&04,$chr(5),&05,$chr(6),&06,$chr(7),&07,$chr(8),&08,$chr(9),&09,$chr(10),&10,$chr(11),&11,$chr(12),&12,$chr(13),&13,$chr(14),&14,$chr(15),&15,$chr(16),&16,$chr(17),&17,$chr(18),&18,$chr(19),&19,$chr(20),&20,$chr(21),&21,$chr(22),&22,$chr(23),&23,$chr(24),&24,$chr(25),&25,$chr(26),&26,$chr(27),&27,$chr(28),&28,$chr(29),&29,$chr(30),&30,$chr(31),&31) }
alias rr { return $replacex($readini($1,n,$2,$3),&01,$chr(1),&02,$chr(2),&03,$chr(3),&04,$chr(4),&05,$chr(5),&06,$chr(6),&07,$chr(7),&08,$chr(8),&09,$chr(9),&10,$chr(10),&11,$chr(11),&12,$chr(12),&13,$chr(13),&14,$chr(14),&15,$chr(15),&16,$chr(16),&17,$chr(17),&18,$chr(18),&19,$chr(19),&20,$chr(20),&21,$chr(21),&22,$chr(22),&23,$chr(23),&24,$chr(24),&25,$chr(25),&26,$chr(26),&27,$chr(27),&28,$chr(28),&29,$chr(29),&30,$chr(30),&31,$chr(31),&38,&) }



or simply en/decapsulate his stringsare write/read using
Code:
alias txt2ini { return $replacex($1,&,&38,$chr(1),&01,$chr(2),&02,$chr(3),&03,$chr(4),&04,$chr(5),&05,$chr(6),&06,$chr(7),&07,$chr(8),&08,$chr(9),&09,$chr(10),&10,$chr(11),&11,$chr(12),&12,$chr(13),&13,$chr(14),&14,$chr(15),&15,$chr(16),&16,$chr(17),&17,$chr(18),&18,$chr(19),&19,$chr(20),&20,$chr(21),&21,$chr(22),&22,$chr(23),&23,$chr(24),&24,$chr(25),&25,$chr(26),&26,$chr(27),&27,$chr(28),&28,$chr(29),&29,$chr(30),&30,$chr(31),&31) }
alias ini2txt { return $replacex($1,&01,$chr(1),&02,$chr(2),&03,$chr(3),&04,$chr(4),&05,$chr(5),&06,$chr(6),&07,$chr(7),&08,$chr(8),&09,$chr(9),&10,$chr(10),&11,$chr(11),&12,$chr(12),&13,$chr(13),&14,$chr(14),&15,$chr(15),&16,$chr(16),&17,$chr(17),&18,$chr(18),&19,$chr(19),&20,$chr(20),&21,$chr(21),&22,$chr(22),&23,$chr(23),&24,$chr(24),&25,$chr(25),&26,$chr(26),&27,$chr(27),&28,$chr(28),&29,$chr(29),&30,$chr(30),&31,$chr(31),&38,&) }


ie: /writeini file section item $txt2ini(text)
& $ini2txt($read(file,section,item)

* for anyone who wonders what all that rubbish above is, im simply locating any asc values from 01 to 31 and replacing them with &01 to &31, and viseversa. also replace & with &38 and back again, this prevents a litteral text of "&20" from being converrted by mistake as it becomes "&3820"

* This method of course leaves all other text in the line in its original form so is still well readable, even editable with a small amount of care
ex:
this is normal text this is bold text & now underline as well
this is normal text &02this is bold text &38 now &31underline as well

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Quote:
This is not a good ideea, what if he wants to use chr 131 too?


"Just use something that you won't normally have in your text, but which is a character than an INI will accept."

It is a perfectly legitimate way of doing it. You usually know what characters would be used in a script you write, so you can pick something that isn't going to ever be used in your script. $chr(131) was an example that would work for most scripts. There are many other $chr's that can be used if that one isn't good for the particular script.


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard