# Calculating Timespans in Years, Months, Days in AutoHotkey, Part 2 (Understanding the HowLong() Function)

## Taking a Close Look at the HowLong() Function for Calculating Years, Months, and Days

In this blog, I discuss in its entirety the most recent AutoHotkey code for the HowLongYearsMonthsDays.ahk script (introduced in my last blog). I’ve broken it up into snippets in order to explain the purpose of each piece. To get a complete copy of the script check out HowLongYearsMonthsDays.ahk at the “ComputorEdge Free AutoHotkey Scripts” page or for a barebones version (without comments and inactive code) see “Function Calculating Timespan in Years, Months, and Days” at the AutoHotkey Forum. This blog reviews the nuts and bolts of calculating the timespan between two dates.

# Calculating Timespans Between Dates in Years, Months, Days (AutoHotkey Function)

## Calculating the Years, Months, and Days Between Two Points in Time Takes More Than Simple Mathematics

Years ago, I wrote an AutoHotkey timespan calculation function for keeping track of my grandkids ages. (I wrote about it in my Digging Deeper Into AutoHotkey e-book and you can find the original function in the GrandKids.ahk scripts.) Developing the function was a bit of a mindbender. As I remember, I just plowed through the project finding my way by trial-and-error. When I recently reviewed the script, I had a heck of a time figuring out what I had done. I know that I explained the steps in the book, but the script (even with the few comments) remained a mystery to me.

As I thought about it, I soon realized that I might write a better function if I changed how I viewed the problem. Continue reading

# Updating the INI Data Table File (AutoHotkey Legal ListView Part 4)

## While It Only Takes One Line of Code to Update the INI Data File, You Must Take Into Account the INI File’s Encoding. Plus, DIY Implementation of the Other Cool ListView Features

Last time, I added code to the LegalListView.ahk script to edit and update the ListView window. This time, I add one line of code to update the same data in the LegalListView.ini file.

By updating the data table file with the edits made via LegalListView.ahk, we save any changes for future use. Continue reading

# Editing ListView GUI Control Data Tables (AutoHotkey Legal ListView Part 3)

## Once Loaded into an AutoHotkey GUI ListView, You Can Add Tools for Editing Data

With the exception of the first column, AutoHotkey does not allow direct editing in a GUI ListView control. That forces us to create separate editing controls for changing and updating content in any of the other columns. We can either add the controls to the same GUI as in the AddressBook.ahk script (shown below)—discussed in my AutoHotkey Applications e-book—or we can create a second GUI which pops-up on demand. Since putting all the controls in the same GUI creates less confusion for the ListView functions (the functions always operate on the default GUI), you might find the AddressBook.ahk example easier to implement for your application. Continue reading

# Use the ListView GUI Control to Find Duplicate Entries in Data Table Files (AutoHotkey Legal ListView Part 2)

## ListView Control Functions in a Loop Work Quickly Locate Repetitious Data

In my last blog, “ListView GUI Control for Viewing Data Table Files (AutoHotkey Legal ListView Part 1)“, I introduced using the ListView GUI control to view and correct a data table file—in this case, an INI file (LegalInput.ini). While sorting and viewing a data table in the ListView control offers many benefits, the most power comes from the 11 built-in functions available for manipulating the control and editing data.

All GUI controls (e.g. Edit, Text, MonthCal, etc.) offer options you can call with the initial Gui, Add command. ListView (and its sister TreeView) include similar options plus special functions for directly manipulating the control. Last time, we used LV_Add() to load the data table rows into the ListView control. This time, we use the LV_GetCount() function (the number of ListView rows) to limit the total number of iterations in a loop, LV_Modify() to focus on each table row in sequential order, and LV_GetText() to retrieve and store data in the row. Continue reading

# ListView GUI Control for Viewing Data Table Files (AutoHotkey Legal ListView Part 1)

## The Powerful ListView GUI (Graphical User Interface) Control Offers Advanced Features for Reading and Sorting Data Tables, Plus How to Make a ListView GUI Control Resizable

Recently, I wrote about how to use a data table to create Hotstrings using the Input command, then, after discovering that I can’t remember all the Hotstring combinations, showed how to build lookup menus from the same data table. Later, I used the same menu technique to demonstrate how to insert Latin legal terms in italics. I made a promise to create a Legal Lingo ListView GUI (Graphical User Interface) pop-up but, before I could undertake the task, other topics intervened. The time has come for me to deliver on my commitment. Continue reading