Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

  • Newbies
Posted

I have a problem where the IF statement still skip to the ELSE even if there is  a match. To explain the logic here. I'm going through a file and prior to this I have a lot of string parsing and record deletion and everything works perfectly until these last steps to delete the dupes.

  • I show all records
  • I sort by location field so the dupes line up
  • I go to the first record
  • I set the variable  to the ocation field. I've tried local and global variable, but the same result
  • I go to the next record
  • The loop begins
  • When the IF statement is a match it skips the deletion of the record and continue with the ELSE and loops

post-109440-0-90118400-1376131739_thumb.

Posted

The problem: you initialize the variable $$Sdupes, but then refer to $$dupes in the If part (and then again to $$Sdupes).

 

It's probably a good idea to use camelCase names for variable names, especially when the name proper starts with an “s” (and to use local variables, whenever possible), it makes such things easier to spot.

 

Also recommended is the use of the Debugger and the Data Viewer; you would see at once that the script uses two different variables, where only one is supposed to be.

  • Newbies
Posted

Duh, I never saw that coming. I've been sitting here too long and I'm blind. Thanks for clearing that up and now it works. I also saw that I need to step back one after deletion so that I can check the next record for the same. The script looks like this now. Your help is much appreciated.

 

 

post-109440-0-99556800-1376135096_thumb.

Posted

Another strategy: when new, set $ and omit; delete when dup. This way, you remain on the first record and simply let the list slide up, without a Go to Next. Exit Loop if [ not Get ( FoundCount ) ].

 

Initialize the $ before the loop to an empty value, so the first record is considered new. Final two steps just to see the result.

post-80889-0-08442900-1376136885_thumb.p

Posted

Good call using Omit, Eos.  FileMaker, particularly if sorted, is slower going to next record and it gets worse as the record set grows.  

 

 

Initialize the $ before the loop to an empty value, so the first record is considered new. 

 

Why clear a local variable at the start of any script?  Within the loop, the first If[] test will find an empty $location anyway and will evaluate correctly. 

Posted

Why clear a local variable at the start of any script?  Within the loop, the first If[] test will find an empty $location anyway and will evaluate correctly. 

 

Right; I think I started out with another scheme and forgot to edit that little bit of wisdom… but thanks for the reminder.

Posted

"Why clear a local variable at the start of any script?"

 

I think it's good practice.

 

Because sometimes I use script debugger. 

 

If I am stepping through a script and decide I need to look at the loop behavior again, I can just use the "Set Next Step" command to reposition the script to the initializer step and then begin stepping through the loop again.

Posted (edited)

Hi Bruce,  

 

I understand where you're coming from but that means that every time that script runs ... repeat ... EVERY time that script runs (potentially thousands of times and for the remainder of that file's life), it wastes an evaluation simply because the Developer may possibly want to back-step and debug it at some later point.  Possibly.  Maybe once.  Maybe.

 

I wouldn't consider it good practice at all.    :laugh2:

Edited by LaRetta
Posted

Is there a shortage of evaluations? Do they cost money? Are the bits going to get tired too soon?

 

I find it convenient. You may not; but wasting an evaluation just isn't anywhere on the scale of relevance or performance issues.

Posted

A simple thing such as this can make a big difference if ran through a very large record set. And if you easily blow off this evaluation cost and then that evaluation cost and the next thing you know, you have a solution that runs like a dog and sinks like a stone, particularly on WAN.

 

We will have to agree to disagree then ... every evaluation counts.  I would rather spend an addition 5 seconds of a Developer's time than cost the User one nano-second.

Posted

Yes, we will have to disagree. This is just not ever going to have a measurable effect and no user will ever notice it. 

This topic is 4122 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.