logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Customizing spot and alert email formatting
WN4AZY
#1 Posted : Thursday, July 11, 2013 8:32:58 AM(UTC)
admin

Rank: Administration

Groups: Administrators, Beta Testers
Posts: 3,091
Man
Location: Auburn, GA

Thanks: 997 times
Was thanked: 495 time(s) in 410 post(s)
This article is for users who wish to change the formatting of Spot and Alert emails sent by LOGic. This article is intended for advanced users. You do not need to know how to program, but should be a patient individual with good basic computer skills.

There is also a file attached to this article that provides simplified spot and alert emails that you can download so as to avoid doing all this.

The formatting of texts and emails are controlled by a database table. By editing this table, you may change the formatting of emails. There is no screen in LOGic for editing this file, so you need to use Logic's Database Commands feature. This feature gives you access to the internals of LOGic, and is most frequently used for mass-changing data. We will begin with a short tutorial on using the Database Commands feature.

As always, we recommend backing everything up before beginning. An easy way to do this is to exit LOGic, and make a copy of your whole LOGic install folder. In particular, you want to keep a copy of spotemail.dbf and spotemail.fpt (located in the logdata folder which is inside your LOGic install folder -- program files (x86)\logic\logdata in most cases). However, you can get it off of your original installation package if you screw it up and fail to make a backup.

There are menu options in the Database Commands window for opening database files and performing some common basic operations. For brevity, this article will use commands that you will type into the Command window. (However, don't hesitate to explore this window's menu options.) To execute a command, type it in the Command window. Press {Enter} to execute it. Let's try it. Type

? datetime()

and press {Enter}. The current date and time is displayed.

All commands you type remain in the Command window and scroll up as you type new commands. You may redo a command by placing the cursor on it and pressing {Enter}. You may modify the command before pressing {Enter}.

Ok, so lets get started. Type

use spotemail
edit

The file will be displayed in an editable window.

Let's take a look at the records and fields in this table. There are separate records for spots and alerts. There are also separate records for HTML and plain-text emails. LOGic, as of this writing, only supports plain-text emails.

The SUBJECT field contains an expression that defines the subject of the email. BODY is a freeform memo field that contains the template that defines the body of the email. It contains expressions enclosed within double-curlybraces.

To see the contents of the Body fields, hold your mouse on top of it (the window must be active). Or open the memo field in an editor by double-clicking it. The edit window opens behind other windows, so a large monitor helps. Drag things around so you can see everything. If you double-click Memo and no window appears, it probably opened behind something.

Also note the HTML, ALERT, and ACTIVE fields. These are logical True/False fields. If ALERT is T, the record defines the format for alerts. Otherwise it defines the format for spots. ACTIVE determines if the record is in use or not. There must be one and only one active record for Alerts. Ditto for Spots.

For this example, let's simplify the Alert email. We can edit the existing record, but we can also create a new record, leaving the factory one in place so we can easily switch back to it if we want to, or keep it around for an example.

To add a new record to the Edit window, type {Ctrl-Y}. (To delete a record, click the little area to the left of the field names). Type my alert for Descr. LOGic doesn't do anything with this field. It is just for us humans to read. Rather than retype the subject, let's copy and paste the factory alert record. This is the record that has T in Active and ALERT.

We must use the keyboard for this. Hilight the Subject we are copying. Put the cursor in the field and type {Ctrl+A}. Copy to the clipboard by typing {Ctrl+C}. Now place the cursor at the beginning of the Subject field in the new record and paste by typing {Ctrl+V}.

By the way, these keyboard shortcuts for editing are not unique to LOGic, or even Microsoft or Windows. They work in most any application on any computer. They are worth remembering.

To copy the Body, double-click Memo in the factory record, {Ctrl+A){Ctrl+C}, double-click memo for the new record, and {Ctrl+V}. Now close the memo edit window

Finally, be sure to type T for alert in our new record. Enter F for Active in the old alert record, and T for Active in the new record.

Ok, we have finally completed the setup. This is actually the most time-consuming part. The changes will be easy.

Let's start with the subject. It is currently:

Quote:
"LOGic alert " + TRIM(spotalertexpr.descr) + " de " + TRIM(spot_by) + ": " + TRIM(call) + " " + unzerofl(freq) + " " + lower(TRIM(comment))


Let's change it to:

Quote:
"LOGic alert: " + TRIM(spotalertexpr.descr) + " de " + TRIM(spot_by) + ": " + TRIM(call) + " " + unzerofl(freq)


Just delete some stuff from the end. We are removing the comment from the subject

Now the body. It is currently

Quote:
LOGic has received a spot that matches an alert:

Description:{{chr(9)}}{{ALLTRIM(spotalertexpr.Descr)}}
Expression:{{chr(9)}}{{ALLTRIM(spotalertexpr.Expression)}}
Direction:{{chr(9)}}{{unzerofl(direction)}} ({{unzerofl((direction + 180)%360)}} long path)
Posted: {{chr(9)}}{{spot_datet}}


In case you are wondering, all the {{chr(9)}} are tabs.

For the body, we will remove the introductory line and expression, and add the Comment:
Quote:

Description:{{chr(9)}}{{ALLTRIM(spotalertexpr.Descr)}}
Direction:{{chr(9)}}{{unzerofl(direction)}} ({{unzerofl((direction + 180)%360)}} long path)
Comment: {{chr(9)}}{{TRIM(comment)}}


Let's simplify spots too. Create a new record as we did for our new alert. Enter MY SPOT for the Descr. Set Active to T on our new record. Leave ALERT blank or enter F here. Enter F for the factory spot record.

Change the subject from

Quote:
"LOGic spot: " + TRIM(award) + " " + alltrim(awardval)+ " de " + TRIM(spot_by) + " : " + TRIM(call) + " " + unzerofl(freq) + " " + lower(TRIM(comment))


to

[quote]lower(trim(award) + " " + trim(subaward) + " " + trim(call) + " " + unzerofl(freq))[quote]

Note that I have used the LOWER() function to display all of the text in lower-case. Lower-case letters take up less of the precious screen real estate on your cell phone.

Leave the Body blank. It is optional. There, you can't get much simpler than that! You might want to do the subject-only trick for Alerts too.

Close the editing window, close the Database Command Window, and open and close the spot log or just restart LOGic. Generate a test spot to see the results of our work.

If LOGic crashes, there is an error in one of your expressions. The error message should be useful in determining the problem. Or, simply restore your copy of spotemail.dbf

For this example, we just deleted some stuff. We didn't discuss the expressions themselves. The expressions work like any other expression used in LOGic for report writing or filtering, and everything in Help about Expressions and Functions applies here.

The attached file is the results of following this article. To use it, simply download, unzip, and and replace your spotemail.dbf and spotemail.fpt files with these new ones. The files are located in the logdata folder which is in the LOGic install folder.
File Attachment(s):
spotemail.zip (2kb) downloaded 74 time(s).
1 user thanked WN4AZY for this useful post.
aa4hp on 5/25/2014(UTC)
Sponsor
Note: We receive a commission from Amazon when you purchase via this link. It does not affect your cost. Thank you!
vk4iu
#2 Posted : Monday, July 15, 2013 8:44:03 PM(UTC)
VK4IU

Rank: Advanced Member

Groups: Moderator, Registered, Administrators
Posts: 404
Man
Location: Hodgleigh QLD

Thanks: 6 times
Was thanked: 77 time(s) in 68 post(s)
Thanks for that Dennis. Just what I needed.

Peter VK4IU
Peter VK4IU
You can help by posting images of any errors and including your Logic version.
aa4hp
#3 Posted : Sunday, May 25, 2014 8:24:49 AM(UTC)
Rank: Member

Groups: Registered
Posts: 9
Man
Location: Titusville, FL

Thanks: 2 times
This is pretty slick. I modified the output appropriately and sent it to AT&T's Email to SMS gateway, so now I receive spots and alerts as texts. Thanks Dennis it's just what the Doctor ordered!
Hank AA4HP
aa4hp
#4 Posted : Sunday, May 25, 2014 11:40:58 AM(UTC)
Rank: Member

Groups: Registered
Posts: 9
Man
Location: Titusville, FL

Thanks: 2 times
Now that I have good looking text spots, if I wanted to include the LOTW Membership status in either the subject or the body, what would be the expression I would need to operate like the "Y" / blank behavior of the Spot Log?

Tnx, Hank AA4HP
WN4AZY
#5 Posted : Monday, May 26, 2014 6:32:42 PM(UTC)
admin

Rank: Administration

Groups: Administrators, Beta Testers
Posts: 3,091
Man
Location: Auburn, GA

Thanks: 997 times
Was thanked: 495 time(s) in 410 post(s)
Hi--

Glad you are making use of this feature!

Try this expression:

iif(lotw_user, "Yes", "No")

or specifically what you asked for:

iif(lotw_user, "Y, "")

By the way, if anyone is wondering how I figured this out, I looked at the format of the spot file in Database Commands:

USE SPOTS
MODIFY STRUCTURE

I see LOTW_USER listed, as type Logical. IIF is documented in Expressions and Functions in help.

Let me know if any questions.

Tnx & 73,

Dennis WN4AZY
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF 1.9.5.5 | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.075 seconds.