Custom Functions and Statements

I use several (simple) custom functions in Pan6. It is quite easy to write them using the Wizard-Developer Tools menu. But how do you write a custom function in PanX? The Help screens do not cover this.
By the way, this question also applies to Custom Statements.

If you type ‘custom’ into the help search field you will find entries for info("customfunctions"), info("customstatements"), loadcustomfunctions and registercustomfunction.

View > View Organiser… followed by Libraries > Open <your_name>'s Custom Statements… opens your own permanent custom statement database. I don’t think there’s much in the help database about this but I found everything I needed to know that wasn’t obvious in previous forum threads.

Hello pcnewble,
I don’t quite follow your message. I did open the View organizer, I did type in custom, I did look for user functions/statements. But where is the library for these user functions/statements? How does one write a new user function. There is no Wizard menu in my PanX application.

OK. I found the registercustomfunction command, placed it in a new procedure, and ran the procedure. My custom function now works.

Where do I place this command so that it runs every time I use PanX. The Help suggests to place the command inside the
~/Library/Application Support/PanoramaX/Libraries
folder. But I don’t seem to have such a folder named Libraries.

I did find the path, but there is no Libraries folder. Should I just create a blank folder called Libraries? Since it is in my PanoramaX support folder, I don’t want to risk screwing things up.

If you do not have a Libraries folder, use the Finder to make one. You will not screw anything up. You can put a file inside that will run when Panorama starts up and initializes custom functions and statements.

In mine, I have a couple of statements that I have gotten here, a working version of ZipInfoPlus (sorry, it requires an API key, so I have not posted it), and a function that properly formats addresses from ZipInfoPlus so they are not all caps.

PanoramaX will create the library for you automatically and create a database where you can put custom statements and functions.

Open View Organizer
Choose Libraries/Open [username] Custom Statements to open the PanX database that will be created automatically if it does not already exist.

If you add a statement to this database (all caps name), the statement will be available everywhere in PanX. I am at the edge of my knowledge about this, but I think you will need a header in your custom statement to accomplish certain things, like passing variables to the custom statement. If anyone would like to see it, I will be happy to share the standard header that I use.

There are some specific steps you can make to create a custom function once you have a custom statement working.

Michael Kellock is an expert on this topic and taught me what I know.

Hello Bruce and Cooper,
I seem to be missing something. When I open View-View Organizer, I get the following window. There is no “Libraries/Open [user name] Custom Statements” option. There is an “Open Custom Statements” option, but double-clicking that just opens a procedure. It doesn’t create a library or a database to load my macro database into.

It’s on the menu bar.

image

There is a Libraries menu in the menu bar, and the second item in that menu will be

 Open Vic DiFranco's Custom Statements

(The exact name may be different, depening on how your system is set up.)

Thanks, guys. Sorry to be so obtuse.

That’s it for today. I’ll pick it up again next week.

What a great forum this is. Helpful, polite, and patient, with never an unkind word.

Best regards,
Vic

I started using these a long time ago, before there were some of the nice things that have been added. I register functions in a .Initialize procedure in the Custom Statements file.

The procedure should be named “.InitializeFunctions”. The Custom Statements file is opened in secret, and a .Initialize procedure won’t run, but .InitializeFunctions will.

That is what I have. Like I said, it has been a long time.

Thank you to everyone. Success.

I created the Library folder as described, and added my database with custom macro. It works perfectly, just as it did in Pan6 (after making the necessary PanX updates to certain commands).

I am trying to add a new procedure to that custom macro database, but when I double-click the file to open it, nothing happens. I suspect the file is opening as a secret file.

So how can I access the database to add a new custom procedure in future? At a minimum, I need to add a new “.InitializeFunctions” procedure containing the registercustomfunction command. By the way, does that .InitializeFunctions procedure name have to be all caps?

Vic

Open it the same way you created it, from View Organizer.

No. Only the first I, and the F should be capitalized.

Thanks again, Dave.

While trying to trouble-shoot this issue myself, I came across 2 excellent files on my system that explain custom statements and custom functions in great detail. The text file was written by Michael Kellock (his name appears as author towards the bottom), but for the life of me, I don’t remember how or when I got a copy of those files. It must have been when I first purchased PanX.

At any rate, I recommend those two files to others who may be struggling with custom statements/functions. But alas, I don’t know how to get them on-line. Was this something that Michael did for Jim? Can it be accessed from the Help screens? If so, it’s not obvious how.

Vic

A Google search for:

"michael kellock" "custom functions"

gives this page as the first search result, which I suspect is what you were referring to: