Pablo Posted May 21, 2010 Report Share Posted May 21, 2010 I am trying to read a text file that contains font entries from the registry from mIRC. The registry entries use quotation marks which mIRC seems to ignore. Any file I attempt to read with ""s in the various lines, it seems to just ignore those lines. My font scanner uses a run command to export the current Windows installed fonts. Then I wanted to read that file to build a list. However, the read will not read much of the file, I am assuming due to the quote marks. alias testfonts { echo -at Loading Fonts from the Windows registry.. GetFonts .timer 1 2 LoadFonts } alias -l mirc.fontfile { return $shortfn($mircdir) $+ fonts.dat } alias GetFonts { run -n reg export "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" $mirc.fontfile } alias LoadFonts { var %i $lines($mirc.fontfile), %r 0 while (%r <= %i) { echo -at %r - $read($mirc.fontfile, %r) inc %r } } Using /testfonts gets me nothing but a bunch of blank lines. I have used /fopen and $fread to no avail. Is there a way to read this file without using binary? PS - I am assuming it is the quote marks because when i read mirc.ini, it skips lines with them. Link to comment Share on other sites More sharing options...
Pablo Posted May 21, 2010 Author Report Share Posted May 21, 2010 Have you used something like example: $noqt(whatever) ? I tried just now.. no bueno.. it must be a mirc file processing thing. Link to comment Share on other sites More sharing options...
err0r Posted May 21, 2010 Report Share Posted May 21, 2010 when you view the output in notepad it seems to output in a line by line way but if you use a better editor you will see it outputs the registry file in a different format. That could be why you are unable to get the fonts in a readable manner. seems most are just using HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\\Fonts to get the systems font folder path and doing a findfile on .TFF in that folder in which they save and read from. This is a very basic way to do it. Note you will need to improve it to meet your needs and this assumes your font folder is c windows font alias testfonts { write -c fonts.txt var %getfonts $file($findfile(C:\WINDOWS\Fonts,*.ttf,0,write fonts.txt $+($replace($truetype($1-).fullname,$chr(32),\<img src='http://www.tg007.net/forum/public/style_emoticons/<#EMO_DIR#>/cool.gif' class='bbc_emoticon' alt='B)' />,%getfonts))) } ; Credits to Kamek for these 2 aliases - http://www.mircscripts.org/ alias truetype { if (!$isfile($1)) { return } var %fn = $iif(("*" iswm $1), $1, $+(", $1, ")), %ntables, %i = 1, %p, %namepos, %namelen, %nid = 1 if ($findtok(copyright family subfamily id fullname version postscript trademark manufacturer designer - urlvendor urldesigner, $prop, 32)) { %nid = $calc($ifmatch - 1) } bread %fn 0 8192 &font if ($bvar(&font, 1, 4) != 0 1 0 0) { return } %ntables = $bvar(&font, 5).nword while (%i <= %ntables) { %p = $calc(13 + (%i - 1) * 16) if (%p > 8192) { return } if ($bvar(&font, %p, 4).text === name) { %namepos = $bvar(&font, $calc(%p + 8)).nlong | %namelen = $bvar(&font, $calc(%p + 12)).nlong | break } inc %i } if (!%namepos) { return } if (%namelen > 8192) { %namelen = 8192 } bread %fn %namepos %namelen &font var %nrecs = $bvar(&font, 3).nword, %storepos = $calc(%namepos + $bvar(&font, 5).nword), %i = 1 while (%i <= %nrecs) { %p = $calc(7 + (%i - 1) * 12) if ($bvar(&font, %p).nword = 3) && ($bvar(&font, $calc(%p + 6)).nword = %nid) { var %len = $bvar(&font, $calc(%p + 8)).nword, %peid = $bvar(&font, $calc(%p + 2)).nword bread %fn $calc(%storepos + $bvar(&font, $calc(%p + 10)).nword) %len &font return $uni2ansi($bvar(&font, 1, %len)) } inc %i } } alias uni2ansi { var %unicode = $1, %i = 1, %t = $numtok(%unicode, 32), %s = i, %c while (%i <= %t) { %c = $gettok(%unicode, $+(%i, -, $calc(%i + 2)), 32) if ($gettok(%c, 1, 32) = 0) { %c = $chr($gettok(%c, 2, 32)) } else { %c = ? } %s = $left(%s, -1) $+ %c $+ i inc %i 2 } return $left(%s, -1) } Link to comment Share on other sites More sharing options...
Guest Travis Posted May 21, 2010 Report Share Posted May 21, 2010 DCX has a very easy font dialog. Only take's a line of code and the dcx.dll. Link to comment Share on other sites More sharing options...
Pablo Posted May 21, 2010 Author Report Share Posted May 21, 2010 I'm stuck between a rock and a hard place; somewhere between using findfile for a slow laggy method and having a customizable dialog. My objective is to be able to find all system fonts as fast as REG EXPORT works while making a custom dialog. So are you saying that the registry output file is stored in unicode or with a binary header? I will look into that. The DCX method has some of the features I want. But if I make something, it should have what I want. Good option though. Link to comment Share on other sites More sharing options...
err0r Posted May 21, 2010 Report Share Posted May 21, 2010 i went back and included a snippet. it may not be perfect but seems to do ok. Link to comment Share on other sites More sharing options...
Guest Travis Posted May 21, 2010 Report Share Posted May 21, 2010 (edited) I'm stuck between a rock and a hard place; somewhere between using findfile for a slow laggy method and having a customizable dialog. My objective is to be able to find all system fonts as fast as REG EXPORT works while making a custom dialog. So are you saying that the registry output file is stored in unicode or with a binary header? I will look into that. The DCX method has some of the features I want. But if I make something, it should have what I want. Good option though. You should check out the /filter command then. It's amazingly fast and stable. Or write to a hidden window or hash table. Edited May 21, 2010 by Travis Link to comment Share on other sites More sharing options...
Ronan Posted May 21, 2010 Report Share Posted May 21, 2010 Fixed ini file handling bug when reading section/item/data that are enclosed in quotes. New mirc 7 , maybe that's what you're looking for . Link to comment Share on other sites More sharing options...
Pablo Posted May 24, 2010 Author Report Share Posted May 24, 2010 Well it was the header of the file and the method in which it was stored. I could not get anything to read the file as is. So since I was already running a command, I made a batch file to TYPE registry_export.file > clean.file after the registry export. Not so pretty, but it works. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now