Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Need to prompt user to choose a text file

Featured Replies

  • Newbies

Is it possible to have the user be prompted to choose a text file, and then have FM read it?  There's a certain type of XML file that users will need to import more than once. I need a script to process the XML and add records.  I have no problem parsing the XML file in script but I can't figure out a way to read a text file.  Is there a script command that can prompt for a text/xml file?  Or is there some file chooser UI field type?

 

I tried using 'Open File' without specifying the location.  That defaults to only select FM file types.  If you change the dialog to show all file types, and then select a text file, it complains that FM didn't create the file (which it actually did but this clearly is expecting only an FM db).

 

Am I supposed to do something with container fields?  I tried adding one and having the user drag and drop a text file into it but I don't see how to read the actual data from the file.  I can only see the name.  Anyone have any ideas or workarounds?  Thanks.

  • Author
  • Newbies

Hey thanks for the response.  That article kind of confuses me.  Is it just about grabbing the full path to the file?  Once I have the path how exactly do I import / read it?  Am I missing something?

Use the calculation in the article to put the path into a variable, e.g., $importfile. Then specify $importfile as the file in the Import Records script step.

Another option is to use a plugin, such as the (free) BaseElements.

 

However, you shouldn't be having this problem at all, since Filemaker can import XML files directly, given a suitable XSLT stylesheet. Parsing XML within Filemaker is a lot of unnecessary and error-prone work.

 

 

---

P.S.

Please update your profile to reflect your version and OS.

Edited by comment

Hi Breton, and welcome to the Forums,

 

Is it possible...

 

 

As comment replied, please update your profile to reflect your current OS, Platform and FileMaker version. Here is a quick link to MY PROFILE. This information helps us address our reply to fit your situation.

 

Lee

  • Author
  • Newbies

Thanks I think I finally got this working.

 

Yea I'm familiar XSLT but the export XML creation was so simple I ended up not needing it for that.  It may be possible to use FM's import functionality for this XML but I'm guessing with complex table relationships I'm working with and all the dynamic field name creation I'm going to need, I'd be better off just parsing it myself.  That and I'm also a big fan of functional programming.  I've been looking forward to the XML parsing part.  I'll do it all with elegant custom functions.

Take a min and update!

[shrug] Not to belittle your abilities, but Filemaker's text functions are no match for what can be achieved with a dedicated XML parser and XSLT processor - both of which are included in the application.

 

 

I'm guessing with complex table relationships I'm working with and all the dynamic field name creation I'm going to need,

 

"dynamic field name creation"? I don't think that's possible using any method  (except by importing into a new table, if that counts).

Is it possible with an SQL plugin?

Is it possible with an SQL plugin?

 

That's a good point - I believe it is. However, given that:

 

There's a certain type of XML file that users will need to import more than once.

 

I doubt it's something you'd want to do. But maybe it's just me...

  • Author
  • Newbies

[shrug] Not to belittle your abilities, but Filemaker's text functions are no match for what can be achieved with a dedicated XML parser and XSLT processor - both of which are included in the application.

 

 

 

"dynamic field name creation"? I don't think that's possible using any method  (except by importing into a new table, if that counts).

 

I've amassed a pretty robust set of custom functions for string manipulation.  Using those I've also created a lot of custom functions that control string based data structures.  These made this task much simpler than one would expect.  My regular job is a Java developer so I'm used to having tools like this.

 

"Dynamic field name creation" was a bad choice of words.  I meant that I'll only know which fields I need to import at run-time.  It don't think using FM's automated xml import can allow me to conditionally include/exclude certain fields.  This probably sounds weird, but I didn't design the database I'm working with and it does some things in weird ways.

It don't think using FM's automated xml import can allow me to conditionally include/exclude certain fields.

 

I am not convinced that is so. Filemaker could have certainly made it easier by allowing a parameter to be passed to the stylesheet at runtime. Still, you can start the process by exporting a file to a known location and have the stylesheet pick the settings from there.

 

 

EDIT:

Filemaker scripted import - no matter from what type of file - does NOT allow you to "conditionally include/exclude certain fields". The best you can do is prepare several "presets" (each in the form of a stored Import Records script step) and choose one at runtime.

 

Alternatively, you could import all fields into a temp table and take it from there. IMHO, that's still a lot of less work than parsing the entire source file into records AND fields, and only then getting to this exact same point.

Edited by comment

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.