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.

Beginner: perform a search - get the result as array

Featured Replies

  • Newbies

Hi there,

I'm writing a ScriptMaster-Plugin to upload data from a database to an FTP-Server.

FTP stuff is clear but I'm having trouble with more basic stuff.

I want to perform a search on a table and get the result in an array.

By looking through the examples I figured out how to access FM's calculation engine but I still don't know how to access the database and get records to deal with.

Any help, hint or example would be appreciated.

Regards,

Lumpi23

I would suggest executing the Find within Filemaker's scripting language.

You can then use GetNthRecord(table::field;record#) to obtain the contents of field 'field' of record 'record#' in table 'table'. There is a good example of looping through a found set in the 'Access the FileMaker Calculation Engine Part 3' sample script that comes with ScriptMaster. Note that record number above, means 'record number in the current found set'.

You may also want to consider having the Filemaker script tabulate the data, store it in a global field, export this field to a file, and then call the scriptmaster script to ftp it. I don't know enough about the problem to determine if that's a better or faster method or not.

I've done the ftp part with both ScriptMaster and the DOS ftp command, DOS ftp can run concurrently with FM (nice for long files), and doesn't require a plugin, but it isn't as flexible as ScriptMaster which can do ftps, etc. http://fmforums.com/forum/showtopic.php?tid/216556/pid/364984/post/last/m/1/ is an example.

Edited by Guest

  • Author
  • Newbies

Thank You for Your help.

So if I get You right, theres no way of easily accessing data in the database from the ScriptMaster code itself, without to "prepare" a search result in an FM Script? So, as a consequence, data manipulation is not possible from there, either?

I'm doing the FTP-upload using the "Jakarta Commons Net-Library" from apache.org:

http://commons.apache.org/net/

But if I'm thinking about your suggestion to export the data from each field, then an external upload would be more efficient.

Anyway, thank You very much!

Regards,

André

you have access to FileMaker data and to container fields. The fmpro object gives you access to those container fields via fmpro.getContainerStream( fieldName ).

To have complete access to the database data you need to buy the advanced version of ScriptMaster to access the database via SQL. However in your case you could simply create a loop that loops through the records with containerfields and perform the upload (if I understood your problem well).

actually I have a question: what is the exact object returned by the method getContainerStream?

  • Author
  • Newbies

This sounds good to me, but I can only find the "getContainerStream" function in the ScriptMaster Doc. Is there a "getField" function? Or do I have to treat text-fields as containers as well, reading the text as a byte stream?

no you can access the filemaker calculation engine, so you already have access to the GetField () function.

  • Author
  • Newbies

Yes, that makes sence :)

Thank You for helping me out!

From the ScriptMaster docs:

getContainerStream( fieldName )

Gets an input stream with bytes from the container field. Be sure to pass in the NAME of the container field, ie fmpro.getContainerStream( "Person::Photo" )

This will return a java.io.InputStream

You can also use the getContainerFileName if you want to find the name of the file stored in the container field:

getContainerFileName( fieldName )

Gets the name of the file stored in a container field. Be sure to pass in the NAME of the container field, ie fmpro.getContainerFileName( "Person::Photo" ) might return 'jesse.jpg'

Hi Jesse

thanks, but if I create an object using the fmpro.getContainerStream() method, and I apply the getClass() method to this object, I get as a result "FMBinary". As I understood (correct me if I am wrong) inputStream is an abstract class, so can I conclude the FMBinary is simply a subclass of inputStream?

Andries

Here's what I get:

fmpro.getContainerStream("container").getClass()

class com.prosc.fmkit.types.FMBinary$FMContainerInputStream

FMBinary is not an InputStream subclass itself, but it contains a class called FMContainerInputStream, which is what you're getting. FMContainerInputStream is a subclass of InputStream, and the $ sign shows that FMContainerInputStream is a class contained inside the FMBinary class.

This makes a lot of sense, and makes things more clear to me :P-)

thanks!

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.