May 02, 2024, 06:33:38 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Aurora->HTML (or SMF, phpBB) converter

Started by Parker, February 11, 2006, 06:23:37 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Parker

February 11, 2006, 06:23:37 PM Last Edit: February 12, 2006, 04:39:54 PM by Parker
I have written a PHP script to convert Aurora code to colored HTML or SMF code. A couple of features are missing, but it should be fully finished by tomorrow.

The keywords list is very incomplete. Edit - I've already got a list, I'll be including all the keywords soon.

The SMF option is broken, HTML works fine though. Sorry, it'll be fixed tomorrow.

Oops, I forgot to give a link :-[
http://virus.topspec-computers.co.uk/auroraconvert.php
Please note, "virus" is a shortened form of "VirusScanner", my forum account's real name. I have never and do not intend to write a virus.

Parker

I think everything is working now, let me know if you have any problems. Currently View Source is the only way to get the text, sorry. Soon there will be a separate display that reencodes the characters so you can just copy and paste from the page.

Here's a sample SMF output

global sub main()
{
   
dlg d1;
   
d1.Create(0,0,300,202,0x80C80080,0,"Caption",0);
   
d1.AddControl(CTLISTVIEW,"",10,9,157,181,0,0x200,LISTVIEW_1);
   
d1.AddControl(CTBUTTON,"Press this to make the listview appear",190,37,70,96,0x50002000,0x0,BUTTON_2);

   
d1.DoModal();
return 0;
}

Bruce Peaslee

Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Mike Stefanik

Mike Stefanik
www.catalyst.com
Catalyst Development Corporation

Parker

Thanks. There's a problem with strings randomly highlighting the wrong color (color of previous token). It worked in my example, but... I'll work on that tomorrow. There are a couple more minor things that need to be fixed, but for the most part it works fine.

All the keywords and preprocessor are included now, string escapes are handled correctly, I hope most characters come out okay, it's kind of a pain doing it with PHP since it changes all the strings to be escaped and have special HTML encodings.

Sometimes a group of spaces comes out with 1 less than it should, and newlines sometimes don't work correctly inside of block comments, although that's either working now or will be soon - I've figured it out.

Also, the background color doesn't get set for HTML. That will come later.

It's very late here and I'm very tired, so I'll finish this tomorrow.

Thanks for the feedback, and let me know if there any more problems that I haven't noticed.

Parker

Aha, I've found the multiline comments bug! So everything should be working fine in a couple of minutes, I've just gotta upload a new version.

The URL will change since I'm going to have a different index page for my site, but maybe this is a candidate for Aurora's welcome page (Aurora related websites... coming soon)?

Also, I can include other lists of keywords very easily, if anyone prefers types are highlighted in a different color than keywords.

Parker

February 12, 2006, 04:32:26 PM #6 Last Edit: February 12, 2006, 04:40:22 PM by Parker
All done for now! The main page will have some changes since it's not very pretty right now, but it's fully functional.

The official URL now is http://virus.topspec-computers.co.uk/auroraconvert.php

The conversion script will be included for reference if anyone wants it with future CCL source distributions.

If anyone wants to put a link on their site, feel free, it's also fine if you want to make your own interface, view the source of my page to see what form elements need specific names (maybe this PHP snippet will help) and make sure the form has the POST method with action="virus.topspec-computers.co.uk/aconv.php";.

<?php // All the colors are loaded into the $colors array from the $_POST global.
// And the source code is stored in $text.
$colors['keyword'] = $_POST['keyword'];
$colors['preproc'] = $_POST['preproc'];
$colors['comment'] = $_POST['comment'];
$colors['strings'] = $_POST['strings'];
$colors['numbers'] = $_POST['numbers'];
$colors['operator'] = $_POST['operator'];
$colors['charconst'] = $_POST['charconst'];
$colors['foreground'] = $_POST['foreground'];
$colors['background'] = $_POST['background'];
$keeptabs = ($_POST['keeptabs'] != false) ? 0;
$tab_cnt $_POST['tabwidth'];
// A little later down...
$text stripslashes($_POST['sourcetext']);
?>

John S

John Siino, Advanced Engineering Services and Software

Parker

Thanks! The last bug (I hope) was fixed this morning, it was my local PHP and the server's PHP didn't have the same "magic_quotes_gpc" value, causing the stripslashes function to remove actual code on the server. "$text = (get_magic_quotes_gpc() == 1) ? stripslashes($_POST['sourcetext']) : $_POST['sourcetext'];" fixes it.

The interface is better and there are some preset options. Hopefully we'll see some colored code posted here now ;)