Use the Source!

One of the great things about Delphi is not only is it written in Delphi (mostly), but it ships with the VCL, RTL, & FMX source code. You can use this source code in lots of different ways, which I’ll cover in a bit, but sometimes it is a matter of finding the source file with the code you want. There are over 2,234 Delphi source files in the source folder, so it can take a while to find the right file if you don’t know where to look. Not to mention the 1,711 C files, and a few thousand other assorted files.

Source Folder Files

I used to use various GREP and full text searching tools to find the code I was looking for, but then I realized Windows 10 (and earlier versions) has a search function built into it, but you need to make a few configuration changes to use it effectively. So I thought I would outline those for you.

Your source folder is usually located in
C:\Program Files (x86)\Embarcadero\Studio\19.0
but it might be different depending on your installation. I usually Pin it to Quick Access, which makes it easy to access since I find I’m there a lot.

Source Folder

Windows Search and Indexing Options

The next thing to do is configure your Indexing Options. This is what makes it quick to search for files you need. You can find Indexing Options in Control Panel, or just runcontrol.exe srchadmin.dll.

control.exe srchadmin.dll

There are two steps to get the most out of Windows search for your source code. The first is you need to activate Windows search for the file extensions you want, and the second it to tell it to index your folders.

Indexing Options

To add PAS files to indexing click Advanced and go to File Types. You can just type PAS in the list of file types and it will find it for you. You don’t need to add a new extension. PAS files are already listed, but just not indexed by default. Just put a check next to it, and change the “How should this file be indexed?” to “Index Properties and File Contents” that will index all the text contents of the file

Indexing File Types

By default all your user folders are indexed, but Source is in your Program Files folder, so you need to explicitly add it. From the main Indexing Options window click Modify and from there you can add any folder you want to search.

Indexed Locations - Source

It takes a while a while to build and update the index after this change. You just gave it 2,000 more files to index. It has to read all the text out of them, which takes a while. Once it is done then just go to your source folder and use the search box to quickly find the code you are looking for.

Search Results

Everything Search

Everything Software IconAnother great tool to use, to search by file name is the Everything desktop search engine by Voidtools. The thing I love about using Everything is it searches all the file names on your system quickly. The difference between it and Windows Search is Everything only searches the file names, but it searches all the file names.

Everything Search

I find I usually remember the name of a file, but not exactly where I left it. This makes Everything indispensable for me.

Using the Source

So how useful is it that Delphi, RAD Studio and C++Builder includes all this source code? What all can you do with it?

  • Finding that function – You know how I said I can remember the name of a file, but not where I put it? I do the same things with classes and functions. I can remember the name of the method or class, but not which unit it is in. Being able to search all of the source instantaneously to find the source file you need is a huge help.
  • Learning – Just reading source isn’t the best way to learn to program, but having access to the source code is a great way to gain a deeper understanding.
  • Debugging – Sometimes your program doesn’t behave the way you expect it to. When all you have is a blackbox then you are unable to figure out what is happening behind the scenes. When you have the source code you can not only see how that method is implemented, but also debug into the source code, using all the great debugger features.
  • Adding New Features – Maybe there is a new API that was just released, or you need to access an obscure API or 3rd party feature. Since you have access to all the source you can see how other similar APIs are accessed and use that as a roadmap.
  • Fixing or Changing Functionality – One man’s bug is another man’s feature. Sometimes there are bugs you need to fix in the shipping source code, other times you just want to change the way things work. For small changes I just copy the source file out into my project directory. Then my code will use my modifications instead of the original implementation. While you can’t redistribute changed source code, you can compile the code into your program. If you do need to share your changes or fixes you can share a change-set that only contains your changes.

What else do you use the source for?

Posted in Source Code, Tools | Tagged , | 2 Comments

3D Credits Scroll with Delphi

A little fun with Delphi for today’s Star Wars day!

3D Credits Scroll with Delphi - May The Fourth

This is a pretty simple 3D form with a 3D layout at an angle, and then a 2D layout with text and images is animated up the 3D layout. The only code is populating the labels as the animation kicks off automatically.

3D Scroll - MayTheFourth-StructureDownload the code and run the full credit scroll, or change the message to share with your friends. It is FireMonkey, and while I only tested it on Windows, it should work on Android, iOS, macOS, and even Linux if you are running FMX Linux.

CreditScroll3D Source for 10.2.3 Delphi

May the Fourth be with You!

Posted in Funny, Source Code | Tagged , , | Leave a comment

LIVE! from the Embarcadero Austin Office

We are LIVE! from the Embarcadero Austin Office today at 1:30 PM CDT

Starting shortly. See you online!

Posted in podcast, Video podCast | Leave a comment

LIVE! with TMS Software’s Bruno Fierens, Wagner Landgraf & Holger Flick

A live conversation with TMS Software’s Bruno Fierens, Wagner Landgraf, & Holger Flick about some of the latest technology to come out of TMS Software.

[Find your local time]

Posted in podcast, Video podCast | Leave a comment

Google Cloud Shell Network Details

Marco Cantu’s blog post about Running a Delphi Linux Application on Google Cloud Shell got me wondering more about the Google Cloud Shell, specifically around the networking. First of all, is the IP address public?

jim@cloudshell:~$ hostname -I
172.18.0.1 172.17.0.2
jim@cloudshell:~$ curl icanhazip.com
35.199.148.57

So the private IP is different from the public IP. I’ll need to test to see if it is mapped with NAT or something. Seems unlikely though. Google offers public facing computers as part of their cloud services, so it makes sense that you would use those instead.

Next question is around bandwidth.

curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python -

Results in . . .

Retrieving speedtest.net configuration...
Testing from Google Cloud (35.199.148.57)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Mimosa Networks (San Jose, CA) [17.60 km]: 40.662 ms
Testing download speed........
Download: 322.69 Mbit/s
Testing upload speed........
Upload: 260.94 Mbit/s

322.69 Mbit/s down and 260.94 Mbit/s up is really impressive! So if you have a task that requires a lot of bandwidth and then condenses it down to a smaller digest, it would be a really useful platform.

Posted in Cloud | Leave a comment

LIVE! With Boian Mitov of Mitov Software

Join us Tuesday, March 20th, for a LIVE conversation with Boian Mitov of Mitov software as we talk about Arduino, Visuino, IoT, Industrial Automation, AI and more!

(We had to reschedule due to technical difficulties)

11 AM Mountain Daylight Time

 

Posted in News, podcast, Video podCast | Leave a comment

Earlier this week’s episode on Cool Apps

Earlier this week Craig and I had a conversation the Cool App winners

Enter your cool apps and vote today!

Posted in podcast, Video podCast | 1 Comment

LIVE! Episode on Delphi Games and Graphics Engines

Join Craig, David, and Jim as they discuss Delphi powered Games and Graphics engines LIVE!

Live Tuesday, February 27th, 2018 at 12 PM Central Standard Time

Posted in Video podCast | 1 Comment

LIVE! Monday at 9 AM PST – Podcast Episode on Programming Books

On Monday this week David, Craig, and Jim discuss some of their favorite programming books, both focusing on Delphi and C++ specific ones, and general programming topics.

Slides

Posted in podcast, Video podCast | Leave a comment

Collecting Multiple Pages of REST Results in a Single MemTable

I’ve run into this a few times, where a REST Service returns results in pages, so you have to make multiple passes to get all the data. One thing I love about the RAD REST Client Library is the ability to store all the data in the FDMemTable where you can work on it. Unfortunately when you can only get part of the results that limits the functionality. Here is a simple solution to get all the pages in a single FDMemTable.

What you need is a second FDMemTable. My first one is called MembersTempTable, and it is attached to the Response Adapter. The second one is called MembersMemTable and it will hold the complete set of data.

  // Drop any existing data
  MembersMemTable.Close; 
  
  // Get the first page 
  MembersRequest.Params.ParameterByName('limit').Value := '50';
  MembersRequest.Params.ParameterByName('offset').Value := '0';
  MembersRequest.Execute;

  // This clones the FDMemTable
  MembersMemTable.CopyDataSet(MembersTempTable, 
    [coStructure, coRestart, coAppend]);

  // Now we add the other tables
  MembersMemTable.BeginBatch();
  try
    // Repeat until we don't get a full page
    while MembersTempTable.RecordCount = 50 do
    begin
      // Start with the next page
      MembersRequest.Params.ParameterByName('offset').Value := 
        (MembersMemTable.RecordCount - 1).ToString;
      MembersRequest.Execute;
      // Append those records into our FDMemTable
      MembersMemTable.CopyDataSet(MembersTempTable, [coAppend]);
    end;
    MembersMemTable.IndexFieldNames := 'id';
  finally
    MembersMemTable.EndBatch;
  end;
Posted in REST | Leave a comment