Jump to content

Can I write data to a textfile using FMPro 16


Recommended Posts

I have FilemakerPro 16, and I would like a script that does the following:
(1) opens a textfile on my computer, if it exists (or create it if it doesn't exist)
(2) writes the content of a field at the end of the file (ie, as a new final line)
(3) closes the textfile

Is that possible without a plugin?
If not, is there a cheap or free plugin that will enable this?

Link to post
Share on other sites

It is possible in version 18. In version 16, you can:

  1. Insert the text file into a variable;
  2. Read the contents of the file using the TextDecode() function;
  3. Append the contents of a field to the contents of the file;
  4. Encode the resulting text using the TextEncode() function and set a global container field to the result;
  5. Export the global container field, overwriting the original text file.

Alternatively you can use the (free) BaseElements plugin or OS-level scripting (AppleScript on macOS).

 

Edited by comment
Link to post
Share on other sites

Thanks comment.  I downloaded the baseelements plugin, got a zip file which unzipped into a single item called BaseElements.fmplugin

I googled how to install it, but I couldn't get it to install by copying that file into Library>Application Support>Filemaker>Extensions 

Sent a message to the author of the plugin, but so far no reply.

So, I thought I'd try to use your suggestion in Steps 1 to 5, but in Script Workspace I couldn't see TextDecode in the script steps, so didn't understand how I could use it. Is a "function" another name for a "script step"?

Can you please give me a simpler explanation of how to create the script you describe.

Thanks.  Philip Caplan

Link to post
Share on other sites

Let me start with this:

48 minutes ago, philipcaplan said:

I couldn't get it to install

Make sure the file is installed exactly where it says in the help:
https://fmhelp.filemaker.com/help/16/fmp/en/#page/FMP_Help%2Finstalling-plug-ins.html%23

If you're not sure, open Preferences > Plug-ins and click `Reveal Plug-in Folder'. 

Once you have the file there, make sure it's enabled in the Preferences.

 

55 minutes ago, philipcaplan said:

I couldn't see TextDecode in the script steps, so didn't understand how I could use it. Is a "function" another name for a "script step"?

TextDecode() is a function. A function is different from a script step. Not to give you a hard time, but this is something very basic. I am taken aback by your asking this.

 

Link to post
Share on other sites

Hi comment.  I'm sorry if I disappointed you  :(  please understand I am not a database expert. I am a printing-company owner who dabbles in getting freelancers to write website code, and I was introduced to FM (I think it was then Filemaker II) in the late 1980's as a way to "manipulate and massage" data to feed into DTP programs like QuarkXPress.

As I only use FMPro when a need arises, I am not attuned to the subtleties of the program, and to answer your 2 points above:  I had followed the installation instructions to manually copy the baseelements.plugin file into the Library on my Mac, and thought it had not installed because (unlike Works360 plugin, which added script steps in ScriptWorkspace) BE didn't appear. BUT IT HAD INSTALLED (as I found when using Filemaker>Preferences).

I have very much valued your help in the past in providing me with chunks of code which enabled me to achieve results that I couldn't figure out for myself, and I hope you'll be able to help me again in the future.

Please forgive me.

Regards,  Philip Caplan

Link to post
Share on other sites

There is no need to apologize. I was simply surprised because you have been a member here for over 15 years and you describe your skill level as intermediate. I try to tailor my responses to the asker and I would not offer the suggestion in my first post to a novice.

 

Link to post
Share on other sites

My skill level is "intermediate" because, if it was offered as an option, I would prefer to say "intermediate in what I know, novice in what I don't". But that wasn't a choice!!

:)

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.