The latest version of The Bat! is available from the Ritlabs website: DOWNLOAD THE BAT!

Author Topic: how to make %attachments conditional?  (Read 5667 times)

Offline gwailoh

  • Pipistrelle
  • *
  • Posts: 3
how to make %attachments conditional?
« on: February 10, 2003, 11:56:35 AM »
hi there,

i'd like to use %attachments, but only have it work if there actually are attachments added.  in short, i don't want it to spit out <none>

any way to do this?

thanks,
charlie

Offline PerryNelson

  • Noctule
  • **
  • Posts: 28
Re: how to make %attachments conditional?
« Reply #1 on: February 11, 2003, 01:02:21 AM »
Quote from: gwailoh
i'd like to use %attachments, but only have it work if there actually are attachments added.  in short, i don't want it to spit out <none>

any way to do this?


Hi, Charlie.

Yes, it appears that it is possible.  I created a quick template that I called TEST and experimented with the following %IF macro.  It works here, so it proves the possibility.  Now the only exercise for you will be making it work in the context where you need it.  

Here is my TEST quick template:

%IF:"%ATTACHMENTS"="<none>":"":'%IF:"%ATTACHMENTS"<>"<none>":"%ATTACHMENTS"'

Maybe this will get you started.  Let us know how you fare.

--
Perry

Offline gwailoh

  • Pipistrelle
  • *
  • Posts: 3
how to make %attachments conditional?
« Reply #2 on: February 11, 2003, 11:26:10 AM »
Hi Perry,

thanks for your help.  I copied that into a quick template, and it certainly does work that way.   however even with that its not quite i how would prefer it.   Could it be made so that  1. every result is listed on a separate line (not together as separated by semicolons) and 2. that the result(s) occur at the end of the letter, not wherever the cursor happens to be?

however the real failure & problem is that when i copied that into the bottom of my template for 'new' messages, hoping that it'd work automatically ... it doesn't.  all that happens is the last character of my signature getts appended with a  '  symbol.  this is even if i put your %if... string several spaces below the sig.

thanks,
charlie

Offline PerryNelson

  • Noctule
  • **
  • Posts: 28
how to make %attachments conditional?
« Reply #3 on: February 12, 2003, 01:11:03 AM »
Quote from: gwailoh
I copied that into a quick template, and it certainly does work that way.   however even with that its not quite i how would prefer it.   Could it be made so that  1. every result is listed on a separate line (not together as separated by semicolons) and 2. that the result(s) occur at the end of the letter, not wherever the cursor happens to be?

however the real failure & problem is that when i copied that into the bottom of my template for 'new' messages, hoping that it'd work automatically ... it doesn't.  all that happens is the last character of my signature getts appended with a  '  symbol.  this is even if i put your %if... string several spaces below the sig.


Hi, Charlie,

First, let me recommend that you join, even if temporarily, the TBTECH mailing list and ask your question there, because there are a larger number of expert users there who I'm sure can offer you excellent guidance about achieving what you want to do.  Frankly, I don't know if it is possible to change the %ATTACHMENTS' pattern of putting all the attachments on the same line separated by semi-colons, though it wouldn't surprise me at all if that weren't possible to do what you want.  The folks on TBTECH will surely know, however.  If you wish to join that list, you can do so at this URL:

http://www.silverstones.com/thebat/TBUDLInfo.html

Next, let's address your wish to control where the attachments are listed in your message, if you use the quick template method I've already given you.  In my example, you would position your cursor where you want the list of attachments and type the word "TEST' and then press Ctrl-Spacebar.  That will call the quick template and put any attachments on the line where you have entered the name for the quick template (TEST).  

I wouldn't have expected the quick template to work in your template for new messages because when you create a new message, it doesn't yet have an attachment (with one exception that I'll discuss in a moment).  That's why I chose to address your question by using a quick template.   My own work flow when I'm sending a file to someone is to create a message in which I explain that I am sending a file and THEN attach the file.  So in that situation the file would not be attached prior to creating the new message; therefore the attachment(s) wouldn't yet be there for the macro to work on if it were present in the New template.  

Now for the exception I mentioned above.  

If I am in Windows Explorer (or some other application) and right click on a file, I have the option to "Send to" and then one of the options is "Mail Recipient."   I've just tried that here and in that case, The Bat! opens a mail message with a file already attached and, here at least, it puts the file name in the message window in the editor.  So it is already listing that one file.  If I highlight two (or more) files and right click and choose "Send to" and then choose "Mail Recipient," The Bat! opens a message with both of the files listed (albeit with a semi-colon separating them).  Therefore, using this approach, The Bat! is already doing what the quick template I gave you is designed to do.  Coincidentally, The Bat! also uses the file name(s) as the subject of the message it creates.

As to why the last character of your signature gets an apostrophe appended to it, again I'm not quite sure.  I suspect that it has something to do with the fact that you've put the %IF macro after your signature, and, as I said above, at the time the message is created there isn't yet an attachment to the new message you've created.

I hope this helps clarify things a bit.

--
Perry

Offline gwailoh

  • Pipistrelle
  • *
  • Posts: 3
how to make %attachments conditional?
« Reply #4 on: February 12, 2003, 02:32:58 AM »
Thanks for all your help Perry,

best regards,
Charlie

Offline PerryNelson

  • Noctule
  • **
  • Posts: 28
The Answer: "how to make %attachments conditional?"
« Reply #5 on: February 12, 2003, 11:36:58 AM »
Quote from: gwailoh
Thanks for all your help Perry,


I'm glad I could point you in the right direction.  Also I'm pleased Marck was able to answer your question and that you've now gotten the two QTs from the Library he recommended working for you.

For those of you who aren't on TBTECH and may be reading this thread, you can find two quick templates that do almost exactly what Charlie wanted at this URL:

http://www.silverstones.com/thebat/Library.html#attachments+listing

The only caveat is that these only work as quick templates, NOT in New or Reply templates, because of the reasons I mentioned in my previous response to Charlie.

--
Perry

 

SMF spam blocked by CleanTalk