Jump to content

Copy/Paste Oddities


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

Recommended Posts

I have a script that copies a field in one table and pastes it into another corrisponding field in another table. However, the copy does not always seem to work. About 50% of the time, it pastes what ever is in the clipboard. Has anyone experienced something like this?

My scripts are set up as follows: (Really the steps in RED are the ones I'm having bugs with, but I'll post the whole thing).

Thanks,

Bronwyn

Create New VFX Scan•

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

Pause/Resume Script [ Duration (seconds)}:( .25 ]

[color:red]Copy [ Codebook_DB::Key Number Start ] [ Select ]

Commit Records/Requests [ Skip data entry validation; No dialog ]

Perform Script [ “Create New Scan•” ]

Create New Scan•

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

Go to Layout [ “Scans_DB Scan Counts” (VFX Scan_Counts_DB) ]

New Record/Request

[color:red]Paste [ VFX Scan_Counts_DB::Key Number ] [ Select; No style ]

Perform Find/Replace [ Find: VFX Scan_Counts_DB::Key Feet; Replace: Codebook_DB::Key Feet; Search operation: Replace; Search settings: Forward; Search across: Current record/request; Search within: Current field ] [ No dialog ]

Perform Find/Replace [ Find: VFX Scan_Counts_DB::Scene; Replace: Codebook_DB::Scene; Search operation: Replace; Search settings: Forward; Search across: Current record/request; Search within: Current field ] [ No dialog ]

Perform Find/Replace [ Find: VFX Scan_Counts_DB::Take; Replace: Codebook_DB::Take; Search operation: Replace; Search settings: Forward; Search across: Current record/request; Search within: Current field ] [ No dialog ]

Perform Find/Replace [ Find: VFX Scan_Counts_DB::Shoot Date; Replace: Codebook_DB::Shoot Date; Search operation: Replace; Search settings: Forward; Search across: Current record/request; Search within: Current field ] [ No dialog ]

Perform Find/Replace [ Find: VFX Scan_Counts_DB::Camera Roll; Replace: Codebook_DB::Camera Roll; Search operation: Replace; Search settings: Forward; Search across: Current record/request; Search within: Current field ] [ No dialog ]

Perform Find/Replace [ Find: VFX Scan_Counts_DB::Lab Roll; Replace: Codebook_DB::Lab Roll; Search operation: Replace; Search settings: Forward; Search across: Current record/request; Search within: Current field ] [ No dialog ]

Perform Find/Replace [ Find: VFX Scan_Counts_DB::Lites; Replace: Codebook_DB::Lites; Search operation: Replace; Search settings: Forward; Search across: Current record/request; Search within: Current field ] [ No dialog ]

Perform Find/Replace [ Find: VFX Scan_Counts_DB::FPS; Replace: Codebook_DB::FPS; Search operation: Replace; Search settings: Forward; Search across: Current record/request; Search within: Current field ] [ No dialog ]

Perform Find/Replace [ Find: VFX Scan_Counts_DB::Description; Replace: Codebook_DB::Description; Search operation: Replace; Search settings: Forward; Search across: Current record/request; Search within: Current field ] [ No dialog ]

Perform Find/Replace [ Find: VFX Scan_Counts_DB::Film Type; Replace: Codebook_DB::Film Type; Search operation: Replace; Search settings: Forward; Search across: Current record/request; Search within: Current field ] [ No dialog ]

Set Field [ Scan_Counts to JPGS::Scan JPEG; Codebook JPGS::JPG Thumbnail ]

Commit Records/Requests [ Skip data entry validation; No dialog ]

Go to Field [ VFX Scan_Counts_DB::VFX Sequence ]

Show Custom Dialog [ Title: "Message"; Message: "Please enter a new VFX Number and hit Continue. If this is a multiple element shot, hit Cancel after creating the first element."; Buttons: “OK”, “Cancel” ]

Pause/Resume Script [ Indefinitely ]

Perform Script [ “Export to Shot Tracker” ]

Commit Records/Requests [ Skip data entry validation; No dialog ]

Export to Shot Tracker

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

Go to Field [ VFX Scan_Counts_DB::Scan Counts Record ID ] [ Select/perform ]

Copy [ VFX Scan_Counts_DB::Scan Counts Record ID ] [ Select ]

Perform Script [ “Create VFX Shot •” from file: “Shot Tracker” ]

Create VFX Shot •

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

Go to Layout [ “LIST VIEW” (Shot Tracker) ]

New Record/Request

Paste [ Shot Tracker::Scan Counts Record ID ] [ Select; No style ]

Pause/Resume Script [ Duration (seconds): 0 ]

Insert Calculated Result [ Shot Tracker::VFX Seq; Scan_Counts_DB: Record ID::VFX Sequence ] [ Select ]

Insert Calculated Result [ Shot Tracker::VFX Scene; Scan_Counts_DB: Record ID::VFX Scene ] [ Select ]

Insert Calculated Result [ Shot Tracker::VFX Number; Scan_Counts_DB: Record ID::VFX Number ] [ Select ]

Insert Calculated Result [ Shot Tracker::VFX Sequence Name; Scan_Counts_DB: Record ID::VFX Sequence Name ] [ Select ]

Insert Calculated Result [ Shot Tracker::Vendor; Scan_Counts_DB: Record ID::Vendor ] [ Select ]

Exit Script [ ]

Link to comment
Share on other sites

Don't use Copy and Paste for a lot of reasons: One, you destroy what the user had previous copied to the clipboard. Two, you need to be on the layout that has the field you want to paste into. Instead, use Set Field which will always work.

Steve

Link to comment
Share on other sites

Actually, I've found a fix for it. Just took some experimenting...

I figured out that the layout needs to have the field in it that I intend to copy. Now why that didn't work before (the original layout did have it) I don't know...

I still would be interested in knowing what you ment by script pramiter though.

Here is my revised script:

Create New Scan•

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

Go to Layout [ “CB_All” (Codebook_DB) ]

Copy [ Codebook_DB::Key Number Start ] [ Select ]

Go to Layout [ “Scans_DB Scan Counts” (VFX Scan_Counts_DB) ]

New Record/Request

Paste [ VFX Scan_Counts_DB::Key Number ] [ Select; No style ]

Set Field [ VFX Scan_Counts_DB::Key Feet; Codebook_DB::Key Feet ]

Set Field [ VFX Scan_Counts_DB::Scene; Codebook_DB::Scene ]

Set Field [ VFX Scan_Counts_DB::Take; Codebook_DB::Take ]

Set Field [ VFX Scan_Counts_DB::Shoot Date; Codebook_DB::Shoot Date ]

Set Field [ VFX Scan_Counts_DB::Camera Roll; Codebook_DB::Camera Roll ]

Set Field [ VFX Scan_Counts_DB::Lab Roll; Codebook_DB::Lab Roll ]

Set Field [ VFX Scan_Counts_DB::Lites; Codebook_DB::Lites ]

Set Field [ VFX Scan_Counts_DB::FPS; Codebook_DB::FPS ]

Set Field [ VFX Scan_Counts_DB::Description; Codebook_DB::Description ]

Set Field [ VFX Scan_Counts_DB::Film Type; Codebook_DB::Film Type ]

Go to Field [ VFX Scan_Counts_DB::VFX Sequence ]

Show Custom Dialog [ Title: "Message"; Message: "Please enter a new VFX Number and hit Continue. If this is a multiple element

shot, hit Cancel after creating the first element."; Buttons: “OK”, “Cancel” ]

Pause/Resume Script [ Indefinitely ]

Perform Script [ “Export to Shot Tracker” ]

Link to comment
Share on other sites

Well, it WILL work without cut and paste, that's why people are trying to help you with with this. You are making absolutely tons of extra work for yourself. Also, I see you are on a Mac and if you set things up properly, you can do it with a single applescript statement:

If you're in a layout based on table "A":

set theData to (get data current record)

go to layout "B"

create new record with data theData

ALL the fields will be populated in one shot.

But even with standard scripting, you can use script variables and save yourself a ton of effort. That's the sort of thing people with advanced FileMaker skills do easily.

Link to comment
Share on other sites

It appears that you are unnecessarily setting 10 fields in VFX Scan_Counts_DB. Script parameter: When button is clicked at the start, the Codebook_DB::Key Number can be placed in a script parameter to transfer the key to VFX Scan_Counts_DB, something like:

Go To Layout [ based upon VFX Scan_Counts_DB ]

New Record Request

Set Field [ VFX Scan_Counts_DB::Key Number ; Get ( ScriptParameter) ]

Commit Records/Requests

All of the other fields in VFX Scan_Counts_DB can be simply displayed through the new relationship you just established. Why have duplicate fields? If required (for legacy purposes, ie, must be set in time, such as a pricing field which may change) then each of those field definitions can be Auto-Enter or Lookup. Only the unique ID needs to be set after a record creation; the rest can be handled automatically.

It is also unnecessary to 'Go To Field [ VFX Scan_Counts_DB::VFX Sequence ] just to accept Custom Dialog input of the new VFX Number. You also don't have a test after the Custom Dialog to determine whether the User wanted to continue or cancel. And an Exit Script[] is not required at the end of a script. It appears that 80% of your script-steps (in every one of your scripts) aren't really needed at all. Other than that it looks okay. :wink2:

Link to comment
Share on other sites

Bruce,

I appreciate your help, I really do. But please do not sound condescending while you give it, please. As I had said, I did try to use the script step set field, however as no relationship has been established, there is no source field to set from.

As to your applescript, I would be interested in exploring it, but my skills are pretty weak in that department. I will have to do some R&D and figure it out. I'm sure that there is a better way of doing this. And your help is very much appreciated :)

LaRetta,

The reason I need to duplicate the fields in the new table is that I use them calculations in a database unrelated to the original source database. Nor do I want to do an auto enter from my Codebook, because not all records become scans.

To explain the need behind my database, I work in feature film. My Codebook_DB has a record for every take ever shot for a film. The VFX Scan_Counts_DB draws information from the Codebook_DB when a shot is scanned for Visual Effects (VFX). Each scanned shot is assigned a VFX Number, which is not unique. These two Databases exist within the same file as separate tables.

I then have a separate database called Shot Tracker which tracks each scan by their VFX Number. Each VFX Number may have multiple elements and revisions, so I draw from the VFX_Scan_Counts through portals to see every related record for a given shot. Once a shot becomes a VFX, it is now a new element which has no relationship to the original source material from the Codebook_DB.

I also use the script step: 'Go To Field [ VFX Scan_Counts_DB::VFX Sequence ] because that is the first field of data entry, and eliminates a mouse click.

Thank you so much for your suggestions, both of you. I really love filemaker, and I think this forum is fantastic for making us all that much closer to being "people with advanced FileMaker skills:! :

Sincerely,

Bronwyn

Link to comment
Share on other sites

Hi Bronwyn,

"I use them calculations in a database unrelated to the original source database. "

Your script starts:

Copy [ Codebook_DB::Key Number Start ] [ Select ]

Go to Layout [ “Scans_DB Scan Counts” (VFX Scan_Counts_DB) ]

New Record/Request

Paste [ VFX Scan_Counts_DB::Key Number ] [ Select; No style ]

Why are you pasting the key if it doesn't relate? Then you Perform Find/Replace based upon the same fields from Codebook_DB. You are, in fact, using a relationship anyway, are you not? If you need to filter it further, based upon other criteria as well ... well, that's what additional table occurrences are for.

With vs. 8, variables can be used (for transfering data).

If they are not related (regardless of what your script apprears to indicate), then it might be of benefit to establish another table occurrence and MAKE a relationship based upon your scripting needs and then pull the values or set the fields. The script I've outlined would do just that. And you can write multiple criteria to script parameters as well ... pick up all your values then tango on to your next table and parse them into the fields.

There are certainly better (faster and more efficient) ways than using Perform Find/Replace. And a relationship can assist in the data transfer/viewing/lookups/auto-enter. That's the purpose of using keys - you take the key with you and you can unlock all doors. :wink2:

BTW, I believe the script above in which you attempted to use Set Field[] failed because you created your new record but didn't COMMIT it before you began to set it with related data (see my script for example). You don't want to use copy/paste for this! This is why the script parameter was suggested.

LaRetta

Link to comment
Share on other sites

LaRetta,

They are related in the sence that the information in the Codebook_DB is the source of a new record in the Scan_Counts_DB. But, only as a source. The new record is used in the calculations I mentioned. I have since modified my script to use set field rather than find/replace. If there is a better method, I'm all ears. I am still figuring out all of the new things v8 Advanced can do, and I have not yet explored the variables you mentioned. What exactly can they do?

Thanks!!!!! And I'll check out what you posted too.

Bronwyn

Link to comment
Share on other sites

"I think a whole new way of scripting just opened up to me!"

I'm tickled it helped but it was originally suggested by two or three others prior to my persistent attempt. :yep:

Your post doesn't indicate vs. 8 but you'd be even more free'd if you moved up so variables (and many other features) are in your toolkit. You can have a script set many variables at the start (like all those values you need to take elsewhere) as:

Set Variable [ $Key Feet; Value: Codebook_DB::Key Feet ]

Set Variable [ ... etc

... with variables it's like discovering cordless phones for the first time - you'll keep thinking you are attached (and held down) and you'll forget you are now free to move anywhere!! Parsing script parameters is no longer necessary (although sometimes they are still valuable). Variables were also mentioned above but I let that go since you showed vs. 7. Set Field[] is my most cherished script step and the best option (as Bruce and Steve indicated as well). I RARELY put data in a field any other way. You can set the fields with local or global variables (and with calculations) and you can use globals to establish relationships if (and when) you need them - again feeding the globals with variables using Set Field[] and always follow a new record (when establishing a relationship) with a COMMIT.

Script parameters were a bit of a pain ... sometimes I would duplicate buttons or delete buttons and then forget to re-specify the correct parameter. But with variables, those limits are lifted. Try this: Remove the script parameter attached to the button (only the parameter portion in the bottom in the Specify Button). Change your script to something like:

Go to Layout [ “CB_All” (Codebook_DB) ]

Set Variable [ $Key Number ; Value: Codebook_DB::Key Number ]

Set Variable [ $Key Feet ; Value: Codebook_DB::Key Feet ]

... place all your fields to tranfer into variables like this ...

Go to Layout [ “Scans_DB Scan Counts” (VFX Scan_Counts_DB) ]

New Record/Request

Set Field [ VFX Scan_Counts_DB::Key Number ; $Key Number ]

Set Field [ VFX Scan_Counts_DB::Key Feet; $Key Feet ]

... set each field with the associated variable you grabbed earlier ...

* Added bonus. If you preceed the variable name with $$ instead of $, it will persist after the script ends (until file is closed). So when your User executes another script, you don't have to capture the values again - just refer to their global variable. Search here on Forums for some great examples of their power.

I am just at the stage of realizing the phone cord isn't hooked any more... :giggle:

LaRetta

Link to comment
Share on other sites

LaRetta,

I see now that the script parameters were mentioned earlier, but I didn't understand... Thank you for being persistent. I upgraded to v8 Advanced a few months ago, and have not yet finished looking under the hood. I don't make Databases for a living, but my living depends on the databases I create, if that makes sense. It took me almost 6 months to figure out v7!

I will need to explore the Set Variable, but first I need to imagine where I would use it... :) Since the Get (Script Parameters) works so well, and updates all the fields I need without having to list them, I don't see why I would use the Set Variable in this instance, since it appears that I would have to go back and list each field. Unless it is to just check out how it works, that is. I think Filemaker is getting too big for my pea brain! Thank you again for all of your help, I really appreciate it.

My new streamlined script is:

Create New Scan• Script Parameters

Go to Layout [ “Scans_DB Scan Counts” (VFX Scan_Counts_DB) ]

New Record/Request

Set Field [ VFX Scan_Counts_DB::Key Number; Get ( ScriptParameter ) ]

Commit Records/Requests [ No dialog ]

Show Custom Dialog [ Title: "Enter in the VFX Number"; Buttons: “OK”, “Cancel” ]

Pause/Resume Script [ Indefinitely ]

Perform Script [ “Create VFX Shot •” from file: “Shot Tracker” ]

Works like a charm!

Bronwyn

Link to comment
Share on other sites

Excellent streamline!

My example with the variables was mostly to give you an idea ... so that even if you DIDN'T have a relationship, you could load your variables from the originating DB with all the required values instead of loading one script parameter with an array of the values (and then parsing them at the other end). Variables can also replace globals whose only purpose was to assist scripts in increment-counting. I'm removing some globals and script parameters and relationships! vs. 8 will help you streamline your solution.

But you'll discover all of that as you work more with vs. 8 - just as I am. :wink2:

Link to comment
Share on other sites

This topic is 5732 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
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.