2004. november 14., vasárnap
Display a long path as "c:\...\path\myfile.txt"
Problem/Question/Abstract:
Display a long path as "c:\...\path\myfile.txt"
Answer:
To display a (potential) long path shortened in the format shown above, you may use the function MinimizeName from Delphi's unit FileCtrl.
In case you were using a TLabel, you can register the component TPathLabel (declared in the same unit); TPathLabel uses MinimizeName to display the caption.
// \Delphi\Source\Vcl\FileCtrl.pas
unit FileCtrl;
function MinimizeName(const Filename: TFileName; Canvas: TCanvas;
MaxLen: Integer): TFileName;
type
TPathLabel = class(TCustomLabel);
2004. november 13., szombat
Rounding numbers in different ways
Problem/Question/Abstract:
How can I round a number "normally"? Can I round the thousands? Can I round the third digit after the decimal point?
Answer:
Integer rounding
The Round function that comes with Delphi performs what is called "banker's rounding", meaning that a number with a fractional part of 0.5 is rounded sometimes up and sometimes down, always towards the nearest even number. This means that for example Round(3.5) gives 4 while Round(2.5) gives 2. Here goes a set of functions for rounding numbers, including RoundN which rounds a number "normally" (i.e. RoundN(3.5) is 4 and RoundN(2.5) is 3).
function Sgn(X: Extended): Integer;
// Returns -1, 0 or 1 according to the
// sign of the argument
begin
if X < 0 then
Result := -1
else if X = 0 then
Result := 0
else
Result := 1;
end;
function RoundUp(X: Extended): Extended;
// Returns the first integer greater than or
// equal to a given number in absolute value
// (sign is preserved).
// RoundUp(3.3) = 4 RoundUp(-3.3) = -4
begin
Result := Int(X) + Sgn(Frac(X));
end;
function RoundDn(X: Extended): Extended;
// Returns the first integer less than or
// equal to a given number in absolute
// value (sign is preserved).
// RoundDn(3.7) = 3 RoundDn(-3.7) = -3
begin
Result := Int(X);
end;
function RoundN(X: Extended): Extended;
// Rounds a number "normally": if the fractional
// part is >= 0.5 the number is rounded up (see RoundUp)
// Otherwise, if the fractional part is < 0.5, the
// number is rounded down (see RoundDn).
// RoundN(3.5) = 4 RoundN(-3.5) = -4
// RoundN(3.1) = 3 RoundN(-3.1) = -3
begin
(*
if Abs(Frac(X)) >= 0.5 then
Result := RoundUp(X)
else
Result := RoundDn(X);
*)
Result := Int(X) + Int(Frac(X) * 2);
end;
function Fix(X: Extended): Extended;
// Returns the first integer less than or
// equal to a given number.
// Int(3.7) = 3 Int(-3.7) = -3
// Fix(3.7) = 3 Fix(-3.1) = -4
begin
if (X >= 0) or (Frac(X) = 0) then
Result := Int(X)
else
Result := Int(X) - 1;
end;
function RoundDnX(X: Extended): Extended;
// Returns the first integer less than or
// equal to a given number.
// RoundDnX(3.7) = 3 RoundDnX(-3.7) = -3
// RoundDnX(3.7) = 3 RoundDnX(-3.1) = -4
begin
Result := Fix(X);
end;
function RoundUpX(X: Extended): Extended;
// Returns the first integer greater than or
// equal to a given number.
// RoundUpX(3.1) = 4 RoundUpX(-3.7) = -3
begin
Result := Fix(X) + Abs(Sgn(Frac(X)))
end;
function RoundX(X: Extended): Extended;
// Rounds a number "normally", but taking the sign into
// account: if the fractional part is >= 0.5 the number
// is rounded up (see RoundUpX)
// Otherwise, if the fractional part is < 0.5, the
// number is rounded down (see RoundDnX).
// RoundX(3.5) = 4 RoundX(-3.5) = -3
begin
(*
if Abs(Frac(X)) >= 0.5 then
Result := RoundUpX(X)
else
Result := RoundDnX(X);
*)
Result := Fix(X + 0.5);
end;
Rounding to a decimal digit
The functions we've just presented above always round to the last integer digit, but sometimes we need to round for example to the second decimal or to the thousands, millions or billions. You can overload the RoundN function with this version that takes an extra parameter to indicate the digit to be round:
function RoundN(x: Extended; d: Integer): Extended;
// RoundN(123.456, 0) = 123.00
// RoundN(123.456, 2) = 123.46
// RoundN(123456, -3) = 123000
const
t: array[0..12] of int64 = (1, 10, 100, 1000, 10000, 100000,
1000000, 10000000, 100000000, 1000000000, 10000000000,
100000000000, 1000000000000);
begin
if Abs(d) > 12 then
raise ERangeError.Create('RoundN: Value must be in -12..12');
if d = 0 then
Result := Int(x) + Int(Frac(x) * 2)
else if d > 0 then
begin
x := x * t[d];
Result := (Int(x) + Int(Frac(x) * 2)) / t[d];
end
else
begin // d < 0
x := x / t[-d];
Result := (Int(x) + Int(Frac(x) * 2)) * t[-d];
end;
end;
Copyright (c) 2001 Ernesto De Spirito
Visit: http://www.latiumsoftware.com/delphi-newsletter.php
2004. november 12., péntek
Paint the form with a tiled bitmap
Problem/Question/Abstract:
Paint the form with a tiled bitmap
Answer:
You may use this code to accomplish it:
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormPaint(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
destructor Destroy; override;
end;
var
Form1: TForm1;
Bitmap: TBitmap;
..
procedure TForm1.FormCreate(Sender: TObject);
begin
Bitmap := TBitmap.Create;
Bitmap.LoadFromFile('C:\WINDOWS\cars.BMP');
end;
destructor TForm.Destroy;
begin
inherited;
Bitmap.Free;
end;
procedure TForm1.FormPaint(Sender: TObject);
var
X, Y, W, H: LongInt;
begin
with Bitmap do
begin
W := Width;
H := Height;
end;
Y := 0;
while Y < Height do
begin
X := 0;
while X < Width do
begin
Canvas.Draw(X, Y, Bitmap);
Inc(X, W);
end;
Inc(Y, H);
end;
end;
2004. november 11., csütörtök
Getting network workgroup name
Problem/Question/Abstract:
How to get network workgroup name
Answer:
I reently noticed that the question "how to find out what's the network workgroup" was being constantly asked. As I had already had the same question and figured it out by myself, I wrote a little function that will do the trick. The trick here consists in reading the "Workgroup" string from the 'System\CurrentControlSet\Services\VxD\VNETSUP' key in the registry (under HKEY_LOCAL_MACHINE). Anyway, here's a shortened (but working) version of the routine I came up with. Note that if the workgroup name can't be retrieved - for any reason - the string '(n/a)' will be returned, standing for 'not available'.
function GetNetWorkgroup: string;
var
Reg: TRegistry;
begin
Reg := TRegistry.create;
Result := '(n/a)';
with Reg do
try
RootKey := HKEY_LOCAL_MACHINE;
if OpenKey('System\CurrentControlSet\Services\VxD\VNETSUP',
false) then
Result := ReadString('Workgroup');
finally
CloseKey;
free;
end;
end;
2004. november 10., szerda
What Custom Compiler messages can do for you
Problem/Question/Abstract:
One of the problems of working in a large project is that you need sometimes to mark certain places of you’re source code, remaining you of things you need to do.
We can mark those places in the code, letting Delphi remind us of them.
Answer:
One of the problems of working in a large project is that you need sometimes to mark certain places of you’re source code, remaining you of things you need to do. There are a number of experts for Delphi that provide a to-do list, even one (nice one) that comes with Delphi.
One think that always bugs me about having a separated list of To-Do items is that you have to go and look for it. You can just as well forget all about it, and it loses it’s purpose. Wouldn’t it be nice if we could tell the compiler to generate a message each time a code with To-Do items is compiled?
Another thing is that a To-Do List is good for project level reminders, not a unit of even object level. You need a reference from the To-Do Item to the unit or object, some way of getting from the item to the code.
I find that using custom compiler messages, I can get another way to remind me of what not to forget. It allows me to overcome the two inconveniencies above, letting me insert reminders directly into the code and letting the compiler remind me of them.
The syntax for this command is
{$MESSAGE HINT|WARN|ERROR|FATAL 'text string' }
and some examples of it (taken from the Delphi help files) are:
{$MESSAGE 'Boo!'}emits a hint
{$MESSAGE Hint 'Feed the cats'}emits a hint
{$MESSAGE Warn 'Looks like rain.'}emits a warning
{$MESSAGE Error 'Not implemented'}emits an error, continues compiling
{$MESSAGE Fatal 'Bang. Yer dead.'}emits an error, terminates compiler
One use of this directive that I find very useful is for TBD items – To Be Done. I use it to replace a To-Do list in this case. There are two advantages to this approach:
You get a compiler message for each item, reminding you to deal with it.
You can browse those messages with the Alt-F8, Alt-F7 keys.
A Code with this directive can look like (just an example from a code I am writing right now):
destructor TumbSelectionTempTable.Destroy;
begin
// Clear the temp tables.
{$MESSAGE Warn ' - remember to free all allocated objects'}
ClearAllOuterWorldFold;
if FSubjectsTempTableCreated then
DropTempTable(FTableName);
FOuterWorldsFolded.Free;
FQuery.Free;
inherited;
end;
2004. november 9., kedd
Save and load TListView items to / from a file (2)
Problem/Question/Abstract:
Does anyone one have any idea how to save the content of a TListView to a text file
Answer:
You could save the contents to a TStrings object, and then save the TStrings using .SaveToFile.
procedure ListViewToStrings(AListView: TListView; AStrings: TStrings; const Delim:
string = ';');
var
Ix, Sx: Integer;
S: string;
begin
AStrings.BeginUpdate;
Ix := 0;
while Ix < AListView.Items.Count do
begin
with AListView.Items[Ix] do
begin
S := Caption + Delim;
if Assigned(SubItems) then
begin
Sx := 0;
while Sx < SubItems.Count do
begin
S := S + SubItems[Sx] + Delim;
Inc(Sx);
end;
end;
end;
AStrings.Append(S);
Inc(Ix);
end;
AStrings.EndUpdate;
end;
2004. november 8., hétfő
Check if Microsoft Word is installed?
Problem/Question/Abstract:
How can I check if Microsoft Word is installed?
Answer:
Solve 1:
Important: this method will only succeed if Microsoft Word 95 or higher is installed.
uses
..., Registry;
function IsMicrosoftWordInstalled: Boolean;
var
Reg: TRegistry;
S: string;
begin
Reg := TRegistry.Create;
with Reg do
begin
RootKey := HKEY_CLASSES_ROOT;
Result := KeyExists('Word.Application');
Free;
end;
end;
Solve 2:
function MSWordIsInstalled: Boolean;
begin
Result := AppIsInstalled('Word.Application');
end;
function AppIsInstalled(strOLEObject: string): Boolean;
var
ClassID: TCLSID;
begin
Result := (CLSIDFromProgID(PWideChar(WideString(strOLEObject)), ClassID) = S_OK)
end;
2004. november 7., vasárnap
Transparent color in glyphs
Problem/Question/Abstract:
Transparent color in glyphs (bitmaps)
Answer:
Delphi always assumes that the color of the bottom left-hand corner pixel is the background color and should be displayed as transparent.
It's not documented anywhere, but if you have the VCL source, you can look at the code in BUTTONS.PAS.
2004. november 6., szombat
Search up and down in a TListView
Problem/Question/Abstract:
How to search up and down in a TListView
Answer:
procedure TRememberMenu.FindDialog1Find(Sender: TObject);
var
MaxLines, Adder, CurrentLine, X: Integer;
LookText: string;
Found: Boolean;
begin
{Find the word}
Found := False;
MaxLines := ListView1.Items.Count - 1;
LookText := UpperCase(FindDialog1.FindText);
if ListView1.Selected <> nil then
CurrentLine := TListItem(ListView1.Selected).Index
else
CurrentLine := 0;
X := CurrentLine;
if frDown in FindDialog1.Options then
begin
Adder := 1;
end
else
begin
Adder := -1;
end;
X := X + Adder;
if (X >= 0) and (X <= MaxLines) then
begin
repeat
begin
if Pos(LookText, UpperCase(ListView1.Items[X].Caption)) <> 0 then
begin
Found := True;
ListView1.Selected := nil;
ListView1.Selected := ListView1.Items[X];
ListView1.Items[X].MakeVisible(False);
ListView1.SetFocus;
end;
X := X + Adder;
end;
until
(X > MaxLines) or (Found) or (X < 0);
end;
if Found = False then
begin
SoundBeep;
end;
end;
2004. november 5., péntek
CD Manufacturing
Problem/Question/Abstract:
CD Manufacturing
Answer:
This is an article from 1994. Quite old, but still interesting to read.
TAKING THE MYSTERY OUT OF MANUFACTURING, PART 1
by Dana J. Parker
Many potential publishers of CD-ROM are unclear about the CD manufacturing process. Even for many experienced CD-ROM publishers, the mastering and replication plant is a black box: they put their data and their money in, and they get discs out.
The CD manufacturing process is perhaps more concerned with standards than any other element of creating a CD-ROM title. In addition to the standard physical and logical formats, there are particular criteria to ensure that each disc meets or exceeds certain quality standards. Manufacturers must stay within given parameters of specific levels for BLER (Block Error Rate), flatness (skew), reflectivity, and birefringence. (Birefringence, also called double refraction, occurs when a light wave breaks into two perpendicular waves upon entering the clear polycarbonate. A birefringent disc would scatter laser light and be very difficult to read).
It's just not that simple to create thousands and thousands of discs, each with billions of pits, each pit as small as 500 hydrogen atoms laid end-to-end, and maintain an uncorrectable error rate of fewer than one in 20,000,000 discs. The manufacture of a CD can be broken down into 5 steps: Premastering, mastering, electroforming, injection molding, and spin coating and printing.
Physical Properties of the Compact Disc
Compact discs are 12 centimeters (4 3/4 inch) in diameter, just over a millimeter thick, and weigh about half an ounce. A disc's physical composition consists of clear polycarbonate, a very thin layer of aluminum, and a lacquer protective coating. A CD-ROM disc can hold up to 680 MB of data: text, images, graphics, sound, video, and animation. Data is stored in the form of microscopic pits arranged in a single spiral track. A pit is about a half-micron wide -- about the size of 500 hydrogen atoms laid end-to-end -- with a single CD-ROM containing approximately 2.8 billion pits. The spiral track makes 20,000 or more revolutions around the disc.
CD-ROM Premastering
Data to be published on CD-ROM may arrive at the manufacturing plant in many different formats. Among the most common are 9 track, 8mm Exabyte, and DAT tape, but many mastering facilities also accept MO (magneto optical) cartridges and SCSI hard drives. Before this data can be used to create a compact disc, it must be converted into the correct format for CD-ROM, CD-I, CD-ROM XA, or CD Video. Also, EDC/ECC (error detection code/error correction code) must be added where necessary. Increasingly, data arrives already recorded in its final CD format, complete with error detection/correction, on CD-Recordable media. U-matic or 8mm tape or CD-R discs can be used as input for the next step, which is the creation of a glass master.
Mastering
Mastering is the process of using an LBR (Laser Beam Recorder) to etch the audio or computer data, in the form of microscopic pits, into either a layer of photoresist or plastic on a glass master disc, which is then electroplated with silver or nickel to form a metal stamper. Photoresist and Non-Photoresist are the two most common methods, although direct metal mastering is under development.
Photoresist mastering requires several steps. First, a highly polished glass disc is coated with adhesive and an even layer of photoresist, and then baked, to "cure" the photoresist. Then the photoresist is exposed to the laser beam, which etches a pattern of pits and lands into the photoresist layer. The glass master is then "developed" in a chemical bath, which cuts away areas exposed to the laser beam. Finally, a metal coating is evaporated onto the etched, developed, photoresist layer. At this point, the master can be tested on a master player. This method is very difficult and time-consuming with many critical steps and stringent humidity, temperature, and air quality requirements. Despite the difficulties of this method, it produces very high quality masters and is used in most plants.
NPR (Non-PhotoResist), also called DRAW (Direct Read After Write) mastering, also starts with a glass master, but the glass is coated with a layer of plastic, which is then vaporized in a pattern of pits and lands by the LBR. A reading laser follows the cutting laser to check the integrity of the cut directly after it is made. This method eliminates the chemicals used in adhesive and photoresist, and the baking and development processes, as well as the necessity for a master player to test the disc. Masters can be created two to three times faster than with the photoresist method, and any errors can be detected immediately, rather than an hour or two after the process begins. The NPR process assures improved efficiency, yield, and productivity over photoresist mastering and is more environmentally friendly. As in photoresist mastering, the final step is to evaporate a metal coating onto the etched layer of plastic. The metal layer makes the glass master electrically conductive.
Electroforming
Once the glass master has been written, tested, and silvered, it is ready to be electroplated. The now electrically conductive disc is placed in a reservoir holding an electrolyte solution (nickel sulphamate) and electrical current is applied at a low level and gradually increased, producing a metal part of sufficient thickness in about two hours. If the number of replications of this particular disc is expected to be 10,000 or less, this nickel copy, called the metal "father," can be used as a stamper to replicate CDs. Otherwise, the metal father is returned to the electroplating process to create metal "mothers," which are in turn used to generate metal "sons," which are the stampers used in molds to replicate CDs. Often, the metal "family" is stored for future reorders. Glass masters can be washed and reused many times.
It's important to note that not all CD manufacturers own their own mastering and electroforming equipment. Many newer and smaller plants do only the mass replication of discs -- that is, the injection molding, metalizing, printing, and packaging of discs at their own plant. They must buy mastering from other, larger plants, which involves sending their customer's data to another plant to be transferred to a glass master and then to a metal father and/or stamper. The stampers are returned to the originating plant, where they are used to mass-produce discs.
Replication
Injection molding techniques are most commonly used to stamp out thousands of copies of a disc in polycarbonate. Polycarbonate was chosen because of its transparency, dimensional stability, impact resistance, and freedom from impurities. Polycarbonate, in the form of pellets, is heated to about 350 degrees centigrade in order to achieve smooth flow properties when injected into mold cavities. Metal stampers created in the electroforming process are carefully mounted to form one side of the platter-shaped mold. The molds themselves are finely machined so that the resulting disc is flat, centered, and free of optical distortion and impurities. Because the molded polycarbonate would harden slowly at room temperature, water channels are carefully designed as part of the molds so that the formed disc can be cooled and hardened quickly and evenly. At this stage of the process, the compact disc is a clear plastic platter with microscopic pits molded into one side.
Metalization, Spin Coating, and Printing
In order for the disc to be readable by a laser beam, it must reflect laser light. Four metals are inert to polycarbonate and have sufficient reflective properties to be used as a reflective layer: gold, silver, copper, and aluminum. Aluminum is the most cost-efficient, and most widely used, although CD-R discs use gold for its greater reflectivity. Some plants offer gold metalizing as an option for commemorative discs and limited runs. An extremely thin layer of metal (50 to 100 nanometers) can be applied to the plastic disc via vacuum evaporation, sputtering, or wet silvering. To protect the metal from scratches and oxidation, a thin layer of acrylic plastic is applied by spin-coating and cured in ultra-violet light. The molded, metalized, spin-coated disc can now be silk screen-printed in up to six colors, or labeled with a special non- impact offset printing process. The disc is now finished and ready to be packaged and shipped. The time from raw polycarbonate to labeling is under two minutes, and a single replication line is capable of producing two million discs per year.
Packaging
There are now as many ways of packaging a CD as there are types of content on CD - too many to name or describe here, with new and innovative ideas in packaging becoming reality every day. The single most popular packaging for CDs of all types remains the jewel case - a clear plastic hinged case with slots for tray cards and booklets. The jewel case, though not cheap - usually about 25 cents each - remains a popular and inexpensive packaging option because the insertion of discs and printed matter into jewel cases can be automated, and most disc manufacturers own the equipment. Other types of packaging - plastic and paper sleeves, for example - require that the disc be inserted by hand. Even in the most automated and high-tech plants you can find workers seated around tables stuffing discs in sleeves. Normally, each motion necessary to insert the disc and printed matter is billed separately. If it takes five separate and distinct motions to assemble a disc in a sleeve with printed matter, the charge will be as much as 20 cents per disc. Even if the packaging itself costs less than a jewel case, using manual labor can make it more expensive.
(Standard Deviations column, CD-ROM Professional magazine, September/October 1994. Contributed by author. May be reproduced with attribution given.)
TAKING THE MYSTERY OUT OF MANUFACTURING, PART 2
By Dana J. Parker
So, you've spent many months and thousands of dollars creating your CD-ROM application. You've designed packaging, tray cards, and label art. You've decided how your product will be marketed, distributed and supported. You've shopped around, gotten pricing from several replicators, and chosen one who can meet your needs at a rock-bottom price, and according to your schedule. You're ready to commit all that work to thousands of polycarbonate discs.
How can you tell if the CD-ROM replicator you have chosen makes good quality discs?
What You Can't See Can Hurt
Getting the right data on the disc, with the right label, and in the right packaging, is what most CD-ROM publishers are concerned with. It's often assumed that quality in disc manufacturing is a "given"; that is, if the disc is good, it will look right, and it will work. It's further assumed that a bad disc won't make it out of the plant into your customers' hands. Many CD-ROM publishers assume that every disc has been completely tested. Others ask about "BLER" (Block Error Rate, see sidebar) and are reassured when the salesperson cites a low figure.
The fact is that in every part of the manufacturing process, from premastering to packaging, there are many things that can go wrong. Some of these manufacturing errors, like a poorly printed label or pinholes in the aluminum reflective layer, are visible. Most are not. Without stringent testing procedures and quality control, cumulative minor errors in every part of the process can add up to an unreadable disc, or a disc that works on some drives but not others, or a disc that works right out of the box, but which degenerates and becomes unreadable over time. Marginally defective discs can also increase random access times. BLER, by itself, is actually a poor indicator of the quality of a disc, because the error detection and correction in CD-ROM drives can overcome many manufacturing errors that are not accounted for by BLER. A disc with a low BLER rate, but with other tolerances at the high end of the scale, can succumb rapidly to environmentally introduced impediments such as dust, dirt, scratches and fingerprints. Worst of all, even a disc that is nominally up to spec may be unreadable on some low-end drives, even though it is functional on others.
A Disc is a Disc...Right?
The very nature of CD-ROM manufacturing makes quality control as difficult as it is important. The average CD-ROM replication run is 1,000 to 1,500 discs. Once the stamper has been placed into the mold, discs can be molded at a rate as high as 15 discs per minute (900 discs per hour). By the time a disc pulled out of the process near the beginning of the run has been tested, the entire run could be molded and ready for labeling. If there's a serious problem, the entire run might have to be discarded. This is time-consuming and costly. In some cases, manufacturers will label and ship marginal discs, and hope that nobody notices.
Most CD-ROM manufacturers started out as CD Audio manufacturers. For many, as much as 90% of their business still consists of CD Audio discs. Because CD Audio discs sell for considerably less than CD-ROM discs, because the content of CD Audio discs is only music played in a stream, and because it is far easier to mask error in audio playback than it is to correct errors in computer data, CD Audio discs are subject to less stringent specifications than CD-ROM discs. Some manufacturers manufacture only CD-ROM, some dedicate molding lines to CD-ROM, some use higher testing standards for CD-ROM discs, and some make and test CD-ROM discs to the same specs as audio discs. One manufacturer recently told me, when I asked what extra quality control measures they used for CD-ROM, "A disc is a disc". Obviously, this is not the kind of manufacturer you want to handle your CD-ROM replication needs.
How to Make Sure that What Can Go Wrong, Doesn't
Finding a replicator who shares your concerns about quality is only part of the solution. There are steps you can take to make sure that what you want is what you get.
Labels and Printed Material: First, make sure that what you order is what you want. If the manufacturer provides templates and specifications for label art and printed material such as tray cards and booklets, use them. Submit your color separated films as specified, with colors denoted as PMS (Pantone Matching System) colors. If you have questions, ask to speak to the graphics department. Make sure any inserts are noted on the order form, or your disc may well be shipped without them. If the dimensions of the tray cards you have printed are even slightly out of spec, they can jam the machinery that inserts them into jewel cases. Use a printer that can ensure conformance to specs, or have the disc manufacturer take care of your printing needs for you.
Premastering: With the increasing use of CD-Recordable discs as input, the possibility of errors being introduced into the actual data that goes on a disc is minimized - as long as the CD-R disc itself is free of defects. Using flawed CD-R media as input ensures that these flaws will be faithfully reproduced in CD-ROM. However, some manufacturers still do not use the CD-R disc you send in as direct input to the LBR that creates the glass master. Instead, they transfer the data from your CD-R to tape, which is then used as input. Most plants do a bit-for-bit verification to ensure that what you send in is what you get out.
Make sure that the data on the CD-R disc you send to the plant as input is exactly the way you want it. Use a "virgin" PC, in the minimum configuration required for your application, and a low-end CD-ROM drive, to test the installation and features one last time. Unfortunately, all low end drives are not created equal - what works on one may not work on another. This is all the more reason that your discs should be manufactured well within all specs - to allow for factors that are beyond your control, such as your end-user's equipment.
Use a program such as Disc Detective to check the integrity of the CD-R disc that you plan to send in as input. Even if the disc plays without any noticeable errors, Disc Detective can, in some cases, find flaws in the CD-R media that could be reproduced in the mass-produced discs.
Finding a Manufacturing Partner
The electrical, mechanical, and chemical processes involved in manufacturing compact discs are incredibly complex, and methods used to test the resulting discs are equally complex.
For example, a CD pit is one of the smallest manufactured formations, about the size of a smoke particle. You can't even see them without using a scanning electron microscope. And yet, minute distortions in the dimensions of the pits -- their depth, form, and length -- can make the difference between a good disc and a marginal one. Defective pits can be the result of contamination, vibration, chemical properties of materials in the mastering and galvanizing process, ambient temperature, humidity, injection pressure, temperature of the molten polycarbonate, temperature of the mold, chemical properties of the polycarbonate, uneven cooling, shrinkage, and so on. And that's just the pits (pun intended). Moving on to tracks, there's track pitch, eccentricity, beginning and end of data area, and so on. Then there's reflectivity, optical properties, flatness (skew), and overall disc dimensions including weight, thickness, and clamping area.
In a production facility, finished discs are inspected for continuous and random defects such as birefringence, high-frequency signal, frame error rate, crosstalk, jitter, noise, presence of foreign particles, reflectivity, frame tracking, number of interpolations, and skew. The results of the tests can then be interpreted and used to fine- tune the myriad factors in every step of disc production. Unfortunately, it's not as simple as looking at the results of the ECC test (see sidebar) and then mounting the stamper just a teensy bit to the right - there many factors that could result in off-center tracks. A misplaced stamper could also produce a disc that compensates for errors found in the stamper itself.
Obviously, you shouldn't have to know or think about all of the things that can go wrong when your discs are being manufactured. That's the manufacturer's responsibility. Unfortunately, there is no agency or study currently available that monitors the quality of product each plant manufactures. Philips, the licenser of the standards and the specifications that are used to measure the quality of the discs in various formats, does not subject their licensees to any kind of testing to ensure that they are complying with the standards. However, there are still some things you can do to make sure you get high-quality discs.
Ask your mastering and replication facility about their test equipment and their testing procedures. It's not enough that they own all of the latest and most expensive test equipment; they should also be able to tell you how they use it in a specific Quality Control program. Can they show you a Quality Control Procedures Manual? Do they test one disc from the beginning, middle, and end of each run? Do they pull a sample disc from every line once an hour for testing? More important, do they simply test the discs to see if they are "good enough", or do they track the results of these tests as an ongoing attempt to locate trends and correct them before a serious problem arises? Are they ISO 9000 compliant, are they at least working on it, or have they never heard of it?
Does your disc manufacturer have separate, and more stringent, QA procedures for CD-ROM? Do they have a computer available that is capable of playing your disc? If you receive a bad disc or shipment of discs, will your replicator test them for you at no charge and take steps to correct the problem, as well as replace your discs? Although your sales representative may not be able to answer these questions immediately, he or she should certainly be able to find the answers for you, or put you in touch with someone who can. In any case, your salesperson should take your concerns about quality seriously.
No CD-ROM manufacturer makes perfect discs, just as no automobile manufacturer makes perfect cars. Some manufacturers, however, consistently do a much better job than others. While many CD-ROM publishers insist that their priorities for choosing a replicator are quality, service, and price, in that order, the typical CD-ROM publisher will devote hours of time and effort to find the lowest price, fastest turn time, and friendliest and most helpful customer support, but will worry about quality only when their current manufacturer screws up - and when it's already far too late.
The following parameters are more stringent for CD-ROM than they are for CD Audio:
BERL:
Burst Error Length should be less than 5 for CD-ROM. Shows physical damage such as scratches, dirt, etc. Indicates presence of a physical defect large enough to affect more than one block of data.
BLER:
Block Error Rate should be no more than 50 errors per second for CD-ROM. Measures the number of blocks of data that have at least one occurrence of erroneous data; i.e., rate of errors per second.
ECC:
Eccentricity should be *50* for CD-ROM. Measures the difference between the geometric center of the tracks and the center of the center hole. If this figure is higher than *50*, random access time increases.
MID:
Maximum Information Diameter should be less than 113mm for CD-ROM. Technically, MID signals the end of the disc.
SYM:
Symmetry should be 10% deviation for CD-ROMs.
(Standard Deviations column, CD-ROM Professional magazine, November/December 1994. Contributed by author. May be reproduced with attribution given.)
Dana J. Parker is Standards Columnist and Contributing Editor for CD-ROM Professional magazine, and the co-author of New Riders' Guide to CD-ROM, Second Edition, New Riders Publishing, CD-ROM Fundamentals, Boyd & Fraser, and CD-ROM Professional's CD-Recordable Handbook, Pemberton Press. Communications to the author may be addressed to CIS 102212,472.
2004. november 4., csütörtök
How to save components to a file or stream (2)
Problem/Question/Abstract:
I would like to stream selected components (say a panel with some other components on it) to a DFM like (text preferred over binary) file and be able to load it and restore them programatically.
Answer:
You need to save this component with root (where its handlers are declared), f.e., with TFormX:
{ ... }
type
TForm1 = class(TForm)
MyComponent: TMyComponent;
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
private
{ Private declarations }
public
constructor Create(AOwner: TComponent); override;
function FormFileName: string;
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function TForm1.FormFilename: string;
begin
Result := ExtractFilePath(ParamStr(0)) + Classname + '.DAT';
end;
constructor TForm1.Create(AOwner: TComponent);
var
fname: string;
begin
RegisterClass(TMyComponent); {And anything else that is required }
fname := FormFilename;
if FileExists(fname) then
begin
CreateNew(AOwner);
ReadComponentResFile(fname, Self);
end
else
inherited Create(AOwner);
end;
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
WriteComponentResFile(FormFileName, Self);
UnregisterClass(TMyComponent);
end;
2004. november 3., szerda
How to trap and process Windows messages before the applications' window procedure is executed
Problem/Question/Abstract:
How to trap and process Windows messages before the applications' window procedure is executed
Answer:
The following project source demonstrates how to get Window messages before the application's window procedure is called. It is rare, if ever, that this needs to be done. In most cases assigning a procedure to the Application.OnMessage will accomplish the same thing.
program Project1;
uses
Forms, messages, wintypes, winprocs, Unit1 in 'UNIT1.PAS' {Form1};
{$R *.RES}
var
OldWndProc: TFarProc;
function NewWndProc(hWndAppl: HWnd; Msg, wParam: Word; lParam: Longint): Longint; export;
begin
result := 0; { Default WndProc return value }
{Handle messages here; The message number is in Msg}
result := CallWindowProc(OldWndProc, hWndAppl, Msg, wParam, lParam);
end;
begin
Application.CreateForm(TForm1, Form1);
OldWndProc := TFarProc(GetWindowLong(Application.Handle, GWL_WNDPROC));
SetWindowLong(Application.Handle, GWL_WNDPROC, longint(@NewWndProc));
Application.Run;
end.
2004. november 2., kedd
How to programmatically change the column positions in a TDBGrid at runtime
Problem/Question/Abstract:
When a user selects some items (Field Names) from a TListBox, I need a TDBGrid to rearrange those columns so that they are shown first, i.e. the left hand side of the grid. You can do this at runtime by dragging the columns where you want them and then saving that grid configuration in a file to be reopened next time. I need to do it as soon as the user selects say 'Jan,Feb,Mar'... These fields are normally in the middle of the grid. I've looked at a lot of the properties of the grid and columns but can't figure it out.
Answer:
Solve 1:
type
TGridAccess = class(TCustomGrid);
{ Is needed because TCustomGrid.MoveColumn is protected. Declare it in the
imlementation section of the unit. }
procedure TForm1.Button1Click(Sender: TObject);
var
sField: string;
i: integer;
begin
sField := listbox1.Items[listbox1.itemindex];
with TGridAccess(DBGrid1) do
begin
for i := FixedCols to Columns.Count - 1 do
if Columns[i].Title.Caption = sField then
MoveColumn(Columns[i].Index + FixedCols, FixedCols);
end;
end;
Solve 2:
When you change indexes on a table, you might want to pull the column that the table is sorted by to the 1st column position. Here's how to move a column to the 1st column position in a normal TDBGrid:
procedure TForm1.MoveColumnToFront(fieldName: string);
var
tempColumn: TColumn;
columnFound: Bool;
counter: Integer;
begin
columnFound := false;
{find the field's index number}
for counter := 0 to (dbGridView.Columns.Count - 1) do
begin
tempColumn := dbGridView.Columns[counter];
if tempColumn.FieldName = fieldName then
begin
columnFound := true;
break;
end;
end;
if columnFound then
tempColumn.Index := 0;
end;
2004. november 1., hétfő
How to invoke the Find dialog in a TWebBrowser
Problem/Question/Abstract:
How do I invoke the Find, Option or View Source options?
Answer:
Here's a code sample for invoking the Find dialog:
{ ... }
const
HTMLID_FIND = 1;
HTMLID_VIEWSOURCE = 2;
HTMLID_OPTIONS = 3;
{ ... }
procedure TForm1.FindIE;
const
CGID_WebBrowser: TGUID = '{ED016940-BD5B-11cf-BA4E-00C04FD70816}';
var
CmdTarget: IOleCommandTarget;
vaIn, vaOut: OleVariant;
PtrGUID: PGUID;
begin
New(PtrGUID);
PtrGUID^ := CGID_WebBrowser;
if WebBrowser1.Document <> nil then
try
WebBrowser1.Document.QueryInterface(IOleCommandTarget, CmdTarget);
if CmdTarget <> nil then
try
CmdTarget.Exec(PtrGUID, HTMLID_FIND, 0, vaIn, vaOut);
finally
CmdTarget._Release;
end;
except
{Nothing}
end;
Dispose(PtrGUID);
end;
Feliratkozás:
Bejegyzések (Atom)