Travelers bug - I’m in China!
I’ve decided to embark on my first international travel adventure. I am currently sitting in a nice little office in my girlfriends apartment in Lanxi, Zhejiang province, China. She has been here since April of 2006 teaching English at the Number 1 Middle School in Lanxi and I’ve decided to visit and get a taste for all things China. So far it’s been an amazing experience and I’ve seen, tasted, and done some amazing things! I will be working from here until the beginning of October and then I will return to the states.
So far I’ve mostly been fascinated by the new foods and, well, traffic! The driving here is very different from the states! If it’s flat (or even not!) it is driven on. Crossing the street is like playing Frogger. Watch out for that car, truck or bicycle!
Just thought I’d drop a note and keep you all up to date as to my whereabouts! Feel free to drop me a line if you’re in the area and want to say hi!
-A
Share This | Email this page to a friend
Posted by Adam Markowitz archive on September 4th, 2006 under Uncategorized | 7 Comments »Graduation
So, after 5 years of mostly full time school and work, I’ve finally graduated with my B.S. in Computer Science from the University of California at Santa Cruz (UCSC). There were good classes, bad classes, and classes that inspired. Interestingly enough, the key factor of a great class wasn’t necessarily the content (which could be very interesting), but rather the instructor and their enthusiasm for the subject they were teaching. I’d never realized how much the instructor made a difference. I’d have to say that my favorite class was taught by Jerry Talton and focused on graphics programming ala OpenGL. His enthusiasm and teaching style were great! It was also quite interesting to see the differences between academia and industry. I was occasionally taken aback at what was, and what wasn’t, taught in the undergraduate studies.
My mind is still boggled from juggling work, school, and the rest of life so please forgive the hap-hazzard wordiness.
Woo-hoo!
-Me
Share This | Email this page to a friend
Posted by Adam Markowitz archive on June 27th, 2006 under Uncategorized | 16 Comments »How to do late binding to dll exports (Delphi2006)
Applications can be deployed on a multitude of systems, some of which may have functionality installed that does not exist on others. In the case of the Windows operating system, new API functions generally appear for each new version and it can be quite nice to take advantage of the functionality without statically binding to a dll or export that may or may not be there.
As an example, we’ll look at how one might do late, or lazy, binding to the GradientFill() function that is exported from msimg32.dll.
We’ll use a function pointer that is typed with the correct parameters for the user to call. We will also use 3 implementations of this function pointer for our purposes, 2 that we write and one that we import. The first implementation is the part that tries to locate and bind the function to its actual implementation in msimg32.dll; the second implementation is a small stub that is used if the real implementation in msimg32.dll can’t be found; and the third implementation is the actual msimg32.dll code.
The flow goes something like this:
- Initialize the function pointer to the lazy load stub.
- When the function is first called attempt to load the real one from the library it is exported from.
- If it is found, revector the function pointer to the one loaded from the library, otherwise set the function pointer to the nop stub (this does nothing).
unit LateBind; |
Example code here: http://cc.borland.com/item.aspx?id=23928
Share This | Email this page to a friend
Posted by Adam Markowitz archive on February 17th, 2006 under Uncategorized | 15 Comments »Sojourn of Delphi
I’ve been here a while (going on 10 years now) and can remember a number of times when romanticism about such events occurring could be heard in the halls or seen in the twinkling of any eye. Now that the time is nigh, I can’t say I’m surprised as it seems a very reasonable thing to do. The current executive management team at Borland (Todd Nielsen, Rick Jackson, etc) have been amazingly up front and open about the business (more so than past executive teams), what is necessary to focus on, and how they can achieve success. To achieve success in ALM/SDO requires focus on ALM/SDO. To achieve success in the Developer Tools market requires focus on Developer Tools. I, for one, am excited about this new sojourn and sincerely hope that focus, opportunity, and success is achieved for both companies.
Oh yeah. There should probably be some opinion stuffed in here somewhere, huh? I like it. Let’s do it.
w00t!
-Adam
Share This | Email this page to a friend
Posted by Adam Markowitz archive on February 8th, 2006 under Uncategorized | Comment now »Live Template Script Examples - var declaration with initialization and clipboard contents (Delphi2006)
In the shipping version of Delphi2006 you can type the word ‘var’ in the code editor and hit TAB. This allows the user to fill out a template for a variable declaration. This variable then gets declared in the containing methods var block without having to navigate all over the place. I find this very convenient and so do a number of others. However, there have been some requests for a modification to this template that allows the user to not only declare the variable, but initialize it with a default value as well. I have uploaded this new template and an example of a code template script engine that implements some of this functionality here: http://codecentral.borland.com/item.aspx?id=23910
The use of this new template is as follows:
type “var“
then hit the TAB key.
You will get something that looks like this:
LVar: Integer := 3;
Fill out the variable name, type, and initialization value. Hit ENTER or tab off the last template point and it will be changed to:
LVar := 3;|
(or whatever you named it and initialized it to).
Additonally, there is a template called ‘clippy’ that allows a user to get the clipboard contents into a template point. This example wraps the clipboard contents with a try…finally block. So if you copy/cut some code to the clipboard and then type:
clippy
your clipboard contents should be wrapped in a try finally block.
Notes: You’ll need to download the code from http://codecentral.borland.com/item.aspx?id=23910, unzip it, build it, install it as a design time package in the IDE, and copy the live templates (.xml files) into the code_templates directory (either the Local Settings one or the one under the objRepos directory).
Let me know if there are any other nifty template ideas and I’ll see what I can do.
’til next time!
Share This | Email this page to a friend
Posted by Adam Markowitz archive on January 20th, 2006 under Uncategorized | 25 Comments »Importing VS 2005 Code Snippets (Delphi2006)
Not only am I having writers block for this blog, but the entry I just wrote got wiped out. grrr. :P You shall now get the very short version.
Summary:
Importing/using Visual Studio 2005 Code Snippets in BDS 2006
Steps:
- Download source from code central: http://codecentral.borland.com/item.aspx?id=23903
- unzip
- build
- install in the IDE (Components | Install)
- download VS 2005 templates: http://www.gotcodesnippets.com/
- install template (copy .snippet file to the code_templates directory either under your local settings or under the ObjRepos directory)
- Oooo and Aaaaaahh
Example:
- Goto http://www.gotcodesnippets.com/1024.snippet and download the snippet.
- Unpackage it and install it in the IDE (#6 above)
-
open a C# app, type “email“ sans quotes and press tab.
Note: VS templates are occasionally packages into .vsi files. These are merely .zip files with a different extension so you can rename them to .zip and extract the .snippet file manually.
Share This | Email this page to a friend
Posted by Adam Markowitz archive on January 18th, 2006 under Uncategorized | 4 Comments »Displaying macros in Code Completion (C++Builder2006)
If you’ve ever used C or C++ you know about macros and their [ab]uses. Macros can be used in a number of ways, one of which is to substitute a string of text for a single identifier as in:
#define MAX_TYPEVECSIZE (sizeof(typeVec[0]) * vecLength)
you may also declare them as a parameterized macro (looks like a function call) as in:#define isVisible(t) (((t)->flags & VIS_MASK) >= VIS_PUBLIC)
Note that both of these macros are indistinguishable from regular symbols (lexical identifiers) in source code. Doesn’t code completion show you what identifiers are available in a specific context? Why yes, it does. So why doesn’t it also show the macros that are available? In fact, the ability for Code Completion to show macros has been there since BCB6 (this same trick, in the root Code Insight key, should work in that IDE as well), but it has been turned off by default for two reasons:
- There was concern that it would be seen as extra noise in the Code Completion list (I disagree with this one).
- It increases the size of the Code Completion list (and depending on which headers you’re including there could be thousands of extra macros) thus it increases the amount of time taken to show the list since the sort routine has quite a few more items to sort.
To turn it on change the value of the following registry string value to True:
xxxBDS4.0Code InsightBorland.EditOptions.CShow Macros = True
/* If there is a blank spot here, scroll down to see the rest of the blog */
Restarting the IDE should not be necessary.
You should now be able to see macros in the Code Completion list.
Share This | Email this page to a friend
Posted by Adam Markowitz archive on December 19th, 2005 under Uncategorized | 4 Comments »Convenient editor shortcuts (Delphi2006)
Every once in a while I’ll come across a message from a developer who wasn’t aware of a particular feature or keyboard shortcut that might ease some of their development pain. Following is a short list of convenient editor keyboard shortcuts for the default keybinding that is shipped with Delphi 2006. This not an exhaustive list, just the ones that I find are lesser known, yet still very convenient.
CTRL+J : Invoke code templates
CTRL+T : Delete current word
CTRL+E : Incremental search
CTRL+Y : Delete current line
CTRL+SHIFT+G : Insert a new GUID at the cursor position
CTRL+SHIFT+I : Indent the current selected block
CTRL+SHIFT+U : outdent the current selected block
CTRL+SHIFT+Y : delete to the end of line
CTRL+SHIFT+J : Invoke syncedit
ALT+[ : match pair forward
ALT+] : match pair backward
ALT+RightArrow : browse forward (hotlink history)
ALT+LeftArrow : browse backward (hotlink history)
ALT+UpArrow : browse to symbol under editor cursor (invoke a hotlink and add it to the hotlink history)
F4 : Run program to current cursor position
F5 : Toggle breakpoint
F7 : Debugger step into
F8 : Debugger step over
F9 : Run program under debugger
CTRL+F12 : View units
ALT+G : Goto line number in editor
CTRL+SHIFT+R : Start/Stop recording editor macro
CTRL+SHIFT+P : Play editor macro
CTRL+SPACE : Invoke code completion
CTRL+SHIFT+SPACE : Invoke code parameter hints
CTRL+ENTER : Open file at cursor
CTRL+SHIFT+C : Invoke class completion for the class that currently contains the cursor
CTRL+SHIFT+UpArrow : Navigate to method implementation/declaration
CTRL+SHIFT+DownArrow : Navigate to method implementation/declaration
CTRL+ALT+UpArrow : Navigate to previous method implementation in lexical order
CTRL+ALT+DownArrow : Navigate to next method implementation in lexical order
CTRL+ALT+Home : Navigate to the lexically first method implementation in this source unit
CTRL+ALT+End : Navigate to the lexically last method implementation in this source unit
CTRL+/ : Toggle comment per line or selected block
Let me know if anyone wants a list of equivalents in a different keybinding that we provide.
May the editor shortcuts be with you and your coding be swift.
Share This | Email this page to a friend
Posted by Adam Markowitz archive on December 15th, 2005 under Uncategorized | 18 Comments »Hidden feature, anyone?! (Delphi2006)
Soooooooo… Whilst I was hacking apa^H^H^H^H^H^H^H^H modifying the sync edit code to get it ready for live templates I was wondering in what other ways this functionality could be used to ‘make things better.’ I asked around and ended up with Steve Trefethen and Allen Bauer in my office (if memory serves me correctly) and we came up with something that’s pretty sweet. We have it turned on internally and it rocks. Oh yes. Unfortunately this was after requirements for the product were already accepted, this feature not being one of them so you don’t get to see it. No no. Please… Ooooooooooooooooooohhhhhhhhhh…..
Ok.
I guess you can check it out, but sshhhhh!! It’s a secret! *wink*
It’s currently called sync edit params, but that’s just a place holder. Since this is an unfinished prototype of the feature the work was only done for the Delphi personalities and there has been no QA of the feature except for those of us that have turned it on so use it at your own risk.
What does it do? Glad you asked. You know when you invoke code completion and complete a proc/func/method and end up with something like this:
Wouldn’t it be nice if it did a little more for you? Like, say, allow you to navigate between each parameter and type mundane things like commas for you? Like, say, maybe pre-seed the parameter names for you with things that might make sense (it’s not really intelligent yet, but you get the picture)?
Now what if choosing the same selection as above from code completion produced the following:
Way cool…
How to turn it on:
go to your HKCUSoftwareBorlandBDS4.0Code Insight registry key (or whatever the path is in the delivered build) and add a new string value to it:
Sync Edit Params
with a value of 1

Please feel free to give feedback on this. Do you like this feature? Does it get in the way? Suggestions? Currently the main issue with it that I’ve seen is that both the Code Parameter hints and the Sync Edit hints can be active at the same time which can look a bit cluttered…
Notes:
- To see the other argument names/data types use the TAB and SHIFT+TAB navigation keys to jump to the next input area. When a new input area is selected the hint is updated for the currently selected formal argument.
- This is only invoked when picking a method name from the Code Insight drop down list (CTRL+SPACE, or .) and not as a replacement for CTRL+SHIFT+SPACE.
Share This | Email this page to a friend
Posted by Adam Markowitz archive on December 9th, 2005 under Uncategorized | 25 Comments »Creating Live Templates - Basics (Delphi2006)
In this blog we’ll step through creating a simple template to make a more type safe descendant of TBucketList. This will go over the basics of code template creation which are:
- Naming the template and specifying the target language.
- Adding jump points for navigation and renaming synchronization.
- Adding jump point default text and hints.
- File | New | Other | Other Files | Code Template
- View | Templates
- Click the "New" button in the template dialog.
<template name="" invoke="manual"> |
Let’s use the name "NewBucketList" as the name of the template. The template line should now look as follows:
<template name="NewBucketList" invoke="manual"> |
Next we’ll fill out the description and author of this code template as follows:
<description> |
Feel free to use a different author name. I like my name so I’m gonna use it for this example
Next we’ll put in the code we want and tell the template which language we’re targetting. This code was mostly lifted from Contnrs.pas. Note that it goes in the CDATA section of the code template.
|
|
At this point our file should look like the following:
|
|
This is all fine and good, but what if we want to make a TBucketList descendant for TWinControl? Do we create a completely new template? The answer is ‘no’. We add what I call ‘jump points’ to this template to allow users to easily change the names of multiple identifiers at the same time.
Jump points need to be declared in the template so the template engine knows which points get what default text, etc.
For this example, we’ll want two points, one for the class name and one for the name of the type that we’re making the descendant for.
The "text" node contained within the point declaration defines what the default text is for that point.
"hint" is the pop up hint that is displayed when a user navigates to that point while the template is being invoked.
The point declarations below creat the two points we want, give them names, default text, and hint values.
<point name="classname"> |
These declarations should be contained in the tag.
Now, all we need to do is replace TControlBucketList with |classname| and TControl with |typename| in the code to change the template so that it uses jump points instead of hard coded names. Following is the complete template.
|
|
Note that default delimiter for jump points is the $ character and that I’ve changed the delimiter for the Delphi template to be the | character in the following line:
<code language="Delphi" delimiter="|">
The reason for this is that $ is a valid character for Delphi code:
Foo := $3F;
and we don’t want the engine to get confused by this if we were to use it in a template.
Other things of note:
the attribute invoke is used to tell the template engine how this template is invoked.
The following values can be used:
- auto - invoked by pressing SPACE or TAB
- manual - invoked by pressing TAB
- none - invoked by using CTRL+J, CTRL+SPACE, or using the template viewer
Notes:
- TBucketList is declared in Contnrs.pas so be sure that Contnrs is in your uses clause.
- There are a number of languages that are supported by code templates and can be specified as the value of the language attribute in the <code> tag. Currently they are:
- CSharp
- VB
- Jsharp
- HTML
- XML
- Delphi
- C
- SQL
- IDL
- JavaScript
- CSS
- INI
- PHP
Hopefully this covers some of the basics and answer some questions.
Share This | Email this page to a friend
Posted by Adam Markowitz archive on December 5th, 2005 under Uncategorized | 23 Comments »Server Response from: dnrh1.codegear.com
