How to programmatically copy an object from one form to another?

How do I write code to copy an object from one form and paste it into another?

You have to know the name of the object or the id of the object you want to copy to the other form. Here is code that will copy the MyObject object on the Test1 form and recreate it on the Test2 form. Neither form needs to be in graphics mode for this to work.

let objectBP=""
formobjectblueprint "", "Test1", "MyObject", objectBP
goform"Test2"
execute objectBP

Thanks Gary, I’ll check that out.

I also need to know how to delete a form. I can delete a procedure using this code:

setprocedureoptions "","MyProcedure","DELETE",""

so I thought this would work:

setformoptions "","MyForm","DELETE",""

but it doesn’t.

OK, it didn’t work because the form to be deleted wasn’t the active form.

It not only does not have to be the active form, it does not even have to be open.

That’s odd. I’m strapped for time at the moment (moving house whilst writing code - or should that be the other way around?) so I’ll check it later. For the moment, I have code that works.

The one thing I can think of why it didn’t work with the code you listed is that there was another database active at the time so the database parameter you had of “” was the wrong database for the form.

You really have an eye for this stuff Gary - that’s exactly what it was - I had a secret database which for reasons best known to itself wouldn’t close.