Tip: Days Remaining

I’m setting up a new dashboard for a book chapter I promised to write. The first draft is due on January 17, and I’m feeling a little nervous about that: the chapter is showing an alarming tendency to grow.

So I added a dashboard note with the following rule*:

$Subtitle=days(date("today"),date("1/17/2022 6:00 PM"))

So, now I have a nice note to remind me how much time remains.

*After the rule was working, I moved the rule to an edict. There’s no need to update this every few second, since it changes only once a day.

What handy dashboard items do you use?

5 Likes

Hi Mark,

Nice idea. Can you share an image of the note as well?

Tom

image

2 Likes

What handy dashboard items do you use?

I’m recording business mileage details in a dashboard container. The $Name of the container is the year and the $Subtitle is the total mileage expense for the year.

The children in the container are all of my individual car trips for the year, where I record mileage along with other business related attributes. Mileage expense for each trip is automatically calculated based on the allowed mileage rate for the year.

Here are my relevant dashboard container rules for 2021:

$TotalMileageExpense=sum(children,$MileageExpense);
$Subtitle=$TotalMileageExpense.format(“$”);
$MileageRate(children)=0.56;

1 Like

Nifty!

Could you post an image of your dashboard item! I think that’s a fun thing to do!

Screen Shot 2021-10-27 at 12.08.55 PM

I think this is a really good idea for a Task prototype.

In my pTask prototype I currently have the following rule: $Subtitle=$CompletionScore +"% Complete" which works with a bar Plot to change the colour of my task notes depending on how far along the completion path I am with that task. (set Pattern to “bar” and Expression to '$CompletionScore" where $CompletionScore is an attribute of that prototype)

The problem with my approach is that the $Subtitle should be across 2 lines, and it’s currently on one line. Any suggestions on how to insert a line break in the $Subtitle after “% Complete”?
Thanks

When entering a subtitle in the inspector, you can enter a line break with ctrl-Return.

When using an action to set the subtitle, \n represents a line break:

$Subtitle=42+"\n% complete"

Thanks a lot. I tried the /n but I put it outside the quote marks. This is a very elegant solution, thanks again.

No, I made an even dumber mistake. Forward slash is not the same as backslash. I’ve got it now.

For someone else looking for a solution, this works:

$Subtitle=$CompletionScore +"% Complete \n" + days(date(“today”),date($DueDate)) + " Days left"

Where $CompletionScore is a number between 0 and 100, held in an attribute that I update as the project or task progresses.

How about a note with the current outside temperature?

Using https://openweathermap.org:

$URL = https://api.openweathermap.org/data/2.5/weather?id=6947478&appid={yourAppId}&units=metric

“yourAppId” is the API key you get for free after registering with openweathermap.org.

$AutoFetchCommand = if($Text.contains(“.temp.:([0-9.]+)”)){ $Temperatur = $1; };

you will get:
Bildschirmfoto 2021-11-03 um 22.57.19

Weather.tbx (81.2 KB)

3 Likes

Suggestion: use the Dashboard prototype, or just adapt the settings, to make the subtitle big and the title small.

image

3 Likes

Here is a small update - the parameters for the weather API are now attributes of a prototype ($WeatherAPI and $WeatherCity). Then you could add individual notes and change the attribute $WeatherParam to retrieve any of the values delivered by the API (temp, …):

Weather_v2.tbx (100.4 KB)

It is not a perfect solution because each note sends it’s own request just to receive the same JSON as the other notes.

1 Like

A way to solve this is to have one note — perhaps /config/Weather — send the request. That note can parse out all the weather information you need, and other notes simply ask it for what they want.

$Subtitle=$Humidity(/config/Weather)

Alternatively, the config note could be responsible solely for downloading the json, and each note that wants to do weather could get the json from $MyString(/config/Weather) and extract what it needs.

2 Likes

just another sample - current news:

I used API Documentation - mediastack (up to 500 requests a month for free). You need to register and get a free API access key to use the demo.

NewsSample.tbx (100.1 KB)

1 Like

This is very cool, and I’ve been able to create an account, obtain an API authorization, looked up my city code, and I’m getting local data in the dashboard. That is, it worked.
I changed units to imperial, because they’re what I’m accustomed to, though metric in pressure is equally as familiar. "Hg is just quaint.

But… I could not figure out for the life of me how you’re populating the $Subtitle attribute with the returned data.

I saw you’re using $AutoFetchCommand, and that’s setting a variable, “myRegExTerm” equal to the result of some regular expression magic. That’s ALL you can see in the Attribute Browser, and there is nothing in the Action Inspector. In the Attribute Browser, there is an ellipsis following the regex statement. On a hunch, I clicked on the attribute, which highlighted it and I copied it and pasted it into a note, where I found this (I don’t see an icon to cause this to display as code):

var myRegExTerm=“.” + $WeatherParam + “.:([0-9.]+)”;
if($Text.contains(myRegExTerm)){ $Subtitle = $1 + $WeatherUnit; };

I understand everything in this except the $1. I don’t know what that is.

And to @eastgate, what am I missing in terms of being able to find the entire action code of the $AutoFetchCommand? I’m sure there’s something I’ve overlooked.

Thanks! This is very cool and an excellent use case for learning about a neat feature of Tinderbox.

1 Like

After a regular expression has been matched, Tinderbox sets a number of local variables that are available to the rest of the action.

  • $0 : the matched string
  • $1 : the first matched backreference
  • $2 : the second matched back reference

For string attributes longer than a displayed expression table, you can click to edit and then use the arrow keys, home and end keys, and so forth to examine them. Or copy the whole thing and paste in some convenient place, such as the text of a note. Some people like to compose in a note and then use a rule to move the text to the action attribute.

Thanks! Yes, the ellipsis was the essential clue. Didn’t think of arrowing over the text, but the ellipsis and the highlight made me think of “copy.” Noted for “best practices” purposes.