Jump to content

loops in script and a subscript


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

Recommended Posts

  • Newbies

I am developing a solution that includes a Itemized Receipt Maker for payments off monthly tuition and other fees.

The receipt maker first creates the empty records, then populates the records, and then moves the receipts to a storage file. In the main script that populates the empty receipts there is a loop that stops the script when there are no more payments for that particular account and month.

The problem is getting the receipt maker to process all the empty receipt records. When the main script exits the loop in the subscript checking for more payments it also exits the main loop to process all the records

Everything works fine If I process only 1 receipt it is batch processing that I am having trouble with. (The same problem is preventing me from combining all 3 main scripts together also)

I am developing with FMPro 5.0v1 on a PC

Any help is greatly appreciated.

Link to comment
Share on other sites

  • Newbies

How can I show you the script? There are several subscripts as well that make the whole thing work? Is there a way to print the script definitions to a file and then be able to e-mail it? or a way to copy and paste on a PC?

Is there any philosophy or online articles that deal with loops contained in a main script within loops in a subscript ?

Again any help is greatly appreciated.

Link to comment
Share on other sites

Good question, you could probably send me a cut down version of the file (to protect anything proprietary). Or print the script to a .pdf file and send it to me.

The general principle is if you use an exit loop, it drops you at the step after end loop. If you use an exit script, you will return to the next step in the calling script. An exit loop script step in a subscript should only affect the loop in the subscript. All loops should have their loop...end loop steps in the same script.

There is probably a way to do what you wish, but we'll need to get down to the particulars if the above ideas don't help.

-bd

Link to comment
Share on other sites

  • Newbies

Sound like in theory that it should be able to work then. Have to go through it again on tues when I get back to work. May be a better way to do this as well as I am new to FMP side of scripting (converted web developer)

Also how do I print to a .pdf file? I have postscript drivers installed (from Photoshop CD) but I do not have Adobe Acrobat. just the reader. Will it be text or images that get exported?

Thank You for your time.

Link to comment
Share on other sites

I'm not sure exactly what the pdf driver looks like on the PC side, it should just look like another printer. You should be able to print just about anything to the file and have it reproduced when the .pdf file is opened with Adobe Acrobat Reader. A pdf file is just a variation of the postscript instructions set to a postscript printer when you print to it.

It was my pleasure.

-bd

Link to comment
Share on other sites

  • Newbies

FYI:

I was able to print to .pdf with the demo version of Amyuni PDF Converter for PC @ www.amyuni.com

It leaves a watermark on your PDF Doc but you can still copy and paste the text into a text file and then format it.

When I run this without looping it it works fine. I am trying to get this script to proccess multiple records. It will do the first record and that is all

Any help is greatly appreciated

*****RECEIPTS.FP5*****

Reciept Maker Start

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

# "Start Search for This Months Payments "

Perform Script [ Filename: "Tuition.fp5", "Determine Month and Year" ]

[ Sub-scripts ]

Go to Field [ Account Number ]

Copy [ Account Number ]

[ Select entire contents ]

Perform Script [ Filename: "Tuition.fp5", "Final Search" ]

[ Sub-scripts ]

Perform Script [ " Reciept Maker" ]

[ Sub-scripts ]

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

Reciept Maker

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

# "Start Creating This Months Receipts"

Loop

# " Pass 1"

# "Copy and Paste Payment Amount"

Perform Script [ Filename: "Tuition.fp5", "Copy Payment Amount" ]

[ Sub-scripts ]

Exit Loop If [ Status( CurrentMessageChoice) = 1 ]

Perform Script [ " Reciept Maker 1 Payment Amount" ]

[ Sub-scripts ]

# "Copy and Paste Check Number"

Perform Script [ Filename: "Tuition.fp5", "Copy Check Number" ]

[ Sub-scripts ]

Perform Script [ " Reciept Maker 1 Check Number" ]

[ Sub-scripts ]

# "Copy and Paste Payment Date"

Perform Script [ Filename: "Tuition.fp5", "Copy Date Received" ]

[ Sub-scripts ]

Perform Script [ " Reciept Maker 1 Check Date" ]

[ Sub-scripts ]

Perform Script [ Filename: "Tuition.fp5", "Omit Record" ]

[ Sub-scripts ]

# " Pass 2"

# "Copy and Paste Payment Amount"

Perform Script [ Filename: "Tuition.fp5", "Copy Payment Amount" ]

[ Sub-scripts ]

Exit Loop If [ Status( CurrentMessageChoice) = 1 ]

Perform Script [ " Reciept Maker 1 Payment Amount" ]

[ Sub-scripts ]

# "Copy and Paste Check Number"

Perform Script [ Filename: "Tuition.fp5", "Copy Check Number" ]

[ Sub-scripts ]

Perform Script [ " Reciept Maker 1 Check Number" ]

[ Sub-scripts ]

# "Copy and Paste Payment Date"

Perform Script [ Filename: "Tuition.fp5", "Copy Date Received" ]

[ Sub-scripts ]

Perform Script [ " Reciept Maker 1 Check Date" ]

[ Sub-scripts ]

Perform Script [ Filename: "Tuition.fp5", "Omit Record" ]

[ Sub-scripts ]

# " Pass 3"

# "Copy and Paste Payment Amount"

Perform Script [ Filename: "Tuition.fp5", "Copy Payment Amount" ]

[ Sub-scripts ]

Exit Loop If [ Status( CurrentMessageChoice) = 1 ]

Perform Script [ " Reciept Maker 1 Payment Amount" ]

[ Sub-scripts ]

# "Copy and Paste Check Number"

Perform Script [ Filename: "Tuition.fp5", "Copy Check Number" ]

[ Sub-scripts ]

Perform Script [ " Reciept Maker 1 Check Number" ]

[ Sub-scripts ]

# "Copy and Paste Payment Date"

Perform Script [ Filename: "Tuition.fp5", "Copy Date Received" ]

[ Sub-scripts ]

Perform Script [ " Reciept Maker 1 Check Date" ]

[ Sub-scripts ]

Perform Script [ Filename: "Tuition.fp5", "Omit Record" ]

[ Sub-scripts ]

# "End Creating This Months Receipts"

End Loop

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

Reciept Maker 1 Payment Amount

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

If [ IsEmpty(Payment Amount) = 1 ]

Paste [ Payment Amount ]

[ Select entire contents ]

Else

Perform Script [ " Reciept Maker 2 Payment Amount" ]

[ Sub-scripts ]

End If

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

Reciept Maker 2 Payment Amount

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

If [ IsEmpty(Payment Amount line 2) = 1 ]

Paste [ Payment Amount ]

[ Select entire contents ]

Else

Perform Script [ " Reciept Maker 3 Payment Amount" ]

[ Sub-scripts ]

End If

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

Reciept Maker 3 Payment Amount

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

If [ IsEmpty(Payment Amount Line 3) = 1 ]

Paste [ Payment Amount Line 3 ]

[ Select entire contents ]

Else

Show Message [ Buttons: "OK", "", ""; Data: "There are more payments than lines available" ]

End If

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

Reciept Maker 1 Check Number

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

If [ IsEmpty(Check Number) = 1 ]

Paste [ Check Number ]

[ Select entire contents ]

Else

Perform Script [ " Reciept Maker 2 Check Number" ]

[ Sub-scripts ]

End If

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

Reciept Maker 2 Check Number

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

If [ IsEmpty(Check Number line 2) = 1 ]

Paste [ Check Number line 2 ]

[ Select entire contents ]

Else

Perform Script [ " Reciept Maker 3 Check Number" ]

[ Sub-scripts ]

End If

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

Reciept Maker 3 Check Number

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

If [ IsEmpty(Check Number Line 3) = 1 ]

Paste [ Check Number Line 3 ]

[ Select entire contents ]

Else

Show Message [ Buttons: "OK", "", ""; Data: "There are more payments than lines available" ]

End If

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

Reciept Maker 1 Payment Date

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

If [ IsEmpty(Payment Date) = 1 ]

Paste [ Payment Date ]

[ Select entire contents ]

Else

Perform Script [ " Reciept Maker 2 Payment Date" ]

[ Sub-scripts ]

End If

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

Reciept Maker 2 Check Number

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

If [ IsEmpty(Payment Date line 2) = 1 ]

Paste [ Payment Date line 2 ]

[ Select entire contents ]

Else

Perform Script [ " Reciept Maker 3 Payment Date" ]

[ Sub-scripts ]

End If

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

Reciept Maker 3 Check Number

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

If [ IsEmpty(Payment Date Line 3) = 1 ]

Paste [ Payment Date Line 3 ]

[ Select entire contents ]

Else

Show Message [ Buttons: "OK", "", ""; Data: "There are more payments than lines available" ]

End If

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

*****TUITION.FP5*****

Determine Month and Year

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

# "This script will determine what month and year it is and run the appropiate subscripts"

# "JANUARY 2001"

If [ Month(Status( CurrentDate)) = 1 and Year(Status( CurrentDate))= 2001 ]

Perform Script [ " Sort for Receipts Jan 2001" ]

[ Sub-scripts ]

End If

# "FEBRUARY 2001"

If [ Month(Status( CurrentDate)) = 2 and Year(Status( CurrentDate))= 2001 ]

Perform Script [ " Sort for Receipts Feb 2001" ]

[ Sub-scripts ]

End If

# "MARCH 2001"

If [ Month(Status( CurrentDate)) = 3 and Year(Status( CurrentDate))= 2001 ]

Perform Script [ " Sort for Receipts Mar 2001" ]

[ Sub-scripts ]

End If

# "APRIL 2001"

If [ Month(Status( CurrentDate)) = 4 and Year(Status( CurrentDate))= 2001 ]

Perform Script [ " Sort for Receipt April 2001" ]

[ Sub-scripts ]

End If

# "MAY 2001"

If [ Month(Status( CurrentDate)) = 5 and Year(Status( CurrentDate))= 2001 ]

Perform Script [ " Sort for Receipts May 2001" ]

[ Sub-scripts ]

End If

# "JUNE 2001"

If [ Month(Status( CurrentDate)) = 6 and Year(Status( CurrentDate))= 2001 ]

Perform Script [ " Sort for Receipts May 2001" ]

[ Sub-scripts ]

End If

# "JULY 2001"

If [ Month(Status( CurrentDate)) = 7 and Year(Status( CurrentDate))= 2001 ]

Perform Script [ " Sort for Receipts July 2001" ]

[ Sub-scripts ]

End If

# "AUGUST 2001" If [ Month(Status( CurrentDate)) = 8 and Year(Status( CurrentDate))= 2001 ]

Perform Script [ " Sort for Receipts Aug 2001" ]

[ Sub-scripts ]

End If

# "SEPTEMBER 2001"

If [ Month(Status( CurrentDate)) = 9 and Year(Status( CurrentDate))= 2001 ]

Perform Script [ " Sort for Receipts Sept 2001" ]

[ Sub-scripts ]

End If

# "OCTOBER 2001"

If [ Month(Status( CurrentDate)) = 10 and Year(Status( CurrentDate))= 2001 ]

Perform Script [ " Sort for Receipts Oct 2001" ]

[ Sub-scripts ]

End If

# "NOVEMBER 2001"

If [ Month(Status( CurrentDate)) = 11 and Year(Status( CurrentDate))= 2001 ]

Perform Script [ " Sort for Receipts Nov 2001" ]

[ Sub-scripts ]

End If

# "DECEMBER 2001" If [ Month(Status( CurrentDate)) = 12 and Year(Status( CurrentDate))= 2001 ]

Perform Script [ " Find February 2001" ]

[ Sub-scripts ]

End If

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

Final Search

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

Enter Find Mode

Go to Field [ Account Number ]

Paste [ Account Number ]

[ Select entire contents ]

Perform Find

Sort [ Sort Order: Hidden Field Month (Descending)Date Recieved (Ascending) ]

[ Restore sort order, No dialog ]

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

Copy Payment Amount

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

Go to Field [ Hidden Field Month ]

If [ IsEmpty(Hidden Field Month) = 1 ]

Show Message [ Buttons: "OK", "", ""; Data: "No more payments this month" ]

Else

Go to Field [ Payment Amount ]

Copy [ Payment Amount ]

[ Select entire contents ]

End If

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

Copy Check Number

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

Go to Field [ Hidden Field Month ]

Copy [ Check Number ]

[ Select entire contents ]

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

Copy Date Received

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

Go to Field [ Hidden Field Month ]

Copy [ Date Recieved ]

[ Select entire contents ]

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

Omit Record

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

Omit Record

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

Link to comment
Share on other sites

I have not reviewed the script in great detail, but two obvious problems stick out. First, you use copy and paste to move values, but have no Go to Layout steps in your scripts. For a copy or paste to work, the field must be visible on the current layout. To make sure they are, you must use Go to Layout steps to make sure. Second, when you use a Show Message() script step, the result of this step are only valid to be tested in the next script step in the same script. You can't test the result five script steps later or in an external script in another file. Yes it MOSTLY work, but results can be unpredictable. If you need to test the button later, the script should look like:

Show Message ()

Set Field (gResult, Status(CurrentMessageChoice))

where gResult is a global number field.

You're working too hard to do what you need. The use of relationships would simplify the setting of the values in the other file greatly and eliminate the need for sooo many scripts and most of the external scripts. You could use a portal to access multiple records in the Tuition file. In general, it is good practice not to use copy and paste to move data from one file to another. Globals, relationships, and the Set Field step are a must better idea.

As to your early loop exit problem. It's probably due to the improper use of the message test I mentioned above. Many script steps return a status and can write over the button status you are looking for by the time you get around to the test.

-bd

[This message has been edited by LiveOak (edited February 14, 2001).]

Link to comment
Share on other sites

Another thing I noticed in your loop script is there is no "Go to Next Record" step. If you do not have that step, it will process the first record then either stop or continue to process that same record - over and over until the script is manually stopped.

Link to comment
Share on other sites

  • Newbies

Thanks for all the help it is greatly appreciated.

I was having trouble deriving information from portals thus the reason for sooo many scripts in other files. All the data is related I was just having trouble accessing what I needed through a portal (or portals.

I have re-investigated using portals with much more success (I made a tuition maker which adds monthly tuition to all accounts depending on which program, siblings, sibling discounts and scholarships)

I am going to re-do the receipt maker using portals hopefully with more success.

I used the message status to exit loops. I was kinda using them as place holders also to trouble shoot the script.

I did not use go to next record because I was omiting the record instead (I was having trouble proccessing the last record)

Again thanks for all your help and insight.

Link to comment
Share on other sites

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