Renaming procedures

Can procedures be renamed programmatically?

I don’t know of a way to directly rename a procedure with a program, but you could create a new procedure and give it the same text. Here is one way to do that:

local lvproctext,lvnewname,lvoldname
Gettext "Enter current procedure name: ",lvoldname
Gettext "Enter new procedure name: ",lvnewname
lvproctext=getproceduretext("",lvoldname)
makenewprocedure lvnewname
openprocedure lvnewname
setproceduretext lvproctext

That leave the original procedure; I have not found a way to delete the original procedure programatically.

You can use setprocedureoptions to change a procedure’s name. Here is a quote from the Help file for setprocedureoptions:

NAME

This option changes the name of the specified procedure. This example changes the name of the procedure Aloha to Hello .

setprocedureoptions "","Aloha","NAME","Hello"

The database must not already contain a procedure with the new name. If it does, the setprocedureoption statement will stop with an error.

Thanks guys.

My Safari search only finds whole words. That’s why I didn’t see it in the Help.

This will do it:

setprocedureoptions "",Name of your procedure in quotes,"delete",{}