29 Sep 2009

Developing Flash for Free!

Developing in Flash was something that has been bound to hit me for a few years now and I have avoided it and ignored it for a long time now. The main reason's being that I have never been able to get my head round animation and the use of a timeline and Flash, to me, is another proprietry plugin for your web browser that we could probably all do without the hassle of having to install. But I am not developing Flash apps for the web so it is ok.

Adobe's new CS3 and CS4 packages comes a big price tag and a 30-day trial is just not long enough for me to learn everything I need to learn and do everything I need to do. Investment in the latest version of the Adobe's authoring suite was always going to be out of the question as I never plan to adopt Flash as my choice for web development. So I started considering other options aside from piracy.

Eventually after reading much, I understood that Actionscript 3, the language behind Flash movies and FLA and SWF files can be compiled into SWF applications ready for release using Adobe's free, open source Flex SDK. So with that in my hands I started to 'Google' terms like 'Actionscript 3 source editor' and came upon a real gem.

FlashDevelop is a free, open source editor for Actionscript 3 amongst many other possibilities including a new language called haXe. I found FlashDevelop really easy to set up and use, it's auto-completion is BRILLIANT and indispensable for an Actionscript 3 beginner, helping me get through these beginning stages of Flash development with great ease.

All you need to get started is the Flex SDK, a stand alone Flash Player Debugger and FlashDevelop. Unlike the Adobe's Flash authoring suite you write everything in Actionscript 3, no interaction from the mouse and no timeline. I am sure this free, open source method of development has it's draw backs, the timeline and physical WYSIWYG stage are there for a reason, but for the purpose of creating simple Actionscript 3 applications quickly and on a low budget, FlashDevelop is brilliant.

7 Jun 2009

Connecting, Reading and Translating a SAGE Line 50 Database Using PHP5 / Apache2 on Windows XP/Vista

I decided to write this guide and post it here on my website as there is a severe lack in information out the on the web for the intermediate Windows user. Having very little idea about how ODBC connections work and how I would go about pulling data from a SAGE Line 50 database to my MySQL database served on a Linux platform. This guide will be based on the assumption that you are aware of simple configuration tasks in Windows XP/Vista and that you have a good understanding and control over your own server where we are moving the data to whatever platform you are running it on. In my case I was moving data from a Sage Line 50 database hosted on a Windows Vista machine to a MySQL 5 server running on Ubuntu Server Edition 9.04. I used a third machine to translate the data which was running XAMPP (Apache2 with PHP) on Windows Vista. You could use another XP/Vista machine like I did or you could use the machine that Sage Line 50 is on. I looked for a SAGE Line 50 ODBC driver for the Linux platform but did not find anything so it was nessessary for me to use a middle man machine of the Sage Machine itself. If anyone knows of a Sage Line 50 ODBC driver for Linux, please contact me as I would be very keen to hear about this. This was annoying as I had to set up another server. Even though I was only using PHP's CLI I used XAMPP for the set since there is no configuration required and it is easy to remove afterwards. Now onto the how to: The first thing that you will need to do is set up the Sage Line 50 ODBC driver on the computer that will be doing the 'translation'. You will find an install package for the Sage Line 50 ODBC driver inside the Sage Line 50 directory on the machine that Sage Line 50 is installed on. Once the install package is complete you will need to set the up the data path for the Sage Line 50 ODBC driver from the Windows Control Panel. Go to the Windows XP/Vista Control Panel (You will have to select something like 'View Classic Mode' somewhere to see all the functions in the Control Panel). Open up the ODBC configuration function. You will see in the list something like 'SageLine50v13'. Edit this entry to set the data path. You need to point to the network location where the Sage Line 50 data is stored. Usually under the Sage Line 50 installation directory in a folder called ACCDATA. To access this over the network, Windows file sharing will have to be set up (READ ONLY) on that directory. So set your data path as something like '\\192.168.1.100\SAGE\ACCDATA' . Once that has been done you can start writing your PHP script. Here's an example:
<?php
$odbc['user'] = 'username';
$odbc['dsn'] = 'SageLine50v13';
$odbc['table'] = 'SALES_LEDGER';
$fields = array();
$results = array();
$conn = odbc_connect($odbc['dsn'],$odbc['user'],$odbc['pass']);
if (!$conn) die('Error connecting to: '.$odbc['dsn']);
$sql = 'SELECT * FROM '.$odbc['table'];
$r = odbc_exec($conn,$sql);
if (!$r) die('Error executing query: '.$sql);
for ($i=1;$i<=odbc_num_fields($r),$i++)
$fields[odbc_field_name($r,$i)] = odbc_field_type($r,$i);
$x=0;
while (odbc_fetch_row($r)) {
for ($i=1;$i<=odbc_num_fields($r),$i++)
    $results[$x][odbc_field_name($r,$i)] = odbc_result($r,$i); $x++;

}
odbc_close($conn);
?>
So now you have two arrays, $fields and $results, with all the information in to move the data over to your MySQL database. It is just a case of structuring the table using the $fields array and then looping through all the data in results and adding it to your new table on your MySQL database. Pretty simple really. I am currently fine tuning the script I am using for this, since it will eventually be set up on the Sage Line 50 machine to run as a Scheduled Task in windows to INSERT or UPDATE data on an hourly basis. Once I have completed this script I will share it here will all the nessesary information. It is a shame that there is little to no information for us casual developers to access on Sage and it is a shame that the Developer Community Subscription is so expensive. I hope that my article will help someone trying to do something similar. Clear applications for this that I can think of right away would be if you needed your Sage Line 50 data linked in with your osCommerce data.

Rick Vause's Space

Hi, I’m Rick Vause. I am a web developer that loves Python.

I have always been interested in technology and software. I am a keen supporter of a number of open source projects.

I am obsessed with my ideas and attempts to continuously better myself in both my work and leisure time. I am always learning and trying to improve as long as there is space left in my head. I often find interesting, new things (interesting and new to me, at least) that I share on my blog.

I also like music and art.

I once spent 2 months working on a self-portrait that turned out terrible so for the avatar portrait I turned to my better half, Klaudia.

If you have any questions, comments or wish to talk to me about a project you are working on, please contact me.

I also try to be social so you can find me on Twitter, Facebook and Last.fm.

Contributors

Rick Vause