dbTalk Databases Forums  

Records and Scripting

comp.databases.filemaker comp.databases.filemaker


Discuss Records and Scripting in the comp.databases.filemaker forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
MammalianFish@gmail.com
 
Posts: n/a

Default Records and Scripting - 02-15-2007 , 10:44 PM






Hi,
I have a script that duplicates every record in a Find and modifies
the duplicate. At the end, another script runs that duplicates some
records again based on a certain parameter. The problem is that when
the second script runs, it will only duplicate the original records,
not the duplicates, even though the duplicates meet the parameters for
the script.

Basically, the scripts read like this:

{Define Cable}
Perform Script "Find and Sort"
GoTo Record [First]
Loop
Clear; [Select1.0::Cable Note]
Insert Text [Select1.0::Cable Note; "F"]
If [$1.0:irection = 1]
Perform Script "Return Circuit Name and Number"
# This script searches the record for info to copy from a
different field to paste in
Else
Perform Script "Return Previous Position"
#This script searches the previous record for information to
copy and paste in
End If
GoToRecord [Next; Exit After Last]
End Loop
Perform Script "Create Males"
Perform Script "Create Spares"
GoTo Record [First]
++End of Script++

{Create Males}
GoTo Record [First]
Loop
Duplicate Record
Insert Text [Select1.0::Cable Note; "M"]
GoToRecord [Next; Exit After Last]
End Loop
++End of Script++

{Create Spares}
GoTo Record [First]
Loop
If [$1.0::Cable > 49]
Duplicate Record
Insert Text [1.0::Position; "*"]
Insert Text [1.0::Number; "*"]
Insert Text [1.0:est Pos; "*"]
Insert Text [1.0:est Num; "*"]
End If
GoToRecord [Next; Exit After Last]
End Loop
++End of Script++

All the components seem to work individually, but whether run on the
master script or not, Create Spares doesn't work on duplictaed
records.

Thanks for any insight.

Joe


Reply With Quote
  #2  
Old   
Ursus
 
Posts: n/a

Default Re: Records and Scripting - 02-16-2007 , 07:55 AM






I would first start with eliminating every copy/paste action. It is never a
good idea to rely on something that can be changed in a multiple sort of
ways. Look into local variables and global variables and set field.

Then I would look in what you are wanting to achieve. To me it looks like
you are duplicating a lot of fields, then changing a few. Where I would
think that a related table would be easier to set up and easier to maintain.

Then it looks like the Create Spares script will duplicate an already
duplicated record. So now you have three clones of the same record.

Ah and now I see the problem. It is the $ sign. This is reserved for
variables only. NEVER use ist for anything else! Not for tablenames, fields,
layouts, valuelist. NEVER use it except for naming variables.

Ursus

<MammalianFish (AT) gmail (DOT) com> schreef in bericht
news:1171601079.344100.15330 (AT) m58g2000cwm (DOT) googlegroups.com...
Quote:
Hi,
I have a script that duplicates every record in a Find and modifies
the duplicate. At the end, another script runs that duplicates some
records again based on a certain parameter. The problem is that when
the second script runs, it will only duplicate the original records,
not the duplicates, even though the duplicates meet the parameters for
the script.

Basically, the scripts read like this:

{Define Cable}
Perform Script "Find and Sort"
GoTo Record [First]
Loop
Clear; [Select1.0::Cable Note]
Insert Text [Select1.0::Cable Note; "F"]
If [$1.0:irection = 1]
Perform Script "Return Circuit Name and Number"
# This script searches the record for info to copy from a
different field to paste in
Else
Perform Script "Return Previous Position"
#This script searches the previous record for information to
copy and paste in
End If
GoToRecord [Next; Exit After Last]
End Loop
Perform Script "Create Males"
Perform Script "Create Spares"
GoTo Record [First]
++End of Script++

{Create Males}
GoTo Record [First]
Loop
Duplicate Record
Insert Text [Select1.0::Cable Note; "M"]
GoToRecord [Next; Exit After Last]
End Loop
++End of Script++

{Create Spares}
GoTo Record [First]
Loop
If [$1.0::Cable > 49]
Duplicate Record
Insert Text [1.0::Position; "*"]
Insert Text [1.0::Number; "*"]
Insert Text [1.0:est Pos; "*"]
Insert Text [1.0:est Num; "*"]
End If
GoToRecord [Next; Exit After Last]
End Loop
++End of Script++

All the components seem to work individually, but whether run on the
master script or not, Create Spares doesn't work on duplictaed
records.

Thanks for any insight.

Joe




Reply With Quote
  #3  
Old   
Grip
 
Posts: n/a

Default Re: Records and Scripting - 02-16-2007 , 10:00 AM



On Feb 16, 6:55 am, "Ursus" <ursus.k... (AT) wanadoo (DOT) nl> wrote:
Quote:
I would first start with eliminating every copy/paste action. It is never a
good idea to rely on something that can be changed in a multiple sort of
ways. Look into local variables and global variables and set field.

Then I would look in what you are wanting to achieve. To me it looks like
you are duplicating a lot of fields, then changing a few. Where I would
think that a related table would be easier to set up and easier to maintain.

Then it looks like the Create Spares script will duplicate an already
duplicated record. So now you have three clones of the same record.

Ah and now I see the problem. It is the $ sign. This is reserved for
variables only. NEVER use ist for anything else! Not for tablenames, fields,
layouts, valuelist. NEVER use it except for naming variables.

Ursus

MammalianF... (AT) gmail (DOT) com> schreef in berichtnews:1171601079.344100.15330 (AT) m58g2000cwm (DOT) googlegroups.com...

Hi,
I have a script that duplicates every record in a Find and modifies
the duplicate. At the end, another script runs that duplicates some
records again based on a certain parameter. The problem is that when
the second script runs, it will only duplicate the original records,
not the duplicates, even though the duplicates meet the parameters for
the script.

I agree with Ursus, you are NOT using best practices in this script
and naming your field with a $ is causing your If statement to fail.
Didn't FM give you a warning message not to do that?

G



Reply With Quote
  #4  
Old   
Howard Schlossberg
 
Posts: n/a

Default Re: Records and Scripting - 02-16-2007 , 11:26 AM



Putting aside good naming conventions, your 'Create Spares' script is
set to only duplicate those find requests where $1.0::Cable > 49. But
you've never set that field to anything while you were in find mode. So
it seems you are really trying to test for the field value being >49.
If true, then you're script should probably look like this:

{Create Spares}
GoTo Record [First]
Loop
Duplicate Record
Set Field [$1.0::Cable; ">49"]
Set Field [1.0::Position; "*"]
Set Field [1.0::Number; "*"]
Set Field [1.0:est Pos; "*"]
Set Field [1.0:est Num; "*"]
GoToRecord [Next; Exit After Last]
End Loop
++End of Script++




MammalianFish (AT) gmail (DOT) com wrote:
Quote:
Hi,
I have a script that duplicates every record in a Find and modifies
the duplicate. At the end, another script runs that duplicates some
records again based on a certain parameter. The problem is that when
the second script runs, it will only duplicate the original records,
not the duplicates, even though the duplicates meet the parameters for
the script.

Basically, the scripts read like this:

{Define Cable}
Perform Script "Find and Sort"
GoTo Record [First]
Loop
Clear; [Select1.0::Cable Note]
Insert Text [Select1.0::Cable Note; "F"]
If [$1.0:irection = 1]
Perform Script "Return Circuit Name and Number"
# This script searches the record for info to copy from a
different field to paste in
Else
Perform Script "Return Previous Position"
#This script searches the previous record for information to
copy and paste in
End If
GoToRecord [Next; Exit After Last]
End Loop
Perform Script "Create Males"
Perform Script "Create Spares"
GoTo Record [First]
++End of Script++

{Create Males}
GoTo Record [First]
Loop
Duplicate Record
Insert Text [Select1.0::Cable Note; "M"]
GoToRecord [Next; Exit After Last]
End Loop
++End of Script++

{Create Spares}
GoTo Record [First]
Loop
If [$1.0::Cable > 49]
Duplicate Record
Insert Text [1.0::Position; "*"]
Insert Text [1.0::Number; "*"]
Insert Text [1.0:est Pos; "*"]
Insert Text [1.0:est Num; "*"]
End If
GoToRecord [Next; Exit After Last]
End Loop
++End of Script++

All the components seem to work individually, but whether run on the
master script or not, Create Spares doesn't work on duplictaed
records.

Thanks for any insight.

Joe

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Schlossberg (818) 883-2846
FM Professional Solutions, Inc. Los Angeles

FileMaker 8 Certified Developer
Associate Member, FileMaker Solutions Alliance


Reply With Quote
  #5  
Old   
MammalianFish@gmail.com
 
Posts: n/a

Default Re: Records and Scripting - 02-16-2007 , 01:42 PM



Hey,
I am new to Filemaker and its GUI scripting, so forgive me if it's
still a little crude.
However, I don't want to force all of the copies to have Cable values
of >49. When "Create Males" runs, it makes copies of every record (the
original records are set up to be Females, and the database is used to
create labels for cables). After it runs, I want "Create Spares" to
duplicate both records (male and female) for each cable over 49' long
(and modify them slightly so I know which is the spare). Correct me if
I am wrong, but the code you suggest will end up creating a spare for
every cable in the database.

On Feb 16, 12:26 pm, Howard Schlossberg
<how... (AT) antispahm (DOT) fmprosolutions.com> wrote:
Quote:
Putting aside good naming conventions, your 'Create Spares' script is
set to only duplicate those find requests where $1.0::Cable > 49. But
you've never set that field to anything while you were in find mode. So
it seems you are really trying to test for the field value being >49.
If true, then you're script should probably look like this:

{Create Spares}
GoTo Record [First]
Loop
Duplicate Record
Set Field [$1.0::Cable; ">49"]
Set Field [1.0::Position; "*"]
Set Field [1.0::Number; "*"]
Set Field [1.0:est Pos; "*"]
Set Field [1.0:est Num; "*"]
GoToRecord [Next; Exit After Last]
End Loop
++End of Script++



MammalianF... (AT) gmail (DOT) com wrote:
Hi,
I have a script that duplicates every record in a Find and modifies
the duplicate. At the end, another script runs that duplicates some
records again based on a certain parameter. The problem is that when
the second script runs, it will only duplicate the original records,
not the duplicates, even though the duplicates meet the parameters for
the script.

Basically, the scripts read like this:

{Define Cable}
Perform Script "Find and Sort"
GoTo Record [First]
Loop
Clear; [Select1.0::Cable Note]
Insert Text [Select1.0::Cable Note; "F"]
If [$1.0:irection = 1]
Perform Script "Return Circuit Name and Number"
# This script searches the record for info to copy from a
different field to paste in
Else
Perform Script "Return Previous Position"
#This script searches the previous record for information to
copy and paste in
End If
GoToRecord [Next; Exit After Last]
End Loop
Perform Script "Create Males"
Perform Script "Create Spares"
GoTo Record [First]
++End of Script++

{Create Males}
GoTo Record [First]
Loop
Duplicate Record
Insert Text [Select1.0::Cable Note; "M"]
GoToRecord [Next; Exit After Last]
End Loop
++End of Script++

{Create Spares}
GoTo Record [First]
Loop
If [$1.0::Cable > 49]
Duplicate Record
Insert Text [1.0::Position; "*"]
Insert Text [1.0::Number; "*"]
Insert Text [1.0:est Pos; "*"]
Insert Text [1.0:est Num; "*"]
End If
GoToRecord [Next; Exit After Last]
End Loop
++End of Script++

All the components seem to work individually, but whether run on the
master script or not, Create Spares doesn't work on duplictaed
records.

Thanks for any insight.

Joe

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Schlossberg (818) 883-2846
FM Professional Solutions, Inc. Los Angeles

FileMaker 8 Certified Developer
Associate Member, FileMaker Solutions Alliance



Reply With Quote
  #6  
Old   
Howard Schlossberg
 
Posts: n/a

Default Re: Records and Scripting - 02-16-2007 , 01:54 PM



Fprgive me -- I was under the impression you were still in Find mode,
but I guess you've already done your find and are now creating duplicate
records (not duplicate find requests, which is what I thought you were
doing). I think what threw me off was that you were entering "*" as
data into your fields instead of an actual number or position. (Not
sure what you're trying to do here.)

So as far as that 'spare' script not working, you have:
If [$1.0::Cable > 49]
Was that just a typo (the dollar sign) in your post here or is that
what's actually in the script? If it's a actually in your script, then
that indicates a variable which you have never set. Perhaps that is the
problem.


MammalianFish (AT) gmail (DOT) com wrote:
Quote:
Hey,
I am new to Filemaker and its GUI scripting, so forgive me if it's
still a little crude.
However, I don't want to force all of the copies to have Cable values
of >49. When "Create Males" runs, it makes copies of every record (the
original records are set up to be Females, and the database is used to
create labels for cables). After it runs, I want "Create Spares" to
duplicate both records (male and female) for each cable over 49' long
(and modify them slightly so I know which is the spare). Correct me if
I am wrong, but the code you suggest will end up creating a spare for
every cable in the database.

On Feb 16, 12:26 pm, Howard Schlossberg
how... (AT) antispahm (DOT) fmprosolutions.com> wrote:
Putting aside good naming conventions, your 'Create Spares' script is
set to only duplicate those find requests where $1.0::Cable > 49. But
you've never set that field to anything while you were in find mode. So
it seems you are really trying to test for the field value being >49.
If true, then you're script should probably look like this:

{Create Spares}
GoTo Record [First]
Loop
Duplicate Record
Set Field [$1.0::Cable; ">49"]
Set Field [1.0::Position; "*"]
Set Field [1.0::Number; "*"]
Set Field [1.0:est Pos; "*"]
Set Field [1.0:est Num; "*"]
GoToRecord [Next; Exit After Last]
End Loop
++End of Script++



MammalianF... (AT) gmail (DOT) com wrote:
Hi,
I have a script that duplicates every record in a Find and modifies
the duplicate. At the end, another script runs that duplicates some
records again based on a certain parameter. The problem is that when
the second script runs, it will only duplicate the original records,
not the duplicates, even though the duplicates meet the parameters for
the script.
Basically, the scripts read like this:
{Define Cable}
Perform Script "Find and Sort"
GoTo Record [First]
Loop
Clear; [Select1.0::Cable Note]
Insert Text [Select1.0::Cable Note; "F"]
If [$1.0:irection = 1]
Perform Script "Return Circuit Name and Number"
# This script searches the record for info to copy from a
different field to paste in
Else
Perform Script "Return Previous Position"
#This script searches the previous record for information to
copy and paste in
End If
GoToRecord [Next; Exit After Last]
End Loop
Perform Script "Create Males"
Perform Script "Create Spares"
GoTo Record [First]
++End of Script++
{Create Males}
GoTo Record [First]
Loop
Duplicate Record
Insert Text [Select1.0::Cable Note; "M"]
GoToRecord [Next; Exit After Last]
End Loop
++End of Script++
{Create Spares}
GoTo Record [First]
Loop
If [$1.0::Cable > 49]
Duplicate Record
Insert Text [1.0::Position; "*"]
Insert Text [1.0::Number; "*"]
Insert Text [1.0:est Pos; "*"]
Insert Text [1.0:est Num; "*"]
End If
GoToRecord [Next; Exit After Last]
End Loop
++End of Script++
All the components seem to work individually, but whether run on the
master script or not, Create Spares doesn't work on duplictaed
records.
Thanks for any insight.
Joe
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Schlossberg (818) 883-2846
FM Professional Solutions, Inc. Los Angeles

FileMaker 8 Certified Developer
Associate Member, FileMaker Solutions Alliance


--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Schlossberg (818) 883-2846
FM Professional Solutions, Inc. Los Angeles

FileMaker 8 Certified Developer
Associate Member, FileMaker Solutions Alliance


Reply With Quote
  #7  
Old   
MammalianFish@gmail.com
 
Posts: n/a

Default Re: Records and Scripting - 02-16-2007 , 02:00 PM



Well, that's what everyone seems to think, but when I try to remove
it, I get an error saying "The specified table cannot be
found." (There is only one table in the DB.) I'm new to fmp, but I am
an old hand at VBA. What does the $ operator mean? If all it does is
define a variable, why can't I delete it since I am in a specific
record looking at a specific field?

Also, the "*" is an insert, not a replace, so the value then ends with
*, and is not replaced by it. It's mostly a visual and sorting flag so
I can determine which records are the spares.

Thanks for your [continued] help.
jf


On Feb 16, 2:54 pm, Howard Schlossberg
<how... (AT) antispahm (DOT) fmprosolutions.com> wrote:
Quote:
Fprgive me -- I was under the impression you were still in Find mode,
but I guess you've already done your find and are now creating duplicate
records (not duplicate find requests, which is what I thought you were
doing). I think what threw me off was that you were entering "*" as
data into your fields instead of an actual number or position. (Not
sure what you're trying to do here.)

So as far as that 'spare' script not working, you have:
If [$1.0::Cable > 49]
Was that just a typo (the dollar sign) in your post here or is that
what's actually in the script? If it's a actually in your script, then
that indicates a variable which you have never set. Perhaps that is the
problem.



MammalianF... (AT) gmail (DOT) com wrote:
Hey,
I am new to Filemaker and its GUI scripting, so forgive me if it's
still a little crude.
However, I don't want to force all of the copies to have Cable values
of >49. When "Create Males" runs, it makes copies of every record (the
original records are set up to be Females, and the database is used to
create labels for cables). After it runs, I want "Create Spares" to
duplicate both records (male and female) for each cable over 49' long
(and modify them slightly so I know which is the spare). Correct me if
I am wrong, but the code you suggest will end up creating a spare for
every cable in the database.

On Feb 16, 12:26 pm, Howard Schlossberg
how... (AT) antispahm (DOT) fmprosolutions.com> wrote:
Putting aside good naming conventions, your 'Create Spares' script is
set to only duplicate those find requests where $1.0::Cable > 49. But
you've never set that field to anything while you were in find mode. So
it seems you are really trying to test for the field value being >49.
If true, then you're script should probably look like this:

{Create Spares}
GoTo Record [First]
Loop
Duplicate Record
Set Field [$1.0::Cable; ">49"]
Set Field [1.0::Position; "*"]
Set Field [1.0::Number; "*"]
Set Field [1.0:est Pos; "*"]
Set Field [1.0:est Num; "*"]
GoToRecord [Next; Exit After Last]
End Loop
++End of Script++

MammalianF... (AT) gmail (DOT) com wrote:
Hi,
I have a script that duplicates every record in a Find and modifies
the duplicate. At the end, another script runs that duplicates some
records again based on a certain parameter. The problem is that when
the second script runs, it will only duplicate the original records,
not the duplicates, even though the duplicates meet the parameters for
the script.
Basically, the scripts read like this:
{Define Cable}
Perform Script "Find and Sort"
GoTo Record [First]
Loop
Clear; [Select1.0::Cable Note]
Insert Text [Select1.0::Cable Note; "F"]
If [$1.0:irection = 1]
Perform Script "Return Circuit Name and Number"
# This script searches the record for info to copy from a
different field to paste in
Else
Perform Script "Return Previous Position"
#This script searches the previous record for information to
copy and paste in
End If
GoToRecord [Next; Exit After Last]
End Loop
Perform Script "Create Males"
Perform Script "Create Spares"
GoTo Record [First]
++End of Script++
{Create Males}
GoTo Record [First]
Loop
Duplicate Record
Insert Text [Select1.0::Cable Note; "M"]
GoToRecord [Next; Exit After Last]
End Loop
++End of Script++
{Create Spares}
GoTo Record [First]
Loop
If [$1.0::Cable > 49]
Duplicate Record
Insert Text [1.0::Position; "*"]
Insert Text [1.0::Number; "*"]
Insert Text [1.0:est Pos; "*"]
Insert Text [1.0:est Num; "*"]
End If
GoToRecord [Next; Exit After Last]
End Loop
++End of Script++
All the components seem to work individually, but whether run on the
master script or not, Create Spares doesn't work on duplictaed
records.
Thanks for any insight.
Joe
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Schlossberg (818) 883-2846
FM Professional Solutions, Inc. Los Angeles

FileMaker 8 Certified Developer
Associate Member, FileMaker Solutions Alliance

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Schlossberg (818) 883-2846
FM Professional Solutions, Inc. Los Angeles

FileMaker 8 Certified Developer
Associate Member, FileMaker Solutions Alliance



Reply With Quote
  #8  
Old   
Howard Schlossberg
 
Posts: n/a

Default Re: Records and Scripting - 02-16-2007 , 02:22 PM



You need to go to the relation graph and change the name of the table
occurrence so that it does not begin with a dollar sign. This should be
an illegal character to start a TO or field name with. Once you make
the modification there, then you should be able to go back to your
script and see that it has (possibly) also been removed from there. If
it wasn't automaticvally removed from there, then you should now be
able to manually remove it or at least select the correct
relationship/field name from the dropdown lists.

One $ indicates a local variable. Two $$ indicates a global variable.

MammalianFish (AT) gmail (DOT) com wrote:
Quote:
Well, that's what everyone seems to think, but when I try to remove
it, I get an error saying "The specified table cannot be
found." (There is only one table in the DB.) I'm new to fmp, but I am
an old hand at VBA. What does the $ operator mean? If all it does is
define a variable, why can't I delete it since I am in a specific
record looking at a specific field?

Also, the "*" is an insert, not a replace, so the value then ends with
*, and is not replaced by it. It's mostly a visual and sorting flag so
I can determine which records are the spares.

Thanks for your [continued] help.
jf


On Feb 16, 2:54 pm, Howard Schlossberg
how... (AT) antispahm (DOT) fmprosolutions.com> wrote:
Fprgive me -- I was under the impression you were still in Find mode,
but I guess you've already done your find and are now creating duplicate
records (not duplicate find requests, which is what I thought you were
doing). I think what threw me off was that you were entering "*" as
data into your fields instead of an actual number or position. (Not
sure what you're trying to do here.)

So as far as that 'spare' script not working, you have:
If [$1.0::Cable > 49]
Was that just a typo (the dollar sign) in your post here or is that
what's actually in the script? If it's a actually in your script, then
that indicates a variable which you have never set. Perhaps that is the
problem.



MammalianF... (AT) gmail (DOT) com wrote:
Hey,
I am new to Filemaker and its GUI scripting, so forgive me if it's
still a little crude.
However, I don't want to force all of the copies to have Cable values
of >49. When "Create Males" runs, it makes copies of every record (the
original records are set up to be Females, and the database is used to
create labels for cables). After it runs, I want "Create Spares" to
duplicate both records (male and female) for each cable over 49' long
(and modify them slightly so I know which is the spare). Correct me if
I am wrong, but the code you suggest will end up creating a spare for
every cable in the database.
On Feb 16, 12:26 pm, Howard Schlossberg
how... (AT) antispahm (DOT) fmprosolutions.com> wrote:
Putting aside good naming conventions, your 'Create Spares' script is
set to only duplicate those find requests where $1.0::Cable > 49. But
you've never set that field to anything while you were in find mode. So
it seems you are really trying to test for the field value being >49.
If true, then you're script should probably look like this:
{Create Spares}
GoTo Record [First]
Loop
Duplicate Record
Set Field [$1.0::Cable; ">49"]
Set Field [1.0::Position; "*"]
Set Field [1.0::Number; "*"]
Set Field [1.0:est Pos; "*"]
Set Field [1.0:est Num; "*"]
GoToRecord [Next; Exit After Last]
End Loop
++End of Script++
MammalianF... (AT) gmail (DOT) com wrote:
Hi,
I have a script that duplicates every record in a Find and modifies
the duplicate. At the end, another script runs that duplicates some
records again based on a certain parameter. The problem is that when
the second script runs, it will only duplicate the original records,
not the duplicates, even though the duplicates meet the parameters for
the script.
Basically, the scripts read like this:
{Define Cable}
Perform Script "Find and Sort"
GoTo Record [First]
Loop
Clear; [Select1.0::Cable Note]
Insert Text [Select1.0::Cable Note; "F"]
If [$1.0:irection = 1]
Perform Script "Return Circuit Name and Number"
# This script searches the record for info to copy from a
different field to paste in
Else
Perform Script "Return Previous Position"
#This script searches the previous record for information to
copy and paste in
End If
GoToRecord [Next; Exit After Last]
End Loop
Perform Script "Create Males"
Perform Script "Create Spares"
GoTo Record [First]
++End of Script++
{Create Males}
GoTo Record [First]
Loop
Duplicate Record
Insert Text [Select1.0::Cable Note; "M"]
GoToRecord [Next; Exit After Last]
End Loop
++End of Script++
{Create Spares}
GoTo Record [First]
Loop
If [$1.0::Cable > 49]
Duplicate Record
Insert Text [1.0::Position; "*"]
Insert Text [1.0::Number; "*"]
Insert Text [1.0:est Pos; "*"]
Insert Text [1.0:est Num; "*"]
End If
GoToRecord [Next; Exit After Last]
End Loop
++End of Script++
All the components seem to work individually, but whether run on the
master script or not, Create Spares doesn't work on duplictaed
records.
Thanks for any insight.
Joe
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Schlossberg (818) 883-2846
FM Professional Solutions, Inc. Los Angeles
FileMaker 8 Certified Developer
Associate Member, FileMaker Solutions Alliance
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Schlossberg (818) 883-2846
FM Professional Solutions, Inc. Los Angeles

FileMaker 8 Certified Developer
Associate Member, FileMaker Solutions Alliance


--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Schlossberg (818) 883-2846
FM Professional Solutions, Inc. Los Angeles

FileMaker 8 Certified Developer
Associate Member, FileMaker Solutions Alliance


Reply With Quote
  #9  
Old   
Grip
 
Posts: n/a

Default Re: Records and Scripting - 02-16-2007 , 03:49 PM



Welcome to Filemaker. Have you created this db from scratch or have
you inherited it?

I'm confused about the error message you're getting. In FM, you have
tables which contain fields, and you have table occurances (TOs) which
are representations of table. So, you can have one table, but
different occurances of it in your relationship graph (with different
names). Assuming you only have 1 TO of your 1 table, what is it
named? It looks like (based on other fields in the script) that it is
named 1.0, so removing the $ should work, if the field Cable exists in
that table. Regardless, instead of removing the $ from the field, you
should select the appropriate field from the list of fields presented
in the calculation box.


Also:
Instead of using * in the field, I would create a new field named
"Spares" of type number and set that to 1 for the spares and empty for
non-spares. You can manipulate that field much easier than one with
an asterisk in a text field that is already serving a purpose. If you
insist on using the flag, I would still use Set Field(fieldName) =
fieldName & "*"

Another tip is instead of going through each record and testing to see
if the length meets you're criteria, and then duplicating, you can do
a find on all records pulling a set of the ones with your specified
length and duplicate those, eliminating the If statement.


G

On Feb 16, 1:00 pm, MammalianF... (AT) gmail (DOT) com wrote:
Quote:
Well, that's what everyone seems to think, but when I try to remove
it, I get an error saying "The specified table cannot be
found." (There is only one table in the DB.) I'm new to fmp, but I am
an old hand at VBA. What does the $ operator mean? If all it does is
define a variable, why can't I delete it since I am in a specific
record looking at a specific field?

Also, the "*" is an insert, not a replace, so the value then ends with
*, and is not replaced by it. It's mostly a visual and sorting flag so
I can determine which records are the spares.

Thanks for your [continued] help.
jf

On Feb 16, 2:54 pm, Howard Schlossberg

how... (AT) antispahm (DOT) fmprosolutions.com> wrote:
Fprgive me -- I was under the impression you were still in Find mode,
but I guess you've already done your find and are now creating duplicate
records (not duplicate find requests, which is what I thought you were
doing). I think what threw me off was that you were entering "*" as
data into your fields instead of an actual number or position. (Not
sure what you're trying to do here.)

So as far as that 'spare' script not working, you have:
If [$1.0::Cable > 49]
Was that just a typo (the dollar sign) in your post here or is that
what's actually in the script? If it's a actually in your script, then
that indicates a variable which you have never set. Perhaps that is the
problem.

MammalianF... (AT) gmail (DOT) com wrote:
Hey,
I am new to Filemaker and its GUI scripting, so forgive me if it's
still a little crude.
However, I don't want to force all of the copies to have Cable values
of >49. When "Create Males" runs, it makes copies of every record (the
original records are set up to be Females, and the database is used to
create labels for cables). After it runs, I want "Create Spares" to
duplicate both records (male and female) for each cable over 49' long
(and modify them slightly so I know which is the spare). Correct me if
I am wrong, but the code you suggest will end up creating a spare for
every cable in the database.

On Feb 16, 12:26 pm, Howard Schlossberg
how... (AT) antispahm (DOT) fmprosolutions.com> wrote:
Putting aside good naming conventions, your 'Create Spares' script is
set to only duplicate those find requests where $1.0::Cable > 49. But
you've never set that field to anything while you were in find mode. So
it seems you are really trying to test for the field value being >49.
If true, then you're script should probably look like this:

{Create Spares}
GoTo Record [First]
Loop
Duplicate Record
Set Field [$1.0::Cable; ">49"]
Set Field [1.0::Position; "*"]
Set Field [1.0::Number; "*"]
Set Field [1.0:est Pos; "*"]
Set Field [1.0:est Num; "*"]
GoToRecord [Next; Exit After Last]
End Loop
++End of Script++

MammalianF... (AT) gmail (DOT) com wrote:
Hi,
I have a script that duplicates every record in a Find and modifies
the duplicate. At the end, another script runs that duplicates some
records again based on a certain parameter. The problem is that when
the second script runs, it will only duplicate the original records,
not the duplicates, even though the duplicates meet the parameters for
the script.
Basically, the scripts read like this:
{Define Cable}
Perform Script "Find and Sort"
GoTo Record [First]
Loop
Clear; [Select1.0::Cable Note]
Insert Text [Select1.0::Cable Note; "F"]
If [$1.0:irection = 1]
Perform Script "Return Circuit Name and Number"
# This script searches the record for info to copy from a
different field to paste in
Else
Perform Script "Return Previous Position"
#This script searches the previous record for information to
copy and paste in
End If
GoToRecord [Next; Exit After Last]
End Loop
Perform Script "Create Males"
Perform Script "Create Spares"
GoTo Record [First]
++End of Script++
{Create Males}
GoTo Record [First]
Loop
Duplicate Record
Insert Text [Select1.0::Cable Note; "M"]
GoToRecord [Next; Exit After Last]
End Loop
++End of Script++
{Create Spares}
GoTo Record [First]
Loop
If [$1.0::Cable > 49]
Duplicate Record
Insert Text [1.0::Position; "*"]
Insert Text [1.0::Number; "*"]
Insert Text [1.0:est Pos; "*"]
Insert Text [1.0:est Num; "*"]
End If
GoToRecord [Next; Exit After Last]
End Loop
++End of Script++
All the components seem to work individually, but whether run on the
master script or not, Create Spares doesn't work on duplictaed
records.
Thanks for any insight.
Joe
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Schlossberg (818) 883-2846
FM Professional Solutions, Inc. Los Angeles

FileMaker 8 Certified Developer
Associate Member, FileMaker Solutions Alliance

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Schlossberg (818) 883-2846
FM Professional Solutions, Inc. Los Angeles

FileMaker 8 Certified Developer
Associate Member, FileMaker Solutions Alliance



Reply With Quote
  #10  
Old   
Helpful Harry
 
Posts: n/a

Default Re: Records and Scripting - 02-16-2007 , 04:48 PM



In article <1171656026.242356.314190 (AT) s48g2000cws (DOT) googlegroups.com>,
MammalianFish (AT) gmail (DOT) com wrote:

Quote:
Well, that's what everyone seems to think, but when I try to remove
it, I get an error saying "The specified table cannot be
found." (There is only one table in the DB.) I'm new to fmp, but I am
an old hand at VBA. What does the $ operator mean? If all it does is
define a variable, why can't I delete it since I am in a specific
record looking at a specific field?

Also, the "*" is an insert, not a replace, so the value then ends with
*, and is not replaced by it. It's mostly a visual and sorting flag so
I can determine which records are the spares.

Thanks for your [continued] help.
jf
As well as the $ symbol others have mentioned, the * is also a special
symbol within FileMaker's Find mode, so if you're trying to find fields
with a * you MAY hit a problem (I haven't tested it).

As well as being the muliplication mathematical operator, the *
character in Find mode means "zero or more characters". If you perform
a Find on using "xyz*" on a field, then you will find records where
that fields contains anything like:

"xyz"
"xzy1"
"xyzabc"

It should also find "xyz*" and may not partly be the cause you the
problem here, but it's probably not a good thing to use since it might
cause problem laters if you want to find JUST the "xyz*" records. You
might be better to use # instead, or perhaps even better tag " - Spare"
on the end.


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


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.