Skip 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.

How to code a variable in this script?

Featured Replies

Howdy, all:

I'm trying to learn how to implement variables but am unsure how to insert them and where.

For a runtime solution I'm working on, the attached report-generating script is used for six different-named fields; the script is identical for each one save for the highlighted steps; that's where the different field names plug in but they all end up using the same print layout. For example, AC_Tail_Number is one field used in the attached script, Serial_Number is another field that would/could use the same script and so on for all six fields.

If a variable is used I imagine it'll be a global one (?)

Cheers,

Rich

Variable_Question.gif

Edited by Guest
Upload didn't

You can script a Find like this:

Enter Find Mode

Set Field( myField ; $myValue )

Perform Find

But you can't do this:

Enter Find Mode

Set Field( $myField ; $myValue )

Perform Find

In other words, the field itself can't be dynamically selected -- the field name can't be a variable. You can work around this by using a specific layout to perform your find, and giving each field an object name. Then you can script:

Enter Find Mode

Go to object( $myField )

Set Field( *don't select any field* ; $myValue )

Perform Find

As for Sorts, they can't be specified dynamically at all. About the best you can do is something like:

If( $myVariable = "name" )

Perform Sort

Else If( $myVariable = "date" )

Perform Sort

Else If etc. etc.

Good standard practices are:

- Declare all your variables at the top of your script, so you can keep track of them.

- Use a standard name such as $param and assign Get(ScriptParameter) to it, again right at the top of the script

- Don't use global variables unless you have a good reason. It just makes more work to clean them up when you're done.

  • Author

Thanks, Fitch! Indeed, I should (make that, will) learn the proper nomenclature and structure standards for FM.

I hope you survived the wind and rains okay during the last few days; it's not often you get hurricane winds in Portland. (If Powell's inventory got waterlogged it'll definitely be a tragic loss.)

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

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.