Groups > Databases > Filemaker > Re: Need a little script help




Need a little script help

Need a little script help
Wed, 2 Apr 2008 11:49:27 -0500
My first try at this script and it almost worked.  The problem was that 
it was skipping a record, so I moved the Go to Next record to an 
earlier part of the script.  Now my script runs, but it doesn't 
generate any data.  All I get in the Layout "Broker Code List" is one

record that is completely blank.  On my first attempt when I had the 
first Go to Record/Request/Page [Next; Exit after last] at the end of 
the main Loop it would work, but was skipping a record, so I moved it 
to an earlier step of the script, which looks okay to me, but obviously 
now it no longer generates data.  I'm hoping one of you more 
experienced users could look at this short script and quickly see where 
my problem lies.

Here's the first script:

Go to Layout ["BCLinker" (BCLinker)]
Perform Find [Restore]
Sort Records [Restore; No dialog]
Go to Record/Request/Page [First]
Loop
	Set Variable [$BCodeL; Value: BCLinker::BCID]
	Set Variable [$Description; Value:Users::Users::Name_First & " "
& 
Users::Name_Last & " " & "(" &
BCLinker::CommPerc & ")"]
	Set Variable [$BCode; Value:Broker Codes::BrokerCD]
	Go to Record/Request/Page [Next; Exit after last]
	Loop
		Exit Loop If [$BCodeL <> BCLinker::BCID]
		Set Variable [$Description; Value: $Description & " " & 
Users::Name_First & " " & Users::Name_Last & " "
& "(" & 
BCLinker::CommPerc & ")"]
		Go to Record/Request/Page [Next; Exit after last]
	End Loop
	Perform Script ["Add Records"]
End Loop

And here is the "Add Records" script

Go to Layout ["Broker Code List" (Broker Code List)]
New Record/Request
Set Field [Broker Code List::Broker Code: $BCode]
Set Field [Broker Code List::Description; $Description]
Post Reply
Re: Need a little script help
Wed, 2 Apr 2008 13:25:24 -0700
> I'm hoping one of you more
> experienced users could look at this short script and quickly see where
> my problem lies.

Well I can't make head or tails out of what you are trying to actually
do.

Your inner loop makes no sense to me whatsoever.

But I did note that your add records sub script changes the layout and
doesn't return to the original, so when it comes back for the second
run through the loop its on a different layout, and that's is likely a
bug.

-regards,
Dave
Post Reply
Re: Need a little script help
Wed, 02 Apr 2008 15:01:37 -070
Doug Anderson wrote:

> Well, I solved my own problem.  Apparently the variables are not being 
> passed to the subscript. If I combine the two scripts into one script it 
> works just fine.

I couldn't figure out why you needed the inner loop.  Really could have 
been one loop with an IF[] statement to handle the case where it is a 
new ID.

As for variables being passed to the subscript, either you can use"
1) a global variable (i.e. $$BCode & $$Description), or
2) pass a script parameter with your Perform Script ["Add Records"] 
step.  I would use this method instead of the global variables; the less 
global variables, less clutter and to cleanup.  Since you have two 
parameters, I would pass $BCode & ? & $Description.  And then in your 
"Add Records" script, start it off with:
	Set Variable [$BCode; getValue(get(ScriptParameter), 1)]
	Set Variable [$Description; getValue(get(ScriptParameter), 2)]
There are, of course, other ways to pass multiple parameters...but the 
above will work in this case and may be the simplest.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Schlossberg
FM Professional Solutions, Inc.    Los Angeles

FileMaker 8 Certified Developer
Post Reply
Re: Need a little script help
Wed, 02 Apr 2008 15:02:49 -070
In my last post, I wrote:
> I would pass $BCode & ? & $Description.

Post Reply
Re: Need a little script help
Wed, 2 Apr 2008 15:21:17 -0500
On 2008-04-02 11:49:27 -0500, Doug Anderson said:

> My first try at this script and it almost worked.  The problem was that 
> it was skipping a record, so I moved the Go to Next record to an 
> earlier part of the script.  Now my script runs, but it doesn't 
> generate any data.  All I get in the Layout "Broker Code List" is
one 
> record that is completely blank.  On my first attempt when I had the 
> first Go to Record/Request/Page [Next; Exit after last] at the end of 
> the main Loop it would work, but was skipping a record, so I moved it 
> to an earlier step of the script, which looks okay to me, but obviously 
> now it no longer generates data.  I'm hoping one of you more 
> experienced users could look at this short script and quickly see where 
> my problem lies.
> 
> Here's the first script:
> 
> Go to Layout ["BCLinker" (BCLinker)]
> Perform Find [Restore]
> Sort Records [Restore; No dialog]
> Go to Record/Request/Page [First]
> Loop
> 	Set Variable [$BCodeL; Value: BCLinker::BCID]
> 	Set Variable [$Description; Value:Users::Users::Name_First & "
" & 
> Users::Name_Last & " " & "(" &
BCLinker::CommPerc & ")"]
> 	Set Variable [$BCode; Value:Broker Codes::BrokerCD]
> 	Go to Record/Request/Page [Next; Exit after last]
> 	Loop
> 		Exit Loop If [$BCodeL <> BCLinker::BCID]
> 		Set Variable [$Description; Value: $Description & " " &

> Users::Name_First & " " & Users::Name_Last & "
" & "(" & 
> BCLinker::CommPerc & ")"]
> 		Go to Record/Request/Page [Next; Exit after last]
> 	End Loop
> 	Perform Script ["Add Records"]
> End Loop
> 
> And here is the "Add Records" script
> 
> Go to Layout ["Broker Code List" (Broker Code List)]
> New Record/Request
> Set Field [Broker Code List::Broker Code: $BCode]
> Set Field [Broker Code List::Description; $Description]

Well, I solved my own problem.  Apparently the variables are not being 
passed to the subscript. If I combine the two scripts into one script 
it works just fine.
Post Reply
<< Previous 1 2 Next >>
( Page 1 of 2 )
about | contact