Win32 Application Online Update (Manually)

Anyone knows that updating such that distributed application is a boring activity, especially for those who have tons of PCs. It can make peoples from IT department wasting their times to upgrading client application. Moreover, looking forward email contain application attachment from software vendor also can bring much troubles for wide company and I mean this is an old-fashioned way. Why don’t you just suggest the vendor to change the update method with an online way? But for this, you need to make sure that the client PCs has internet capability so that you only have to tell the operator to download the update.

The update method is very simple and I did this to one of my client across Jakarta. It’s easy for them to update and me as the software developer to publish the application. Any latest update, I just store it to my domain immediately. How to do that? Look at image simulate the process below:



The process is quite plain; just tell the application to generate a link in any latest version available from web server, but simply ignore the priors so that it will only show the fresh version link. Got that? Ok, let say that you have an online web server named abc.com. Next, prepare a single web based script to generate a link if there is any newest version on hand (on this example, I used PHP script and named it with app.php). Now, the question is, how the scripts can detect and compare between current version and others up-to-date? Well, it’s as simply as that app.php needs to catch what the current application version is. This means that you need to retrieve current version number from the program and make it as a parameter when the URL has navigated to app.php. In case I used Borland Delphi for this test, so I drop-in a TWebBrowser component in a form and let it navigate to http://www.abc.com/app.php?v=1. The "1" number refers to current version application.


const InfoNum = 10;
InfoStr: array[1..InfoNum] of string = ('CompanyName', 'FileDescription', 'FileVersion', 'InternalName', 'LegalCopyright', 'LegalTradeMarks', 'OriginalFileName', 'ProductName', 'ProductVersion', 'Comments');


procedure TFAbout.FormShow(Sender: TObject);
var S: string;
n, Len, i: DWORD;
Buf: PChar;
Value: PChar;
Begin
S := Application.ExeName;
n := GetFileVersionInfoSize(PChar(S), n);
if n > 0 then
begin
Buf := AllocMem(n);
Memo1.Lines.Add('VersionInfoSize = ' + IntToStr(n));
GetFileVersionInfo(PChar(S), 0, n, Buf);
for i := 3 to 3 do
if VerQueryValue(Buf, PChar('StringFileInfo\040904E4\' + InfoStr[i]), Pointer(Value), Len) then
WebBrowser1.Navigate('http://www.abc.com/app.php?v='+Value);
FreeMem(Buf, n);
end;
end;


Done with client application, now it turns to PHP script app.php. The app.php consist of comparison between both current version (delivered from client via TWebBrowser component) and others up-to-date version. Take a look at completely app.php below:

<?
$v=$_GET['v'];
?>
<html>
<head>
<title>Download Update</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#E4E4E4">
<em>Current Version: <?=$v?></em><strong><br>Download Update</strong>:<br>

<?php
$wrong=0;
$right=0;
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file !="app.php") {
$file_zip = substr($file,0,1);
$file_tmp = substr($file,1,1);
if ($file_tmp>$v && $file_zip=="v")
{
$right++;
echo "&#8226; <a href='$file'>$file_tmp</a> (" . filesize($file)/1000 . " Kb)<br>";
}
else $wrong++;
}
}
closedir($handle);
}
if ($right==0 && $wrong>0) echo "-"; // shows �-� if no update available
?>
</body>
</html>



Store both of app.php and latest zipped application (v2.zip on sample) in a same path over the web server. At last, try to do a test.



Voila, those little scripts now works helping IT department from updating application task over the internet and buried the ancient way. The above scripts can be expanded to do various things for your Win32 application. Good day and don’t forget to leave your comment here.

Labels: , , , , , ,

  Post a Comment

Where’s My Last Record?

If you have develop an application (Win32 based I mean) & playing around with great number of records then I suggest you not to let users wasting their time to scroll rows in a list of table & select what record they need time after time. Got what I’m talking about? No? Okay, in a specific case, data transactions committed by an assist of others record, let say a combo or grid of records. It would be nothing if it has 10 records, how about 100 or more? I can guarantee that users will be flustered or the mouse soon will be broken because a long scroll or thousands clicks over it.

I’m saying about to keep last record position in memory & store it on next task. Pretty simple but it helps users effectively, at least minimize the use of scrolling. Here my example on Delphi, with TDBGrid contains records retrieved from a table & assigned with TQuery component. Once TQuery refreshed, record pointer will be at first position. To avoid this, save bookmark pointer before TQuery refreshed & store position in after. Check a code sliced below:

unit ULastRecordPointer;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, DBGrids, ComCtrls, DB, DBTables, ExtCtrls, JPEG;

type
TFLastRecordPointer = class(TForm)
...
private
{ Private declarations }
public
{ Public declarations }
end;

var
FLastRecordPointer: TFLastRecordPointer;
...
ptr_record: TBookmark;

implementation

{$R *.dfm}

procedure TFLastRecordPointer.FormRefresh(Sender: TObject);
begin
try
q3.GotoBookmark(ptr_record);
except
//
end;
end;

procedure TFLastRecordPointer.DBGrid1DblClick(Sender: TObject);
begin
ptr_record:=q3.GetBookmark;
end;
end.


The last record position will be saved if users had double clicking on grid (pick a record) & try to store it after the form refreshed. So that the small black triangle will stay on it’s previous position.



With this help of TBookmark, users job will assisted & no more times will be wasted. Furthermore, your users mouse will be much more durable ;-p

Labels: , , ,

  Post a Comment

JavaScript: Return Multiple Values in Count Between Dates Function

JavaScript is one of parts that can’t be separated with web programming. Sometimes we usually depend on it, although we can solve the problem with another technique but the use of JavaScript is much helpful to support dynamic runtime application. For example manipulating or counting math is possibly without refreshing the page. Therefore, it is much simpler than AJAX. This article purposely dedicated to my self & any newbies which want to learn JavaScript methods.

Just like my own experience improving a page counting difference between two dates, here I found something new & I’d like to archived for me then share to you. The web page project it self are related to MySQL date field type & based on PHP programming. The subject was, how to calculate the year & month difference by both dates after the page loaded & once the date object is changed? As usual, I set the date interface with JavaScript so it would generate an interesting GUI just like common date object on Win32 programming.



Those dates GUI are compatible with date type format in MySQL (yyyy-mm-dd). When the date icon clicked, it will show small interactive calendar panel. The first date object I named with date_start, the second is date_end & sequentially, the difference year & month is n_year & n_month. The core date subtract function need 2 parameter dates & I created as well as it will return more than one value (year & month). On JavaScript, the treatment is put it on array mode. Pick out a small portion below:

function selisihTgl(dateEnd,dateStart)
{

return [yearAge, monthAge];
}


Displaying returned both value from function in array are simply called the array variable just like any others programming which is 0 based in bracket.

function fSelisih(sender)
{

obj.n_year.value=selisih[0]
obj.n_month.value=selisih[1]
}


That’s it, kinda simple isn’t it? By the way – unfortunately -, when dates changed, the date GUI object doesn’t have trigger event to call the function. So, I take <FORM> tag with onMouseMove event. Pretty dumb, but it works fine. Below is complete script from A to Z, check this out:

// portion of PHP code to retrieve both dates value from MySQL database
...
//
<HTML>
<HEAD>
<TITLE>Your Title Please</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
</HEAD>
<script language="JavaScript">
function selisihTgl(dateEnd,dateStart)
{
var baru = new Date(dateEnd.substring(0,4),
dateEnd.substring(5,7)-1,
dateEnd.substring(8,10));

var yearBaru = baru.getYear();
var monthBaru = baru.getMonth();
var dateBaru = baru.getDate();

var lama = new Date(dateStart.substring(0,4),
dateStart.substring(5,7)-1,
dateStart.substring(8,10));

var yearLama = lama.getYear();
var monthLama = lama.getMonth();
var dateLama = lama.getDate();

yearAge = yearBaru - yearLama;

if (monthBaru >= monthLama)
var monthAge = monthBaru - monthLama;
else
{
yearAge--;
var monthAge = 12 + monthBaru -monthLama;
}

if (dateBaru >= dateLama)
var dateAge = dateBaru - dateLama;
else
{
monthAge--;
var dateAge = 31 + dateBaru - dateLama;

if (monthAge < 0)
{
monthAge = 11;
yearAge--;
}
}

return [yearAge, monthAge];
}


function fSelisih(sender)
{
var obj=sender;
var selisih = selisihTgl(obj.date_end.value,obj.date_start.value);
obj.n_year.value=selisih[0]
obj.n_month.value=selisih[1]
}
</script>
<BODY onLoad="fSelisih(this)">
...
<form action="path/to/save/or/ignore/it" method="post" name="form1" onMouseMove="fSelisih(this)">
...
</form>
...
</BODY>
</HTML>


Don’t forget to insert the function within onLoad event on <BODY> tag to automatically count them expressly when the page are fully loaded.



Done! Enough for now lesson & I’ll be back with another unique tips & trick programming.

Labels: , , , , , , , ,

  Post a Comment

450 Fresh PCs Inspecting


The task to inspecting total of 450 new Z*rex computers on it’s factory has been done. Me & the team consists of 10 man just already did it in 3 days. This all brand new PCs was ordered from the company I’ve been worked after having a selection criteria to choose much lower price with better performance & hardware specification (what an usual criteria!). Lot of certified PC vendors was submitted to join the beauty contest before. Some of them came with world trade name, such as HP, Acer, Dell & much more. At the end, the local PC Z*rex won the competition (again, with an annoyed thing!).

The OS agreement as listed on the official appointment was so simple. They only have to plugged in the Linux Fedora Core 4 appropriated to our condition in order to support our plan to moving from Windows. The thing is we have to check, test & finalized the agreed hardware specification & also the system configuration one by one PC… manually. Fiuh… better no to do that by your own finger!


To simplify the jobs, I created an automated batch bash shell based script to identify the hardware specification & the system configuration. This script are executed from the USB storage flash disk. So, the mounting process will also checking any of the front USB port damaged at the same time to the new computer. It is shown below:

#!/bin/bash
Common bash shell script initialization syntax

top
Check the amount of available physic RAM

echo swapon /dev/sda3 >> /etc/rc.local
Since the image developed by vendor are come with inactive swap (I wonder why?), so I try to activate it manually to the Linux startup files. The syntax above will automatically adding the swapon command to the end of the /etc/rc.local file.

swapon /dev/sda3
Try to activate the swap to test whether it’s linked & matched with the dedicated swap partition

cat /proc/swaps
Finally, check the available of active swap partition

lspci
Displaying the chipset detailed information

cat /proc/cpuinfo
Displaying the processor detailed information

df -hT
Displaying the rest partition available complete with the volume space & partition type

kppp
Execute the kppp interface to test the internal modem query process

umount /media/usbdisk
Unmount the UFD hardware safely

poweroff
Shutdown command

The dumb scripts above are really increasing about 5x faster then our manually checking time. Once the PC is quality control confirmed, it patched with a passed logo sticker & continued to packer staff.

Labels:

  Post a Comment

VirtualBox: Another Open Source Virtual Machine (Part III)

From the previous serious problem, I have to make a solution about how to bridging on Linux hosts over the VirtualBox, but I great successfully working on it. From the documentation available, the VirtualBox implemented Host Interface Networking with the Linux kernel's own TAP interfaces. Therefore, make sure that Linux kernel has support for TUN/TAP enabled. While the additional drivers are then not required, the TUN/TAP packages are not available on Fedora Core 4 setup CD’s. There are at least 3 packages are needed to enabled it.

tunctl utility
With TAP, the Linux kernel can simulate Ethernet interfaces that, instead of being attached to networking hardware, communicate with VirtualBox. The TAP interfaces therefore appear like physical network interfaces (e.g. eth0) on the system. To create a TAP devices, use the tunctl utility. For Fedora Core 4 release, have a download session on this link.

brctl utility
Bridging, then, is a feature provided by the Linux kernel and can be controlled with the brctl command from another utility package. This tiny packages released for Fedora Core 4 are available on this link.

libsysfs library
The libsysfs is a dependency library needed by the brctl utility. Again, for Fedora Core 4, the download link are available here.

There are two ways these interfaces can be created, define a static link or dynamically. A static link build a persistent TAP interfaces on the Linux host and make them available to VirtualBox. While a dynamically build TAP interfaces each time a VirtualBox starts, and destroyed when it stops. To simplify this, I let you know how to create a static link. For a moments, go provide those 3 packages above available & install it on your Linux system. Then perform the following steps as root:

1. As root, run tunctl to create a new TAP interface:
tunctl -t tap1 -u
where is the user who wants to run VirtualBox with the new bridge.

2. Create a new bridge, which we will call br0:
brctl addbr br0
3. Put your network adapter in promiscuous mode so that it will accept Ethernet frames for MAC addresses other than its own:
ifconfig eth0 0.0.0.0 promisc
You will lose network connectivity on eth0 at this point.

4. Add your network adapter to the bridge:
brctl addif br0 eth0
5. Transfer the network configuration of your ethernet adapter to the bridge (the following example assumes your network adapter is configured with DHCP):
dhclient br0
Your physical Ethernet adapter will now merely act as a transport medium for the bridge.
For configurations where the network adapter is configured statically, you need to setup br0 exactly as you would have set up eth0. At this point the host should have network connectivity
again.

6. Add the new TAP device to the bridge as well:
brctl addif br0 tap1
7. Activate the new TAP device:
ifconfig tap1 up
After this, you can now specify tap1 in the settings of your virtual machine, as if it were a real network adapter. Note that in order to use a static TAP interface, the VirtualBox process needs to have write access to /dev/net/tun. Either make sure the access bits allow access or add the user of the VirtualBox process to the group owning that device file.



Go get some pinging process to local Linux host or other else hosts & it will working good. By the way, if the existing network are configured with proxy & gateway, you may adding a router mechanism after succeded bridging the VirtualBox. This would done by "route add" command prompt at Windows, just like example below:
C:\WINDOWS\Desktop>route add 10.1.1.0 mask 255.255.255.0 10.1.7.225

C:\WINDOWS\Desktop>route print

Active Routes:

Network Address Netmask Gateway Address Interface Metric
10.1.1.0 255.255.255.0 10.1.7.225 10.1.7.225 1
10.1.7.0 255.255.255.0 10.1.7.225 10.1.7.225 1
10.1.7.225 255.255.255.255 127.0.0.1 127.0.0.1 1
10.255.255.255 255.255.255.255 10.1.7.225 10.1.7.225 1
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
224.0.0.0 224.0.0.0 10.1.7.225 10.1.7.225 1



The settings above are helping me to connect to the LAN & internet connectivity from the proxy or gateway. So on, there will be no problem with the Windows based native application required networking link but totally failed to run over the Windows emulator. Just like the problem I described earlier…



So, case is closed!

Labels:

  Post a Comment

VirtualBox: Another Open Source Virtual Machine (Part II)

For more furthers, I had tried to run the VirtualBox with the same version of Linux Fedora Core 4 in a multiprocessor machine to test how far the compatibility on it. They just did it well. The VDI image file from the previous machine was copied into this multiprocessor machine & it run normally without any problems. So it is as simply as plug & play since I don’t have to create the Windows 98 from scratch to do the test.

Anyway, there are some serious problems I face within it. If you have the features of SELinux enabled, just turn it off since it will produce an error messages said something like "/opt/VirtualBox-1.3.8/VirtualBox: error while loading shared libraries: /opt/VirtualBox-1.3.8/VBoxVMM.so: cannot restore segment prot after reloc: Permission denied". Another solution to solve the problem is trying to change the information security context file with the command below:
$>chcon -R -t texrel_shlib_t /opt/VirtualBox-1.3.8/*.so
Other errors you might face, if the VirtualBox installation stage are getting corrupt, it will raise a "VirtualBox - Error" window containing the text "Failed to create new session" & "Callee RC: 0x80040154". This window appears in the final step while creating, modifying or running the virtual environment OS. To solve this, try to make a fresh install the VirtualBox setup package again.

From my couple days experience with Windows 98 running on VirtualBox, the USB storage devices are fully working without driver installed. As we know that it is so differ if we natively running Windows 98. It proved that the VirtualBox HAL (Hardware Abstraction Layer) specifically to the USB host bridging are successfully implemented. Unfortunately, when I tried to connects the Smart Link 56K internal modem, it giving me a great headache since there is no single one COM port detected. I don’t have any idea why it could be happened, while the Windows 98 native said it is OK.



By the chance, I would like to give a try with installing Windows 2000 on a same machine. First of all, I prepared the virtual disk with size of 1GB. The installation started with Windows 2000 boot setup CD from ASUS external DVD-RW drive.



Anyway, this virtual disk was formatted in NTFS format type.



The installations ~ somehow ~ are quite faster than Windows 98, also the boot sequences until the desktop shows up. Nothing serious problems happened anyway.



Got curious about the unavailable of COM port in Windows 98, I also tried on this fresh Windows 2000. Guess what? The detection has failed too! There are none of existing com port on the computer! What is going on with it?



I wondered why it could be happened. Is there any VirtualBox configuration files I missed? Or something is not done configured properly on the hardware side? One for sure, I couldn’t test the internet connection from modem yet. After having a some times searching over the VirtualBox website forum, finally I found a reason why it happened. According to the information on this link, VirtualBox is still doesn’t have ability to support the COM port yet! WTF! In this worsted scenario, the networking bridging become my last solution. It means that I have to provide a real virtual network connection shared from the proxy or gateway from other machine. Got to get this thing down or got my ass sited for a long long times. Fiuh!

Labels:

  Post a Comment

VirtualBox: Another Open Source Virtual Machine (Part I)

Somehow, an application that highly needed in the company I’ve been worked was failed to run with Linux upon the emulator. This application specifically ~ recognized from the meta file information ~ build from Visual Basic 6, using the Microsoft Access as the database storage & also requiring Crystal Report library to previewing the reports. Actually ~ as anyone can see ~ this is the very basic application & might run on emulator such as wine or crossover. From the global process explained by the programmer in US, I also found that it depends on some RPC (Remote Procedure Call) or similar process which didn’t exist in the emulator (it is a kind of thin client application models which try to connecting the server with VPN technology). Just a times before, I had tried several bottles methods from the latest version of wine or crossover but it seems can’t worked in any way.

After being get some failed & frustrated on how to emulating it, finally now I’m working on a different ways. Just make a try to run it in a virtual machine environment & hoping for a better result. Well, I’m currently not to using VMWare since its package is huge (about 130M) & requiring a high specification computer hardware which we doesn’t have yet in the branches. So, I’m trying to use VirtualBox developed by Innotek, another yet open source virtual machine which available to download from http://www.virtualbox.org. It is a multiplatform virtual machine & would work on any operating system likes Mac OS, Linux & Windows.

For the installation, the VirtualBox need only 13MB of empty spaces. It is a quite less virtual machine package than VMWare, ever!. The setup process are so easy, while it also require a dependency of compat-libstdc++ package which unable to detected before. This can be solve after downloading the packages from http://rpmfind.net according to the using of your Linux version (I’m using Fedora Core 4 with kernel version of 2.6.17).

First, I try to create a virtual host environment for Windows 98 since ~ I thought ~ it will run more smooth than Windows 2000 or Windows XP. Preparing the virtual hard drive is easy as VMWare. I let the space for about 980MB for this. Next, I plugged in the Windows 98 setup CD into my external Asus DVD-RW drives and start the VirtualBox to boot it.


Picture #1. Booting From Microsoft Windows 98 Setup CD on My Fedora Box


Picture #2. Entering The Windows 98 Install Boot Menu


Picture #3. Initialization The Windows 98 Setup Process


Picture #4. Copying Files of Windows 98 On Progress

After finished installation, it’s need to restart. Once, the VirtualBox would raise an error messages likes “PIIX3 cannot attach drive...” or something similar. If you meet this exception, close the VirtualBox & try to fix recompile the setup with run a command below on console.
/etc/init.d/vboxdrv setup
Other else, If you see something else error messages likes “PIIX3 cannot attach drive to the Secondary Master”, try to plug out the devices likes USB flash disk, floppy or something else from the computers. This might be a solution for the problem. Hence I don’t know how to resolve it anyway.


Picture #5. Starting The Windows 98 For The First Time


Picture #6. The Windows 98 Desktop Is Ready

Overall, the installation need much time than I expected before. I’ll post my next article regarding to this about on how to connecting to the network & installing the application I explained above.

Labels:

  Post a Comment

Go Open Source (Part II): Back to Fedora Core (5)

The team & me had already migrate the core server for about a week ago into a Linux server. The core server which serve the corporate computer operational (such as: Email Server, DHCP Server & Proxy Server) are being running as well as before.

Next schedule to be done is migrating the clients. There are more than 300 computers in the building with various hardware specification & have to be finished before the end of next month. Well, this is our great jobs even with small amount of staffs (9-10 peoples).

The migrating jobs are not easiest as say. There are lot of things we should beware off before getting started the jobs. However, the importance things includes:

1. What kind of Linux will be chooses
This is a real beauty contest of Linux benchmarking scheme to find out what is the best, link & match to the computer hardware. The driver support for the un-plug & play also become your care. Next to the pre-installation of Linux is knowing the CPU & memory load regarding to the others major hardware exists.

At a glance, we were having successful experiences on migrating the branches a year before with Fedora Core 4. The elections were followed by several self-beauty contest with various of Linux. Meantime, we are planning the same mechanism in HQ. The finalist are Fedora Core 5, Fedora Core 6, Open SuSE & PCLinux. The Fedora Core 6 are quite heavy to load that not too fit in most of hardware we had. The using of Open SuSE are also not suitable to implement since it might need more learning by the regional staffs which having knowledge in Fedora Core 4. Since PCLinux come from Debian family (which having a great optimalization & compact Linux kernel), ahrghh it is so difficult to get a live online support (for me). So, finally we choose Fedora Core 5. That it is most reliable & more easy to use up. Just for sure relax condition, you might need to add the RAM up to 256 MB for it minimal requirement.

2. The installation mechanism
Provide the installation manual book to threat the same way of installing process, so that all computers will running the same configuration.

By the time, I’d already arranged the installation guidance of Fedora Core 5. From it started about how to create room partition with disk image created by Norton Ghost utility until it done about how to configure & running the internal corporate basic application.

3. Application before & after the migrating process
This is the hardest point that have to be achieved. The application which rolling the basic corporate operational should run at the same manner & behavior after the migrating process. The way that have to care about is the application performance as the whole process. Whether it is reliable or not, give this point in a big attention so it would run on it better performance.

In the office, we had several applications based on various databases. While the consolidation program are using 16 bit fox-based compiler, we also had HRD program which developed with 32 bit Power Builder compiler using the Oracle as the back-end database.

Fortunately, the DOS emulator (dosemu 1.3.3, the latest stable DOS emulator package from ASPLinux RPM version I found on rpmfind.net ~ don’t forget to add the package compat-slang-1.4.9-27.2.1.i386.rpm for support on console) are much supporting the Fedora Core 5. Also the CrossOver 5 are quite compatible & robust to handle the Windows 32 bit application. So, both are more smoothly endorsing the migrate process. Just another yet lucky me!

4. Control & behavior each users after the migrating process
Well, it was about quarter century peoples were ready to know Windows. No wonder, there will be much yells when they hitting Linux for the first time. This is a new challenge for you, how to make them “silence”?

The job is much harder when we have to planning something about loosing users worried when they are not too familiar with Linux. The point is, we are talking about the Windows similarity GUI & common replacement application. First of all, we leading the users into a KDE interface (the best & better desktop manager in Linux, AFAIK), then we fill in the application which have the same functionality in Windows. There are OpenOffice to replace the Microsoft Office for examples. Even it will raise a small number of contradiction, but it is the consequences.

5. Preparing the online support
Last but not least, create a full team to assists the newbie users. They will yell louder if you are not in his side. Allow the phone line open in the office hour & make a quick clear answer to respond.

We are designing to make a team shifting at work to helping the users. It is an optimal way showing who’s in charge to pick up the phone line extending to team long live performance.

This article will continue at the end of the finalization…

Labels:

  Post a Comment

Working with Barcode (Part I)

For couple days, I’ve been playing around with barcode tool to support my existing project software development. This become my new experience about how to create the schematic image from several type of barcode and finally pick one to implementing on my Delphi form projects.



Let me introduce to the barcode reader hardware first. The reader comes with a straight PS/2 port compatible to USB cables extension. It has made from Taiwan with serial code 1000 CCD mode from CipherLab 1300. The sensor are quite accurate and support the most known barcode types such as Code39, Italian Pharmacode, French Pharmacode, Industrial 25, Interleave 25, Matrix 25, Codabar, Code93, Code128, UPCE, EAN8, EAN13, MSI, Plessey and PDF417.

Before getting it done, I had to create a small card-name size which typed a tiny barcode image consists 9 digits of number somewhere on it in one of my modules. So, smallest possible barcode image would be nice to paint on the front side of the card. The next question is, what type of barcode I have to choose?

From third party tool application got from internet (shmia@bizerba.de), I had analyzed several barcode images priorities on the length size and sort it in order to fit in the card form I described before. And below is the result :


CodeUPC_Supp2 (Unable to read)

CodeUPC_E0 (Unable to read)

Code_2_5_interleaved

Code_2_5_matrix

Code128C

CodeEAN13

CodeCodabar

Code_2_5_industrial

Code93

Code128A

CodeMSI

Code39

CodePostNet

CodeEAN128A

From the result above, I surely my mind to choose the Interleave 25 barcode type. It has less length and still able detected by the reader hardware. The module I developed, require no external font installed on Windows since the TBarcode (TasBarcode) component create the image by it self.
procedure TForm1.FormCreate(Sender: TObject);
begin
{
Create a barcode object.
this object is freed when the form is going to destroyed, because it is owned
by the form (self parameter)
}
Barcode1 := TAsBarcode.Create(self);
Barcode1.Top := 50;
Barcode1.Left := 30;
Barcode1.Typ := bcCodePostNet;
Barcode1.Modul := 2;
Barcode1.Ratio := 2.0;
Barcode1.Height := 50;

Barcode1.OnChange := Self.Barcode1Change;

ComboBox2.ItemIndex := integer(Barcode1.ShowText);
end;
procedure TForm1.print_demo(bc:TAsBarcode); var tmpbarcode : TAsBarcode; begin { create a temp barcode object, because we want to change some properties } tmpbarcode := TAsBarcode.Create(nil); { copy the object } tmpbarcode.Assign(bc); try with printer do begin BeginDoc; { Height of barcode: 40mm } tmpbarcode.Height := ConvertMmToPixelsY(40.0); tmpbarcode.Height := ConvertInchToPixelsY(1.5); { Modulwidth: 0.5mm } tmpbarcode.Modul := ConvertMmToPixelsX(0.5); tmpbarcode.Top := ConvertMmToPixelsY(100.0); tmpbarcode.Left := ConvertMmToPixelsX(35.0); tmpbarcode.DrawBarcode(Canvas); EndDoc; end; finally tmpbarcode.Free; end; end;
This article will continued...

Labels:

  Post a Comment

Top 3 at Bubu Awards 2007 (?)

After waiting for some times, finally my corporate website I’d developed before has been listed as the finalist of the Bubu Awards this year. It will take couple weeks to find out who become the winner from 2 others finalist such as danamon and e-bursa.com.



Now, I’m dreaming about tons of SMS are electing it since – I guess - there will be no one are vote for it. Lets hope for better result tomorrow.

Labels:

  Post a Comment