Jump to content

"Let" Calc causes near infinite loop?


 Share

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

Recommended Posts

So, I am trying to recover, and any ideas would be appreciated.

I have a database with about 7,000 records in one table. I created a calculation that was supposed to "catenate" two text fields. The calculation was (from memory) something like

Let ( [$value1 = field1;

$value1 = Trim ($value1);

$value1 = $value1 & If (Right ($value1, 1) ≠ "."; "."; "");

$value2 = field2;

$value2 = Trim ($value2);

$value2 = $value2 & If (Right ($value2, 1) ≠ "."; "."; "");

$value = $value1 & " " $value2

];

$value;

)

So I typed this in, hit return, and suddenly FMPro says that it is taking about 1 min/record to update the field--which for 7,000 records is about 4 days. I finally had to kill FMPro, and when I looked at my database after killing the program, it had grown from 1MB to 3GB.

Is this normal?

Link to comment
Share on other sites

Why are you using variables here? You don't have to so just use the standard syntax:

Let ( [

x = Trim (field1);

x = x & If (Right (x; 1) ≠ "."; "." );

y = Trim (field2);

y = y & If (Right (y; 1) ≠ "."; "." )

];

x & " " & y

)

Try that. Also you might consider not storing the result of the calculation.

Edited by Guest
Link to comment
Share on other sites

That was it.

Why was I using dollar signs? Because I thought that they were required by FileMaker syntax.

Interestingly, all my other "Let" calculations in this database were using $'s, and were returning correct results. But in this case, there must have been some sort of recursion, because the database grew at least 300x in size when I introduced this calculation.

Thx

Link to comment
Share on other sites

Yeah, I don't think it was using variables either but just thought i'd point out that.

I still don't think that using that many variables in a calc is a good idea, but it was probably something with the syntax -- maybe there's some way to achieve recursion using just variables?

Link to comment
Share on other sites

I wonder what was responsible then... Probably wasn't incorrect syntax, FM kind of throws fits when you try that : . There is a semi colon after $value where there shouldn't be one, but that's probably just clerical error. Hmmmm...

Link to comment
Share on other sites

Hi

It turns out that removing the $ fixes the problem. Perhaps there was some catentation of previous values as suggested. Perhaps what happens is that the $ syntax does something strange in this context, like dereferencing a string as a variable. I don't know if this is a feature or a bug, but I reported it to FileMaker. They can contact me for more info if requested

The actual calculation that was causing the error was

Let ( [ $result1 = t Conabio locality;

$result1 = Trim ( $result1 );

$result1 = $result & If (Length ($result1) > 0 and Right ($result1; 1) ≠ "."; "."; "");

$result2 = t Conabio Habitat;

$result2 = Trim ( $result2 );

$result2 = $result & If (Length ($result2) > 0 and Right ($result2; 1) ≠ "."; "."; "");

$result = $result1 & If ($result1 ≠ "" and $result2 ≠ ""; " "; "") & $result2

] ;

$result

)

(Please don't comment that there is an easier way to achieve what I was trying to do--I know that).

Note that there is a "bug" in that the variable $result is used before it is set, which may mean that it is picking up the previous value?

My variable naming conventions include starting variable names with a "t" when they are text fields.

Thanks for all the thoughts. As I said, I fixed the problem.

And, as I said, upon declaring a variable based on this caculation (or upon trying to import data into an empty database with this calculation), I almost immediately run into a very wait dialog, taking about 1-minute per record, and the database quickly balloons from 10^7 bytes to 3*10^9 bytes.

A

Please contact me at [email protected] if you really want to follow up on this.

Edited by Guest
Link to comment
Share on other sites

How interesting, so if you set a $var in a field, it will remain set until the file closes? What happens if you change the value in a script?

Hmmmm, good work :(

Edited by Guest
Link to comment
Share on other sites

This topic is 5702 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
 Share

×
×
  • Create New...

Important Information

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