|
nutsnbolts |
Posted: Wed Jun 26, 2002 5:56 pm
Converting ANSI to HTML? |
|
nutsnbolts Apprentice
Joined: 01 May 2002 Posts: 188 Location: USA
|
Posted: Sat Jun 29, 2002 9:24 pm |
Yeh that's what I did. For some reason, it is probably due to my separatory character "". For instance:
If the script is this.
trig does this
trig does that
trig does this
Importing this, for the first time, would work. And when I take a look at the triggers through the Editor, it would show that. However, when I close zmud and then restart it again, when I would take a look at the script again, the editor would be
trig does thistrig does thattrig does this
Hence, when I try to run the script, it's giving me errors like can't understand trig etc..or something like that.
Thank you for everything, it's always appreciated. |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Sat Jun 29, 2002 10:15 pm |
Hmm, I don't know what to tell you. Try unchecking Convert ot one-line commands in the Options menu of the Edit Window. Maybe also checking Pretty Print in the same menu.
I have never seen this problem before.
Kjata |
|
|
|
nutsnbolts Apprentice
Joined: 01 May 2002 Posts: 188 Location: USA
|
Posted: Sun Jun 30, 2002 12:44 am |
I think that will do the trick, haven't tried it yet, will do in like 10 minutes. I'll let you know.
On the other hand, you may want to take a look at Drevarr's reply to this posting about a dos script that converts ansi to html. I tried that thing and it takes literally like 1 second...no mattter how huge the file is. You may want to take a look at it and see what kind of coding he had that may refine yours. Kinda kewl actually.
Thank you for everything, it's always appreciated. |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Sun Jun 30, 2002 2:51 pm |
Well, an interpreted script can never compare to a compiled program in terms of speed, but I'll continue looking into what other optimizations can be made to make the script faster.
Kjata |
|
|
|
wilh Wanderer
Joined: 08 Feb 2001 Posts: 89 Location: USA
|
Posted: Mon Jul 01, 2002 12:13 am |
Kjata,
Can you post your finished script to the finished scripts forum? Thanks!
Wil
Wil Hunt |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Mon Jul 01, 2002 1:03 am |
Sure can.
It's there now.
Kjata |
|
|
|
nutsnbolts Apprentice
Joined: 01 May 2002 Posts: 188 Location: USA
|
Posted: Mon Jul 01, 2002 4:17 am |
I'm glad this post went somewhere. =)
Kjata, this is just a thought and I don't know if this is feasable. Is there anyway to run an external program using zmud. What I mean is utilizing, per say, that script that Drevvar presented to us to run within zmud.
Like using aliases to control or run the script. I may not know what I'm talking about but you know like using the script as a plugin...
Take a look at the script and see how you may be able to integrate or run the program, instead of copying the file then running dos then executing the file....make it all one step?
Thank you for everything, it's always appreciated. |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Mon Jul 01, 2002 11:30 am |
Oh, that would be easy. zMUD provides the #LAUNCH command, that lets you run other programs. You could make a simple alias like:
#ALIAS convertIt {#LAUNCH {ansi2html.exe %1 %2}}
and you just need to supply this alias with the input and output filenames.
Kjata |
|
|
|
nutsnbolts Apprentice
Joined: 01 May 2002 Posts: 188 Location: USA
|
Posted: Mon Jul 01, 2002 4:30 pm |
I'm presuming then that ansi2html.exe would be placed within zmud directory, including the log file that was saved.
In addition, I don't want to make a mess of things but is there anyway to put the .exe file in a directory called c:/zmud/logs and have zmud execute this within that directory so I can just keep zmud directory clean.
Thank you for everything, it's always appreciated. |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Mon Jul 01, 2002 11:26 pm |
Well, you can try it and test it out, but I don't think there will be any problems as long as it is somewhere inside the zMUD directory.
Kjata |
|
|
|
nutsnbolts Apprentice
Joined: 01 May 2002 Posts: 188 Location: USA
|
Posted: Tue Jul 02, 2002 2:45 pm |
nope, it has to be in the zmud directory. I tried creating another directory within zmud directory and placed the .exe and .txt (log file) in there. When I ran zmud and executed the #launch command, it didn't work. It didn't do anything. I wonder if you need to specify the exact path.
Thank you for everything, it's always appreciated. |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Tue Jul 02, 2002 9:15 pm |
quote:
nope, it has to be in the zmud directory. I tried creating another directory within zmud directory and placed the .exe and .txt (log file) in there. When I ran zmud and executed the #launch command, it didn't work. It didn't do anything. I wonder if you need to specify the exact path.
Thank you for everything, it's always appreciated.
#LAUNCH filename.ext will always look ONLY in the ZMud folder, because that's where you told it to.
#LAUNCH "d:filepathfilename.ext" will look in the specified folder, but I don't recall if that will cause problems...
li'l shmoe of Dragon's Gate MUD |
|
|
|
Tarn GURU
Joined: 10 Oct 2000 Posts: 873 Location: USA
|
Posted: Fri Jul 05, 2002 7:41 am |
Apologies for a lengthy post. Note to beginners: This is NOT zScript code. I'm providing it as a tool to use WITH zMud, not a script to use IN zMud.
Well, a week and a day. I'll toss in the start of a file converter- usable in any version of VB or later versions of Excel (cut/paste into a macro). Notes: tested with some old raw Achaea logs, testing/comments appreciated. Only recognizes 'm' codes. Easy to switch what they do or add more- I don't have the ANSI spec in front of me. Uses some deprecated tags/attributes which should be supported by any current browser, but could be updated with more modern tags. Could be made lots faster by reading into a buffer, among other things. My goal was to make it easy for others to understand/extend/modify. If you try to use it in a plugin, remember that in a finished log file, we know the end of the ANSI codes have been 'received'- in a telnet link we don't.
Maybe someone can make/host an executable, a plugin, or an example spreadsheet- I'm in primitiveland right now.
Copyright note: I release this to the public domain. This means that you can do anything you want with it.
-Tarn
Example of calling the code:
ConvertAnsiFileToHTML "c:delmetst.log", "c:delmetst.htm"
Code follows:
Public Sub ConvertAnsiFileToHTML(FullPathIn As String, FullPathOut As String)
Dim iLog As Integer
Dim iHTML As Integer
Dim lPos As Long
Dim lLast As Long
Dim Char As Byte
Dim bInANSI As Boolean
Dim sANSI As String
iLog = FreeFile()
Open FullPathIn For Binary As iLog
iHTML = FreeFile()
Open FullPathOut For Binary As iHTML
Put #iHTML, , "<html><body bgcolor=black><font color=white>"
lPos = 0
lLast = LOF(iLog)
While lPos < lLast
Get #iLog, , Char
lPos = lPos + 1
Select Case Char
Case 27 'escape
sANSI = ""
CollectANSI iLog, sANSI, lPos, lLast
EmitHTML sANSI, iHTML
Case 10 'carriage return
'ignore
Case 13 'linefeed
'new line
Put #iHTML, , "<BR>"
Case 38 '&
Put #iHTML, , "&"
Case 60 '<
Put #iHTML, , "<"
Case 62 '>
Put #iHTML, , ">"
Case Else
Put #iHTML, , Char
End Select
Wend
'all the way through the file
Close iLog
Put #iHTML, , "</body></html>"
Close iHTML
Exit Sub
BadConvert:
Close iLog
Close iHTML
MsgBox "Error in Conversion:" & vbCrLf & Err.Description, vbApplicationModal
End Sub
Private Sub CollectANSI(Handle As Integer, ByRef ANSI As String, ByRef lPos As Long, lLast As Long)
Const MAX_ANSILENGTH = 20 'the largest recognized ansi collection. 'realistic' upper limit, not a spec limitation
Dim lEndSearch As Long
Dim Char As Byte
Dim i As Long
On Error GoTo BadAnsi:
Get #Handle, , Char 'the bracket
lPos = lPos + 1
lEndSearch = lPos + MAX_ANSILENGTH
If lEndSearch >= lLast Then lEndSearch = lLast
For i = lPos + 1 To lEndSearch
Get #Handle, , Char
lPos = lPos + 1
Select Case Char
Case Asc("m")
'that's the end
ANSI = ANSI & "m"
Exit For
Case Else
'not the end yet
ANSI = ANSI & Chr$(Char)
End Select
Next i
Exit Sub
BadAnsi:
ANSI = ANSI & "<p><b><font color=white>End of ANSI not found, position within file: " & lPos & "</font></b><p>"
End Sub
Private Sub EmitHTML(ANSI As String, Handle As Integer)
Dim AnsiCol As Collection
Dim sCode As String
Dim lCount As Long
Dim i As Long
Select Case Right$(ANSI, 1)
Case "m"
'know what to do
Set AnsiCol = ANSIColorCodes(ANSI)
lCount = AnsiCol.Count
For i = 1 To lCount
sCode = AnsiCol(1)
Select Case sCode
Case "0"
Put #Handle, , "</FONT><FONT BOLD=FALSE COLOR=WHITE UNDERLINE=FALSE>"
Case "1"
Put #Handle, , "</FONT><FONT BOLD=TRUE>"
Case "4"
Put #Handle, , "</FONT><FONT UNDERLINE=TRUE>"
Case "30"
Put #Handle, , "</FONT><FONT COLOR=BLACK>"
Case "31"
Put #Handle, , "</FONT><FONT COLOR=RED>"
Case "32"
Put #Handle, , "</FONT><FONT COLOR=GREEN>"
Case "33"
Put #Handle, , "</FONT><FONT COLOR=YELLOW>"
Case "34"
Put #Handle, , "</FONT><FONT COLOR=BLUE>"
Case "35"
Put #Handle, , "</FONT><FONT COLOR=MAGENTA>"
Case "36"
Put #Handle, , "</FONT><FONT COLOR=CYAN>"
Case "37"
Put #Handle, , "</FONT><FONT COLOR=WHITE>"
Case Else
'ignore
End Select
AnsiCol.Remove 1
Next i
Case Else
'don't know what to do
Put #Handle, , "<p><b><font color=white>Unknown ANSI encoding found</font></b><p>"
End Select
End Sub
Private Function ANSIColorCodes(ANSI As String) As Collection
Dim Col As Collection
Dim lPos As Long
Set Col = New Collection
lPos = InStr(ANSI, ";")
While lPos > 0
Col.Add Left$(ANSI, lPos - 1)
ANSI = Mid$(ANSI, lPos + 1)
lPos = InStr(ANSI, ";")
Wend
'have one left- plus an 'm'
Col.Add Left$(ANSI, Len(ANSI) - 1)
Set ANSIColorCodes = Col
End Function |
|
|
|
Deathlok Newbie
Joined: 03 Sep 2002 Posts: 9
|
Posted: Tue Sep 03, 2002 7:52 am |
Ugh. the board lost my first post.
let's try that again.
Oddly enough, Drevarr has version .6 of my ansi2html program on his web page and I just e-mailed him about version .9 before looking at these boards and noticing that he already knew about it. :p
At any rate,
I'm the original author of the Deathlok's Ansi2Html proggie, which I made for a mud I used to play on. I haven't updated the program in 2 years, but if there is interest I wouldn't mind making either a newer command line version or a 'standard' windows version (so you can drag and drop all those pesky log files. :D) and correcting any errors that may have resulted from newer versions of zMud, the way other muds handle ansi, or whatever might be causing problems.
Maybe I'll even release a 1.0 version, who knows...
Since I haven't been mudding in years I haven't messed with the program lately but, as I said, if there is interest I might just fire up that project again...
What do you think? :) |
|
|
|
Deathlok Newbie
Joined: 03 Sep 2002 Posts: 9
|
Posted: Tue Sep 03, 2002 12:57 pm |
Well, I will amend my previous post...
With the introduction (or popularization anyways) of CSS, making colored backgrounds and handling the other ansi fields has become a lot easier.
I updated my internal version to 0.91 which handles ansi backgrounds and then decided that if I rewrote the whole thing using a different type of parser instead of the line-by-line version I could save a lot of hassle in trying to figure out if ansi codes changed between lines, especially when using complex ansi...
So, to make a long story short, I worked up a little GUI for it (which works perfectly, by the way) and, after I get a little sleep, I will begin reworking the internal engine to better handle complex ansi sequences and run a bit faster.
Oh, yes...
I will be including an option to modify the output colors...so everyone who has their zMud set up different than how I do can modify their colors any way they please. :P |
|
|
|
nutsnbolts Apprentice
Joined: 01 May 2002 Posts: 188 Location: USA
|
Posted: Tue Sep 03, 2002 2:26 pm |
Very nice...
Where can we get this bad boy!
Thank you for everything, it's always appreciated. |
|
|
|
Deathlok Newbie
Joined: 03 Sep 2002 Posts: 9
|
Posted: Tue Sep 03, 2002 3:04 pm |
since reworking the engine to handle multiple ansi codes requires more thought-power than my sleep-deprived brain can muster at the moment (since I want to both make the engine faster and output more effecient html) and seeing as I have a 'real job' thingy that I am also expected to do...I wouldn't count on anything formal being released before this weekend.
I will post here when I have a new version publicly available. :^) |
|
|
|
nutsnbolts Apprentice
Joined: 01 May 2002 Posts: 188 Location: USA
|
Posted: Tue Sep 03, 2002 3:09 pm |
It's all good...take your time.
Right now, the ansi2html code I have is efficient enough. Although, getting the new version would be more a luxury item. Hehe...
Thank you for everything, it's always appreciated. |
|
|
|
Deathlok Newbie
Joined: 03 Sep 2002 Posts: 9
|
|
|
|
nutsnbolts Apprentice
Joined: 01 May 2002 Posts: 188 Location: USA
|
Posted: Sat Sep 28, 2002 8:42 pm |
Deathlok you are a god send.
Although beta. It was funny cuz just 2 days ago I was thinking about the ansi2html and when you were gonna release the beta. I was beginning to think that you gave up on it. I just told myself bah, let me wait to get an email regarding a reply to this post. Next thing I know forum@zuggsoft.com arrived at my mailbox! Woo hoo!
Thanks for your good work.
Keep it up!
Thank you for everything, it's always appreciated. |
|
|
|
nutsnbolts Apprentice
Joined: 01 May 2002 Posts: 188 Location: USA
|
Posted: Sat Sep 28, 2002 8:52 pm |
Ok I tested out your beta. It works great. No more typing...just click, click and a click. However, I do have a question. It creates a css style sheet. Well I was wondering. Exactly, every html file I create/convert. Does it always create a style sheet to compliment the html file? Doh, I'm sure it does but do I always have to upload the style sheet? Unless of course I change the configs?
Thank you for everything, it's always appreciated. |
|
|
|
nutsnbolts Apprentice
Joined: 01 May 2002 Posts: 188 Location: USA
|
Posted: Sat Sep 28, 2002 8:56 pm |
Ok I tested out your beta. It works great. No more typing...just click, click and a click. However, I do have a question. It creates a css style sheet. Well I was wondering. Exactly, every html file I create/convert. Does it always create a style sheet to compliment the html file? Doh, I'm sure it does but do I always have to upload the style sheet? Unless of course I change the configs?
Thank you for everything, it's always appreciated. |
|
|
|
Deathlok Newbie
Joined: 03 Sep 2002 Posts: 9
|
Posted: Sat Sep 28, 2002 9:09 pm |
It creates 1 style sheet 'ansi2html.css' that you upload along with your logs. The .css file matches your current config (so if you change your colors it will change on all your logs). You only need to upload the css file 1 time unless you change your colors.
I did this mainly because on long files the color commands in html took up a lot of space so instead of printing out the full color commands I just alias 'em with classes (BODY (aka .aa) through .qi).
Originally I was going to make a css file for each log that only contained the colors used in that log but I am hoping that using a static 'ansi2html.css' file that clients viewing logs will cache the css include and save some bandwidth when viewing multiple large logs. |
|
|
|
Deathlok Newbie
Joined: 03 Sep 2002 Posts: 9
|
Posted: Sat Sep 28, 2002 9:14 pm |
If you are getting many style sheets it is likely that you are converting logs that are in seperate directories.
If you keep all your logs in 1 place you will only get the 1 style sheet, but if the style sheet does not exist when the system creates the log it will create another style sheet. (actually it just creates one every time anyways in case you changed your colors).
This is intentional.
If you plan to upload multiple logs in seperate directories you could upload the .css file to the root directory on your server and change the include path in the files to read the main .css file instead of reading individual files from each directory.
I always kept all my logs in 1 directory so it didn't really occur to me. :) |
|
|
|
nutsnbolts Apprentice
Joined: 01 May 2002 Posts: 188 Location: USA
|
Posted: Sat Sep 28, 2002 9:48 pm |
That's what I figured you'd do. It would be the smart thing :)
I just wanted to confirm. Thanks..
As always, good job. Hope to see more kewl things from you. I'll let you know if I come across any problems.
Thank you for everything, it's always appreciated. |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|