Creating a dynamic file reference as a text field

I am using an email plug called mailit that can send emails within Filemaker with attachments.   I have created a script that grabs the file reference for the attachment from a global field.  The only way it works is if the file reference is a text field with the reference contained in quotes.

I wanted to change the file reference so that it works on any computer.  I tried changing the contents of the global field to Substitute(Quote(Get( DesktopPath) & "Inventory Update.xls");"/C";"C"), and it didnt work.

I am not sure what to do
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

do you mean to work on pc and mac or just on any PC?
also the plug-in probably need a windows or UNC path, not a fmaker one.
so you should get something like:
"C:\Documents and Settings\Utilisateur\Mes documents\Mes images\mire.png"
and  not
"C:/Documents and Settings/Utilisateur/Mes documents/Mes images/mire.png"
so swap / for \ and it shoud be ok.
Also not that dacons mailit has a browse option to select the file to attach.
jarrodpriceAuthor Commented:
I dont want to browse for it, this is an automated script.  This is a pc.  I dont understand your solution.

I want the file reference to be dynamic.  The point of the script is to first import an excel file to the desktop, then send it as an attachment for database backup.  The desktop folder is different on every computer, so I need the file reference to be a Get (desktoppath) calc.  A calc does not work for a file reference.
it does, but not directly, you must use a variable.
for instance:
set $file = get(...........)
then use $file as the fileref (you type it manually in the fileref dialog window).
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

jarrodpriceAuthor Commented:
That doesnt work.  I tried.
jarrodpriceAuthor Commented:
how do I reverse the /\ .

Substitute does not work to replace "/" with "\"
something else is wrong, I do this w/o any pb.
do you have an example from dacons for the attachement path syntax?
do you confirm that the plug-in must grab an external file of which the name is in a fm field?
jarrodpriceAuthor Commented:
If the global field it grabs from is a text file reference it works fine.  If it is a variable that is a text reference it is fine.

It only becomes a problem when I introduce a calculation into the mix, either within the global field it is referencing, or as part of the variable.

I know that get(desktoppath) creates the file reference as /C:/ rather then \, so it could be that.  I dont know.
jarrodpriceAuthor Commented:
"attachment"; Emai_GetFileName(Globals::AttachmentPath);
"once"; "" )

This it their example
the resulting path must use \ for sure.
and calc done on the fly should be ok, unless it is wrong
before using the Emai_SmtpAddAttachment function, use a custom dialog to display the same expression and check if it looks OK.
also quote function prevents get(desktoppath) from working. so remove that 1st
jarrodpriceAuthor Commented:
I am confused.  how do I switch the direction of the "\"'s

I tried evaluating the calc "get(desktop)path"

this is the result: "/C:/Documents and Settings/Administrator/Desktop/"

So how do I switch it around?

Substitute (get(desktoppath);"/";"\") does not work

I would guess this is the cause of the problem, so how do I switch them?

should be:
if you need quotes:
"\"" & right(substitute(get(desktoppath);"/" ; "\\" ); length(get(desktoppath))-1)& "\""
if you don't:
right(substitute(get(desktoppath);"/" ; "\\" ); length(get(desktoppath))-1)

ie, substitute the /, then skip the first character
jarrodpriceAuthor Commented:
still didnt work.

This should be easier.
try to import the file to be attached in a container and use the other method, the one for files from a container field.
And their example works...
So must some other thing... some spécial character in your file name??

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
what did you do finally?
jarrodpriceAuthor Commented:
The first step I imported the file into a container, then used their instructions for sending attachments from a container.

That way, I was able to use the Get (Desktoppath) when importing it into the container, without involving the plugin.

After that it worked fine
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
FileMaker Pro

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.