Here's my save function:
function global:save-checkbook
($checkbook) { #save-checkbook
$checkbook | export-clixml -path
checkbook.xml
$a = (Get-Host).UI.RawUI
$a.ForegroundColor = "cyan"
$a.BackgroundColor = "darkcyan"
}
What happens if I type “save” and
give it the wrong variable?
All my data is over-written. I
shouldn't have to worry about that.
Here's my load function:
function global:get-checkbook {
import-clixml -path checkbook.xml
}
I want to make a copy of my checkbook
before I open it, so, here's the code:
function global:get-checkbook {
$tempdate = get-date
$path = "checkbook"
$path += $tempdate.year
$path += $tempdate.month
$path += $tempdate.day
$path += $tempdate.hour
$path += $tempdate.minute
copy-item checkbook.xml $path
import-clixml -path checkbook.xml
}
This works fine, but I'll add an XML
extension for consistency.
(I know that this only keeps one backup
per minute, but I think that's enough. The problem will be lots and
lots of backups piling up. I guess I could write script that kept
just one per day, or something, or delete them by hand, from time to
time.
But that will wait.
Since the function is more complicated,
it needs to be documented, plus, with the complicated hash table that
I use for transactions, this might get disorienting. How about this:
function remind {
" "
" "
"get-checkbook [load]"
"save-checkbook [save]"
"new-transaction [nt]:"
"-month -day -payee -amount -cat
-debit (default TRUE) -year (Currently 2011)"
}
Powershell provides all this
information, of course, to people who know how to look for it, but
this is all I expect to be trying to remember at any given moment.
And here's the revised get-checkbook:
function global:get-checkbook {
.SYNOPSIS
Loads the checkbook array into a
variable you provide.
.DESCRIPTION
Gets the contents of a file called
"checkbook.xml" after saving the current contents in a
dated backup file.
$tempdate = get-date
$path = "checkbook"
$path += $tempdate.year
$path += $tempdate.month
$path += $tempdate.day
$path += $tempdate.hour
$path += $tempdate.minute
$path += ".xml"
copy-item checkbook.xml $path
import-clixml -path checkbook.xml
}
The long term plan for this is to do
finances with it for the month of January, see how easy it is to use,
add and revise functions as I go.