Monday, July 29, 2019

Stop saying "I don't have time" - Say "It's not a priority"

That little switch from saying "I don't have time", to saying "It's not a priority" is a HUGE game changer. I learned about this from a co-worker last week. She didn't invent it... she heard it and passed it on to me. So, I'm passing it on to you.

I started using it immediately. It's my new mantra. I've mostly said it quietly only too myself so far. An I can attest, it's already made a big difference in my life. I thought about making the title of the post click-bait. For example:

Stop saying "I don't have time", say this instead...


Making people click into the site to get the punchline. But that's not what this is about. This is about leveraging the smallest of things, and turning it into the biggest of life changers. As my good friend Bob Wight, would say, "Riley, that's what you call a woomera". A small little device that when used, gains a tremendous advantage over not using it. (R.I.P. Bob, I miss you a lot).

One of my favorite songs is "We will never pass this way again" by Seals and Crofts. It speaks to me in so many ways. And it's true! So while we go through life, why not pick up a little nugget every now, from wherever we find it, and pass it on to the rest of the world. You never know the significance one small little thought will have on someone.

Enjoy the rest of your day and tackle those priorities!

Semper Fi,
Gunny Mike
zilchworks.com

Sunday, July 28, 2019

Delphi Tip of the Day - TODO or not TODO

I tend to be a scatter-brain when it comes to Delphi.

Really? Tend to be? "No Gunny. You are a scatter-brain when it comes to Delphi." I can hear all of you who know me saying this. That's fine.. I fully embrace it. I am a scatter-brain, especially when it comes to everything Delphi. There is so much I want to learn and do.

I have been trying to update my very old, flagship product Zilch Standard for 8 years. I've made zero progress. Why? Two reasons:
  1. I am a scatter-brain.
  2. I was of the mindset I needed to start from scratch and completely redesign everything.

When I was a teenager,
I would go to the ...


When I was a teenager, I would go to the library with a specific idea of what I wanted to read about. I'd head straight to those bookshelves and start eyeballing titles. "Nope." "Nope." "Uh Uh." 'Nah." 'Oh, that looks interesting." "Hey that reminds me of  X."  "Where is the 'X' section." Off I'd go to the "X" section,  and repeat this process until I found something all consuming.

This happens to me all the time with Delphi. My thirst for learning overtakes me and I lose focus on actually making progress inside the IDE. 

How about the other issue, having the mindset of completely redesigning everything from scratch? Well that was squelched when my hard drive crashed and I lost over three-and-a-half years of code. Gone! Poof! It actually turned out to be a blessing. It has forced me to look at things with a whole different perspective. 

That brings me to today's Delphi Tip of the Day.

As I was going through and porting over my old Delphi 5 code, I started doing that "scatter-brain" thing again. I first noticed it when I was updating the Main Menu functionality. "Hey, you know what would be cool, an MRU (Most Recently Used) file list." "Yeah lets add that". And off I went on a quest to learn how to build an MRU list.

Two hours later when I went to make another Nespresso (yeah I'm a coffee snob), it hit me. "Hey Gunny, an MRU list is not the objective. Put it on the back burner."

My back burner items tend to get lost and disappear.


My back burner items tend to get lost and disappear. Then I get frustrated because I can't remember all those "To Do" items I have on the back burner. "Hey wait a minute. Doesn't Delphi have a 'To Do' list function built in? 

Yes, Delphi does indeed have TODO functionality and I started using it the other day. However, in traditional Gunny Fashion it's not your normal TODO.
"If we are going to get wet up to our knees, we might as well get wet up to our waist and get the job done right."
I often use that phrase at my day job. Especially when there are two or three of us gathered around working on an immediate issue. It's different when it's an urgent need that must get done before you go home. 

So when I get ankle deep on a "new" feature I'd like to add, that is not a priority, I add it to my TODO list in Delphi. However, I also include the links to the website articles that will be useful when the time comes to implement them later. For example here is my current TODO list:


If you drill down into the highlighted "TODO" item it brings up the source code:

var
  HWnd: THandle;
  MR_Result : Word;

begin
  {---------------------------------------------------------------}
  { Use this code for retail version                              }
  {---------------------------------------------------------------}
  Hwnd := FindWindow('TMainForm','Zilch Standard - Main Screen');
  {---------------------------------------------------------------}
  { Use this code for trial version                               }
  {---------------------------------------------------------------}
  //Hwnd := FindWindow('TMainForm','Zilch Standard (Evaluation Copy) - Main Screen');

  {---------------------------------------------------------------}
  { TODO 3 -oMJR -cPhase 2 : Set Focus to running application     }
  {---------------------------------------------------------------}
  // Refer to these links when for implementing this TODO item
  // https://codeoncode.blogspot.com/2016/12/get-processid-by-programname-include.html
  // https://stackoverflow.com/questions/47598473/how-can-i-call-getwindowthreadprocessid-in-delphi-10-2
  {---------------------------------------------------------------}
   If Hwnd <> 0 then SetForeGroundWindow(GetForeGroundWindow())
  else
  begin
    Application.Title := 'Zilch';
    Application.CreateForm(TMainForm, MainForm);
    Application.CreateForm(TNoPrintDlg, NoPrintDlg);
    Application.CreateForm(TCreditorInfo, CreditorInfo);
    Application.CreateForm(TDisclaim_Save, Disclaim_Save);
    {---------------------------------------------------------------}
    { Use this code for US Marine Corps distribution                }
    {---------------------------------------------------------------}
    {
    MR_Result := USMC_End_User_License.ShowModal;
    If MR_Result = idYes then
    begin
      Application.ProcessMessages;
      Application.Run;
    end;
    }
    {---------------------------------------------------------------}
    { Use this code for genral public distribution                  }
    {---------------------------------------------------------------}
    Application.ProcessMessages;
    Application.Run;
  end;
end.

This way I can do a little "ankle deep" research and keep it preserved on the back burner for latter use without the risk of loosing it. It allows me to scratch the itch at the time it itches and lets me go knee deep later on when the time comes to dive in.

Going forward I will make extensive use of the TODO feature in Delphi. I hope this has helped you better understand TODO's and how they can help you scratch the itch when it itches.

It's time to publish this and get back to work!

Enjoy,
Gunny Mike
https://zilchworks.com

Saturday, July 27, 2019

Delphi Makes Updating Old Code Very Easy (Hidden Gem)

When my computer hard drive crashed in October 2018 I was really upset. The hard drive was completely shot and unrecoverable. I lost all of the code I had been working on... ARRRGH! The last backup I had was taken in March 2015. Yup, 3 1/2 years of Delphi, Evelated DB, and SQL code GONE!

Intellectually, I accepted this had happened and purchased Carbonite within a few days of getting my computer back this time with a solid state drive. However, I had not emotionally accepted I lost all that work. Well, last weekend I completely came to grips with the situation. Had a good cry. Decided to pickup what I could and start anew updating my old software.

The last time I compiled this project was 2008. So, I opened my Delphi 2005 project with Delphi 10.3 and clicked "Run" and held my breath.

It looked like crap. The default font is the old "System" font. The background colors didn't register properly. I couldn't see some of the stuff because the font color and background color was the same. This was broken. That didn't look right. Then the big "Ah Ha!" moment came...

Hey wait a minute... I just got a clean compile on code written with Delphi 2005 that is hasn't been touched since 2008 . That's amazing!


I'm slowly working my way through enhancing the look and feel. I'll be adding new functionality as well. It's amazing how a few minor changes takes thing to a whole new level.

Before: 2008 (Delphi 5)

After: 2019 (Delphi Rio)

So now I'm updating this code so I looks modern. In the process I will be replacing old functions with better, faster, more readable functions. Not all of them, just those using dumb code. I started swapping out function names in small little pieces. Repeating the Save, Run, Test, Close, Next Change. Save, Run, Test, Close, Next Change for every function I replaced.

Work Smarter Not Harder!


I wanted to see if I had replaced all the old occurrences of one function with the new function.

By pure dumb luck I right-clicked on a function name and found "Search For Usages...". Whoa. This is a great tool. And I'm going to show you how to use it.

Step 1: Click on a function in any unit.

Step 2: Right-Click on the function name and choose Search For Usages

Step 3: Click Search

Step 4: Expand the results



Step 5: Double-Clicking takes you to the source code

Step 6: Repeat the search making sure there are no more changes needed

Step 7: Clean up when done

I am so grateful I found this nice little utility. I just had to stop making code changes and share it with you guys.

Enjoy,
Gunny Mike
zilchworks.com