Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 3925 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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.

Posted

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?
  • Like 1

This topic is 3925 days old. Please don't post here. Open a new topic instead.

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.