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.

Setting variables from the current record

Featured Replies

I am maintaining a system which has been written by several prople over several years.  A few days ago I needed to modify a routine which set global variables for each of about 40 columns in a record (so context could be switched and still access those fields).  I needed to add about 15 more columns, and that sort of repetitive work doesn't appeal to me.  Thus I came up with the following:

 

Evaluate(

"Let([" & Let(q=Get(LayoutTableName);ExecuteSQL("
select '$$'||fieldname||'="&q&"::'||fieldname
from filemaker_fields where tablename = '"&q&"'
and fieldclass = 'Normal' and fieldtype not like 'global%'
order by fieldname
";"";";¶";""))&"];0)")

 

Assigning this to a variable resluts in zero, but assigns a (global) variable for each non-null normal field in the current record.

 

I don't know how much use this will be to anyone, but it seemed interesting enough to share.

A couple of thoughts:

 

- that calc is very hard to read.  I would expect a good demo to clearly explain what is happening and why.  There are no comments and no whitespace to follow the calc.  After running this through http://www.aptworks.com/cgi-bin/calc_formatter.cgi

I get this, and it is only marginally more readable

 

Evaluate(
    "Let([" &
    Let(
        q = Get( LayoutTableName );
        ExecuteSQL(
            "
select '$$'||fieldname||'=" & q &
            "::'||fieldname
from filemaker_fields where tablename = '" & q &
            "'
and fieldclass = 'Normal' and fieldtype not like 'global%'
order by fieldname
";
            "";
            ";¶";
            ""
        )
    ) & "];0)"
)
 
- more importantly: why would you want to declare x number of global variables in a calc?  Why not do this in a loop in a script and make local variables and take advantage of the proper scope: http://www.soliantconsulting.com/blog/2014/01/all-variables-should-be-global-or-not
Whatever you do with these variables, now you have to find an equally "fell swoop" method of clearing them out.  So the part that I am missing is: why do you need this, and how do you clean up when you are done?

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.