Need a little script help

Need a little script help

am 02.04.2008 18:49:27 von unknown

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]

Re: Need a little script help

am 02.04.2008 22:21:17 von unknown

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.

Re: Need a little script help

am 02.04.2008 22:25:24 von d-42

> 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

Re: Need a little script help

am 03.04.2008 00:01:37 von Howard Schlossberg

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
Member, FileMaker Business Alliance

Re: Need a little script help

am 03.04.2008 00:02:49 von Howard Schlossberg

In my last post, I wrote:
> I would pass $BCode & ? & $Description.

It came through as a question mark but should have been a return character.

Re: Need a little script help

am 03.04.2008 03:29:26 von Helpful Harry

In article
<82da710a-59eb-4e19-a474-15fc22d7bd0d@u10g2000prn.googlegroups.com>,
d-42 wrote:

> > 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.

Me neither. It looks like possibly duplicating records, or at least
some of the data, which might be better done by simply Exporting and
then re-Importing the records.



> 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.

Creating new records will also lose the place in the Loop (although the
records being sorted will help a little) and then there's two Go To
Next Record steps which will likely cause problems and skipped records.

Helpful Harry
Hopefully helping harassed humans happily handle handiwork hardships ;o)

Re: Need a little script help

am 03.04.2008 06:02:29 von d-42

On Apr 2, 3:02 pm, Howard Schlossberg
wrote:
> In my last post, I wrote:
>
> > I would pass $BCode & ? & $Description.
>
> It came through as a question mark but should have been a return character.

I generally use:

List($bcode, $description)

rather than concatenateing strings with return separators. One caveat
to watch for though is that if a parameter is blank List() appears to
omit it entirely instead of inserting a blank line.

-cheers,
Dave

Re: Need a little script help

am 03.04.2008 06:10:01 von d-42

On Apr 2, 6:29 pm, Helpful Harry
wrote:

> Creating new records will also lose the place in the Loop

Possiblly, but only if the two layouts are based on the same table
occurrence.

With modern versions of filemaker, layouts based on a different table
occurrences have independant found sets.

In old versions you had exactly one found set per table/file. And
there were no table occurrences so all layouts in a file shared the
same single found set.

In new versions you have one found set per table occurrence. And
seeing as you can have multiple tables per file, -and- multiple table
occurrences per table, ...well this is incredibly useful, as you can
imagine, as its entirely possible to have multiple found sets for a
single table in different layouts

-regards,
Dave