cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Custom Functions Dialog

JeffH1
14-Alexandrite

Custom Functions Dialog

One legacy feature that has still not been integrated into Mathcad Prime, is the ability to provide companion XML files that integrate Custom Functions documentation into the Mathcad interface.  Legacy Mathcad would read these XML files and add the new functions to the list of internal functions in the Insert Functions panel under their own, specified Function Category.

JeffH1_1-1705843692445.png

Legacy Insert Function Panel

 

While Mathcad Prime does contain a Functions panel for inserting built-in functions (can be triggered with <F2>), it does not allow for incorporation of categorized Custom Functions into that interface. For DLLs containing a large number of Custom Functions, this can be problematic for users to know which functions to use, what they do, what parameters are needed, and the proper function syntax.

 

I've managed to create an open-source add-in, CustFunc, that brings back the Legacy insert functions behavior for Custom functions, reading the function names, categories, syntax, and descriptions from XML files stored in the folder "Custom Functions\docs".  These XML files follow the legacy syntax exactly, with a few enhancements for implementing Unicode characters and constants.  When CustFunc.dll is placed in the Custom Functions folder, any XML files found in the docs folder are read and the new Insert Custom Function panel is launched with hot keys <Shift><F2> (not currently being used by Mathcad Prime).

JeffH1_2-1705844404636.png

New Insert Custom Function panel supplied by CustFunc Add-in

 

CustFunc does not add any new functions of its own, but only provides simplified user access to any loaded Custom Functions if their companion XML files are found in the docs folder.  You can download the CustFunc add-in from the Releases page of my GitHub CustFunc repository.  There are also a number of example XML files there for use in the sampleXML folder.  Feel free to report issues there, post a discussion about the add-in, offer enhancement suggestions and/or contribute to the project.

1 ACCEPTED SOLUTION

Accepted Solutions
JeffH1
14-Alexandrite
(To:JeffH1)

An Added Bonus Hidden in the CustFunc Add-in  

 

Since we're grabbing and inspecting keystrokes anyway, I also added a way to input the units °C and °F from the keyboard (my own keyboard shortcuts).  Since many of the keys are already used by PTC, I wanted to use keys that were memorable.  Unfortunately, while "c" and <Shift>"c" are obviously not good choices, <Ctrl>C is maybe an even worse key combo to abscond with,  <Ctrl><Shift>C is already used by Mathcad for column indexing; <Alt> combos are used as Windows menu hot-keys, and <Windows>-anything is unpredictably in use.  So I had to find another choice.  It occurred to me that this may be the reason that PTC hasn't implemented these hot keys already themselves.

 

As a less obvious choice, the "<" symbol kind of looks like a "C" (from 20 paces, if you squint your eyes).  Additionally, the ">" key, right next to it is also not already used by Mathcad or anything else when used with control key combinations.  So, on any blank worksheet space, with the CustFunc add-in loaded, the following Hot-Keys are implemented.

 

<Ctrl><Shift>"<" :  °C 

<Ctrl><Shift>">" :  °F

 

The add-in uses the quoted string method of entering special character variables, deleting the quotes and assigning the unit style label.

 

Caveat: Since I'm putting keystrokes in the Windows keyboard buffer to virtually "type" on the active Mathcad workbook, this will not work if the cursor is in the units placeholder of a math equation result.  It has to use the quoted string method of inserting special variables and this is not allowed in the units placeholder of a result.

JeffH1_0-1707304672279.png

It can be used, however when putting units on assignments if you use the scaling operator first to create a units placeholder, as was done in the first expression.  As a workaround, you can quickly insert these units with the new hot-keys in a blank area of the worksheet and then copy and paste them into the placeholder of the equation result; however, this isn't much faster (maybe) than grabbing these units off the drop-down menu.  I actually thought about putting these symbols on the Clipboard and having Mathcad paste them at the cursor location.  While this works, it also clobbers whatever the user may have had on the clipboard at the time and all Windows programming guidelines warn against this method.

 

Additionally, since the mechanism is already set up in the add-in, other hot-key combos could be implemented through the CustFunc add-in.  I'm open to suggestions, either here, or in the discussion area of my CustFunc page on GitHub, linked above.

 

All-in-All, this has been a great exercise in bare-metal Windows programming and I learned a lot doing it, including how to interact with other applications that are open on the desktop.

 

View solution in original post

2 REPLIES 2
Fred_Kohlhepp
23-Emerald I
(To:JeffH1)

Impressive!!

 

The users who use custom functions will surely benefit from your efforts. 

But this is yet another case of  the user community stepping up to do what PTC has failed or refuses to do.

IMHO, those who provide improvements to PRIME that were in original Mathcad should be paid for that benefit.

JeffH1
14-Alexandrite
(To:JeffH1)

An Added Bonus Hidden in the CustFunc Add-in  

 

Since we're grabbing and inspecting keystrokes anyway, I also added a way to input the units °C and °F from the keyboard (my own keyboard shortcuts).  Since many of the keys are already used by PTC, I wanted to use keys that were memorable.  Unfortunately, while "c" and <Shift>"c" are obviously not good choices, <Ctrl>C is maybe an even worse key combo to abscond with,  <Ctrl><Shift>C is already used by Mathcad for column indexing; <Alt> combos are used as Windows menu hot-keys, and <Windows>-anything is unpredictably in use.  So I had to find another choice.  It occurred to me that this may be the reason that PTC hasn't implemented these hot keys already themselves.

 

As a less obvious choice, the "<" symbol kind of looks like a "C" (from 20 paces, if you squint your eyes).  Additionally, the ">" key, right next to it is also not already used by Mathcad or anything else when used with control key combinations.  So, on any blank worksheet space, with the CustFunc add-in loaded, the following Hot-Keys are implemented.

 

<Ctrl><Shift>"<" :  °C 

<Ctrl><Shift>">" :  °F

 

The add-in uses the quoted string method of entering special character variables, deleting the quotes and assigning the unit style label.

 

Caveat: Since I'm putting keystrokes in the Windows keyboard buffer to virtually "type" on the active Mathcad workbook, this will not work if the cursor is in the units placeholder of a math equation result.  It has to use the quoted string method of inserting special variables and this is not allowed in the units placeholder of a result.

JeffH1_0-1707304672279.png

It can be used, however when putting units on assignments if you use the scaling operator first to create a units placeholder, as was done in the first expression.  As a workaround, you can quickly insert these units with the new hot-keys in a blank area of the worksheet and then copy and paste them into the placeholder of the equation result; however, this isn't much faster (maybe) than grabbing these units off the drop-down menu.  I actually thought about putting these symbols on the Clipboard and having Mathcad paste them at the cursor location.  While this works, it also clobbers whatever the user may have had on the clipboard at the time and all Windows programming guidelines warn against this method.

 

Additionally, since the mechanism is already set up in the add-in, other hot-key combos could be implemented through the CustFunc add-in.  I'm open to suggestions, either here, or in the discussion area of my CustFunc page on GitHub, linked above.

 

All-in-All, this has been a great exercise in bare-metal Windows programming and I learned a lot doing it, including how to interact with other applications that are open on the desktop.

 

Top Tags