August 19, 200619 yr FMP8A on Windows XP There's probably an answer to this somewhere on the forum, but I've looked and can't find it. Problem: I'm trying to copy and paste four fields from an existing record in table "A" to a new record in (unrelated)table "B" via a script. Copy and paste seems to work fine but I'm wondering if there is a more elegant/appropriate method that would achieve the same results? I experimented with Set Field but I guess I don't know enough about it. TIA LM
August 19, 200619 yr If the tables are truly unrelated, you might want to use script variables. Something like: Set Variable [$$First; Value:TableA::Field1] Set Variable [$$Second; Value:TableA::Field2] Set Variable [$$Third; Value:TableA::Field3] Set Variable [$$Fourth; Value:TableA::Field4] Set Field [TableB::Field1; $$First] Set Field [TableB::Field2; $$Second] Set Field [TableB::Field3; $$Third] Set Field [TableB::Field4; $$Fourth] Edited August 19, 200619 yr by Guest Made variables global
August 19, 200619 yr When you use set field script you should have a global field. or a vriable Script colud be like this set filed [TableA::Filed; global field] Got lay out set field [table B::field; global field Go to layout[original] Edited August 19, 200619 yr by Guest
August 19, 200619 yr Get to know the Set Field command. It is one of the most commonly used commands in the world of FM. I would bet that most experienced developers rarely if ever use copy/cut and paste. I hardly ever find a reason to use it myself. Edited August 19, 200619 yr by Guest
August 20, 200619 yr Perhaps Ted it would make more sense if you told why developers avoid it? The reason is that Copy/Paste should be reserved for inter applicational movements of data, while the avarage scripts hardly ever falls in that category. Worstcase scenario is the user having stored something to paste later, the script will then make it evaporate into thin air by overwriting. I regard it as a bad developer habit to use copy/paste at all in scripts. If the user might grap something for other applications should it be done deliberately by hand! --sd
August 22, 200619 yr If you have FM8, K1200's method is good, but if you're doing the whole process in one script, use script variables, not globals. (I.e. use $, not $$.) Script variables disappear once your script is done, which means one less thing to have to manage. Also note that if you're moving data from one file to another, global variables won't help, as they are file-specific. At any rate, LM is using FM7, so he can't use variables. But as sherif pointed out, you can do the same thing using global fields instead of $$First, $$Second etc. Edited August 23, 200619 yr by Guest Oops... I just noticed that your profile says FM7 but your question was using FM8, so yes, variables would work just fine.
Create an account or sign in to comment