Tuesday, April 17, 2012

Freeing Delphi Dynamic Arrays

This post is about freeing dynamic arrays in, Delphi.

In, Delphi, as in others, dynamic arrays useful in many instances. Here is a good link on a basic understanding
http://delphi.about.com/od/beginners/a/arrays.htm This is not what this post is about.

Let's declare a dynamic array and we will use the same variables as the link above so to make it easier to understand


var
  Students : array of string; 
  nCounter: integer;
begin
  // set the length to something
  SetLength(Students,5); // this will hold six students
  // loop through and load the array with some data
  for nCounter := Low(Students) to High(Students) do
  begin
    Students[nCounter] := 'My student #: ' + inttostr(nCounter);
  end;

  // do something
  // way one to free array
  Students := nil;
  // way two to free array
  SetLength(Students,0);
  // way three to free array
  Finalize(Students);
end;


There you go!

Wednesday, April 4, 2012

Enter ASCII Characters

Several ways to accomplish entering ® or © into text. In Word® you can select it from the fonts. You can also use the Character Map in Windows and find your character and hit copy.

The cool way is to hold down the ALT key and then, using the keypad, type the appropriate ASCII number. For example:
® = ALT + 0174
© = ALT + 0169

You can use this for any of the ASCII characters.

Happy typing.