Sunday

Java - Invalid Number Exception

public class JInvalidNumberException extends Exception {
String mistake;

public JInvalidNumberException()
{
super();
mistake = "Unknown error.";
}

public JInvalidNumberException(String reason)
{
super(reason);
mistake = reason;
}
}

Above is customized exception that is created to be thrown when a invalid postal code enter by a user.

Monday

MySQL note

MySQL does not have "SELECT INTO" statement. A similar statement in MySQL is "INSERT INTO"

INSERT INTO copy_table SELECT * FROM data_table;

The statement copies data from data_table into copy_table

Java data generator

// create child element
child_NumGp_SNO = doc.createElement("SNo");
child_NumGp.appendChild(child_NumGp_SNO);
String sno = String.valueOf(i+1);
Text txt = doc.createTextNode(sno);
// append child element
child_NumGp_SNO.appendChild(txt);

randint = r.nextInt(101);
System.out.print(randint + "\n");

child_NumGp_RAND = doc.createElement("Rand");
child_NumGp.appendChild(child_NumGp_RAND);
String randomint = String.valueOf(randint);
Text txt2 = doc.createTextNode(randomint);
child_NumGp_RAND.appendChild(txt2);


Above is part of Java code that will generate an output XML file that wil be feed by Serial Comm or Network Port to my earlier Line Graph program.

Thursday

Line Graph project

Fig 2

Fig 1

This program is created using C# with graph plotting control from Gigasoft

Not completed yet, but a least the graph is running

[12-May-2010]
Now my program is able to receive data from serial port. The data is displayed on the chart. (See Fig 2)

Wednesday

Stock analysis program using Perl and MySQL


Attach showing part of the perl code that write stock information to MySQL database. The completed code should able to read input list of stock to monitor from a text file, analyse SGX daily stock price in HTML file and write price and other information into a MySQL database.

At present, the program is able to analyse sgx HTML file and write data into MySQL. But the column alignment is a bit out.

Software used/installed
Perl - version 5.10
DBI
DBD-mysql

Heidi GUI for MySQL

Future work
Create a java program that reads from DB and display previous stock price record.

Tuesday

course software project II - program analysis


Sample output of VB.net program

course software project I program analysis



A program created using VB.net

Program challenge
To analyse the text file and create multiple output graphs

Software used/installed
WinGraphz - provides API for graph creation

Monday

Perl - random number generator


The program is written in perl. The motivation to write this script is to generate a random list of numbers that will serve as input to another of my on-going software project.

Objective of this program
1. To create an output which contains random 2-decimal places numbers.

Perl command used:
rand
open
print
sprintf


Requirement
To accept 3 user command inputs (count, filename, step)

Output
a file (filename) with number of lines specified by count

random number with 2 decimal places is generated assigned to y
step determines increment of x.