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

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

Recommended Posts

Posted

I use the following script, and it doesn't work, can anyone tell me why.

I want to show records in a layout List view where the date is today and no later than a week in the future in date order.

The Script

Enter Browse Mode

Sort Sort Order: StartDate Ascending Pickup Ascending Restore sort order, No Dialog

Show All Records

Goto Record/Request/Page

First

Loop

If StartDate >= Today and StartDate < Today + 7

Omit Record

End If

Goto Record/Request/Page

Next, Exit after last

End Loop

Show Omitted

Goto Layout Due Out

This is doing my head in, the programming to me looks fine, why can't Filemaker handle the script. Any suggestion would be appreciated.

Thanks

Posted

Bear in mind that scripts should produce the same result effects as though youo had performed each task in order.

If you perform your task by "hand" you'll find that the go to next record is unnecessary when the record was just omitted, because FM has removed the record from the found set and automatically advanced you to the next.

Personally, I would

Start from last

check/omit as necessary

if we didn't omit then go previous rec

exit if we are at rec 1

Posted

The Script tidied up a bit and made to work:

Enter Browse Mode

Sort Sort Order: StartDate Ascending Pickup Ascending Restore sort order, No Dialog

Show All Records

Goto Record/Request/Page First

Loop

If StartDate >= Status(CurrentDate) and Status(CurrentDate)+7 > StartDate

Omit Record

Else

Goto Record/Request/Page Next, Exit after last

End If

End Loop

Show Omitted

Goto Layout Due Out

--------------------

However, consider this as a solution:

Create a calculating text field (lets call it DATEFINDER) with the following calculation:

Case( StartDate >= Status(CurrentDate) and Status(CurrentDate)+7 > StartDate, “x”, “”)

Now create a find script:

-----

Perform find, restore find requests

Goto Layout Due Out

-----

This looks for the value “x” in the field DATEFINDER and goes to the right layout!

Hope this helps,

Rigsby

Posted

Mark and Rigsby pointed out a very common mistake of using Omit in a Loop, i.e., when you Omit a record, the next record becomes the current record! So the Go to Next Record step skips every record following an Omit. shocked.gif Rigsby's script corrects this by adding the Else statement.

I'm wondering, though, why not just script the Find to begin with?

Enter Find Mode( )

Insert Calculated Result (StartDate, DateToText (Status(CurrentDate)) & "..." & DateToText (Status(CurrentDate) + 7))

Perform Find( )

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