Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Saturday, December 8, 2012

Delphi is my favorite tool for Windows Programming

I've always been drawn to Pascal and preferred it's syntax to the terseness of C.  I learned the basics of Turbo Pascal in an afternoon (after experience with Turing, BASIC and FORTRAN).  For Windows programming, I've always found Delphi to be the best tool available - especially if you aren't a C++ expert.  Delphi combines the power of C++ with the ease of Visual Basic.  I only stopped using Delphi for grade 12 computer science because Delphi 5 (1999) wouldn't run on Vista or Windows 7 and I switched to Java because it was free.  Delphi would have cost the school $100/license.  I never really got into Java (it's a huge language) and now I'll be switching to Python which has a syntax that I prefer.  Some of the programs I use a lot are written in Delphi:  WinGrab and Integrade Pro.

Before the social media craze, I thought RSS feeds would be a great way to publicise school events.  I wrote a Delphi 7 program to update RSS feeds 5 years ago.  It took me about 45 minutes to figure out how to call the Windows API to do FTP tasks with Delphi.  Unfortunately, this never caught on with the school.

However, when I setup Xibo digital signage at school last year, it required an RSS feed as the source of the announcements.  Consequently, I modified the program to suit the needs of this new task.


Recently, I learned how to add images to RSS feeds.  I've been doing this manually and had to figure out how to scale the images properly to maintain the proper aspect ratio.  Today, I figured out how to add this feature to my Delphi program.  I also tried to clean it up a bit so it could be more easily adapted for use at other schools.  I was amazed that you could import an ActiveX control which lets you access the image properties from the browser.  Once I had the height and width of the image, it was easy to scale the image for the RSS feed.  One page I Googled had a typo, but I figured it out by looking at the Delphi generated Pascal file (650,000 lines of code!) for the ActiveX control.  A different page didn't have the typo (I found this 2nd).

I'm glad Delphi is still around.  It's kind of expensive, but educators can have a copy for $100 (RAD Studio Pro even comes with RAD PHP, and C++). Here's a nice site called Delphi for Fun.  I think it's fun too!  It allows a non-expert like me to solve practical programming problems with relative ease!  Delphi Basics is a great reference as one is working with Delphi.

Friday, July 27, 2012

CS4HS UTM July 23-25

Instructional Centre
This past week, UTM hosted a Google CS4HS learning opportunity attended by 16-18 teachers (mostly from Peel and Toronto).  Interestingly, that's about the same number that attended the USask CS4HS event 3 weeks prior.  At last year's UT CS4HS on the main  Toronto campus, there were about twice as many teachers. I had never visited University of Toronto at Mississauga before (formerly called Erindale College).  They have just completed a host of new buildings and most of CS4HS was held in the Instructional Centre.  There were sessions on Python, HTML5/Javascript, general problem solving and sharing amongst the participants and UTM staff.  The level of the participants was quite high and the UTM staff put together a very full and useful program.  They posted a resources page which will be useful and I made some notes along the way for both CS4HS events.

My plan is to use Python instead of Java next year for grade 12.  I may even use it for both grade 11 and grade 12.  The only downside is GUI programming isn't so easy like with Visual Basic or Delphi! I've been working through some exercises and this excellent (short tutorial) Byte of Python.  There are really a ton of free resources out there (textbooks, game programming books, software).  I used Portable Python 2.7  and 3.2 at the UTM event.  It includes PyScripter IDE which I now prefer to Eclipse (less overhead).  Python has a lot of neat features that make problem solving rather than the language the focus.  I would have to say HTML5/Javascript is not so much in that same design mode!

In the past, I always thought using 2 languages (Basic in grade 11, Pascal then Java in grade 12) was a good idea.  Now I am thinking I'll use Python in both grade 11 and grade 12.  Hopefully, by grade 12, we can deal with more interesting (complex, thoughtful) problems and near the end of the class, introduce HTML5 / Javascript for event driven programming.  When I first started event driven programming with VB and Delphi, it took some getting use to compared to the console-type programming I was used to.  It seemed like an extra layer of complexity.  Python with a good IDE (Pyscripter) is very responsive (like QBasic in the past).  I noticed virtually nobody used Netbeans or Eclipse as their Java IDE because it was too much.  Some used BlueJ, others DrJava and I think that was probably a better choice (I've been using Netbeans).
UTM Library

Monday, May 7, 2012

The right tool makes all the difference

I am thoroughly impressed with MySQL and PHP.  The software DBQwikSite is another tool I think highly of.  I have been thinking of how to create a database to calculate school activity points for the last few years.  I started with thinking about how it could be done with Delphi by programming it straight from scratch.  Then I thought about Access.  Then I thought about Delphi or VB.NET to connect to any database.  I could not make very much progress because I was using the WRONG TOOL.  Then, I was exposed to MySQL and PHP through Xibo digital signage.  That was my first exposure to PHPMyadmin to work with MySQL databases.  Last summer, I discovered DBQwikSite.  This slick software lets you create a data driven website without programming.  However, it makes it easy for you to insert custom code (HTML, PHP) so that you can customise the site.  I read Paul Litwin's relational database primer to figure out how to design the two tables required.  I learned about some aspects of MySQL and PHP through W3Schools.  I had to do numerous Google searches to figure out various things
  • how to deal with NULL values
  • how to use MySQL VIEW to create virtual tables (this is so you can make computed fields).
  • how to pass a parameter from one PHP page to another PHP page.
  • how to secure the database with PHPMyadmin (create users) and DBQwikSite
  • creating reports by outputting the SELECT query result (which is an array)
It's all come together and the database website works quite well!