Jump to content

export 58 times some type of loop


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

Recommended Posts

My database has anywhere between 45,000 records and 350,000 records( it changes every day). I need to be able to export 2000 records at a time until all the records have been exported so the way I see is:

58 exports of 2000 records would work for a record set of 116,000

This is going to take me a long to in the scriptmaker to type. Is there anyone out there who knows a faster way of doing this. I took a screen shot of code from script maker so you could see my logic, by the way count1 is just get record count divided by 2000. Please help me!

Picture_6.pdf

Link to comment
Share on other sites

I can think of a way of doing this in FM8 -- sppitting out different file names using variables, but it will be an issue in 7 due to lack of those very variables... Though, what you could possibly do:

Freeze Window

Show All Records

If[Get(TotalRecordCount) <= 2000)]

..Export Records[[color:blue]specify stuff here];

Else

..Loop

....Enter Find Mode[Restore] ([color:blue]specify Omit records Table::Exported = 1)

....Perform Find[]

....Exit Loop If[Get(LastError) <> 0]

....Omit Multiple Records[Get(FoundCount) - (Get(FoundCount) - 2000))]

....Export Records[[color:blue]Enter Static File Here];

....If[Get(LastError) = 0]'

......Go To Record[First]

......Loop

........Set Field[color:red]Table::Exported ; 1]

........Go To Record[Next ; Exit After Last]

......End Loop

....Send Event[[color:blue]Apple Script to rename your static file to something else e.g. add a global field to get the current export set and tack on the date aswell (you'll have to ask someone else about this bit)]

....End If[]

..End Loop

..Show All Records[]

..Loop

....Set Field[color:red]Table::Exported ; ""]

....Go To Record[Next ; Exit After Last]

..End Loop

End If[]

Link to comment
Share on other sites

I am not sure marking the exported records is a good idea. It certainly won't speed the thing up. All that's needed is a global field to act as a counter, so one knows how many records to omit from the start (gCounter * 2000). Then jump to record #2001 and omit the rest. Hopefully no one will be adding new records while this is going on.

BTW, Get(FoundCount) - (Get(FoundCount) - 2000) is always 2000.

Link to comment
Share on other sites

lol, i knew there was something wrong with this logic... to tell you the truth i don't really remember what i was trying to achieve with that... oh well, i never was so good at maths.

Link to comment
Share on other sites

All that's needed is a global field to act as a counter, so one knows how many records to omit from the start (gCounter * 2000). Then jump to record #2001 and omit the rest.

Ok Im still lost? I understand about setting up a counter to know what record is what but how does that help me in the 58+ exports I need to do? I have attached a sample file with the problem laid out in the scriptmaker. There needs to be some sort of loop with this but I cant see it. Any help would be great!

deep1.zip

Link to comment
Share on other sites

I dont think you can put an export into a loop since it would name the file the same thing over and over again. This would overwrite the data so at the end of the 58 exports it would only have one file with 2000 records in it.

Yes this is another issue that I cant wrap my mind arround. only way I see it is to do 58+ exports and name them each 1-58 so there is no overlap?

Link to comment
Share on other sites

Since you're using FileMaker 7, which does not have the script Variable step to set an Export file name/path, you need to rename each export, immediately after exporting, with AppleScript. I say you attempted this, but incorrectly. Here is the generic AppleScript:

tell application "Finder" to set name of file "full path to exported file" to "new name"

The path to the exported file must be a Mac path, ie. (your file :-):

"Macintosh HD:Users:fej:Documents:Documents_ll:Downloads:deep.fp7"

Obviously yours would be different. You could construct it either within FileMaker, or using AppleScript. But that's up to you.

The value "new name" also could be constructed either place. I'd suggest doing it in FileMaker. It must change for every export, so something like a counter or time stamp would work. Do NOT use "/" or ":" in the name; they're not good for file names. Spaces are OK.

I would put the file name into a global field during a Looping script, on the current layout, so AppleScript can get it easily. The "_cExportPath" would be an unstored calculation, of a fixed path. You could use a relative path to the current database, and a fixed folder within its folder; also on the current layout.

Attached is an example file that does the Export & Rename, in a loop, 2000 at a time. It does the entire table however.

Export_Deep.zip

Link to comment
Share on other sites

Try something like:

Go to Layout [ "someLayout" ]

Set Field [ yourTable::gCounter; 0 ]

Loop

Show All Records

# SORT HERE

Exit Loop If [ Get (FoundCount) < yourTable::gCounter * 2000 ]

Go to Record/Request/Page [ First ]

Omit Multiple Records [ yourTable::gCounter * 2000 ] [ No dialog ]

Go to Record/Request/Page [ 2001 ] [ No dialog ]

Omit Multiple Records [ Get (FoundCount) - 2000 ] [ No dialog ]

# EXPORT HERE

#APPLESCRIPT TO RENAME/MOVE EXPORTED FILE

Set Field [ yourTable::gCounter; yourTable::gCounter + 1 ]

End Loop

Search the forum regarding the Applescript to rename the file.

Link to comment
Share on other sites

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