用戶定義的函數已在JMP中使用了很長時間,但現在在JMP 14中,您可以將這些函數作為自定義函數添加到腳本索引和公式編輯器中。
什麼是自定義功能?
自定義函數是已添加到JMP的用戶定義函數,包括其他元數據,因此可以在JMP的其他區域中使用。將函數添加到JMP安裝後,它將在JMP的所有將來會話中可用,直到刪除該函數。使用此新功能,您可以創建供其他人使用的功能,而無需單獨的文檔或需要包含功能或閱讀源代碼。
定義自定義函數
要向JMP添加自定義函數,必須使用New Custom Function()來定義屬性,然後使用Add Custom Functions()將函數定義發佈到JMP。有關定義要在“腳本索引”和“公式編輯器”中顯示的函數的示例,請參見下文。
// Define new function
myFunc = New Custom Function(
"Utilities", // Namespace
"Km to Miles", // Function Name
Function( {km}, km * 0.621371 ), // Function Definition
<< Prototype( "Utilities:Km to Miles( km )" ), // Syntax for SI/Hover Help
<< Parameter( "Number", "number" ), // Add parameter info
<< Result Type( "Number" ), // Add return type
<< Description( "Converts kilometers to miles." ), // Description for SI/Hover Help
<< Example( "Utilities:Km to Miles( 5 );" ), // Example for SI
<< Scripting Index Category( "Conversion" ), // Set SI category
<< Formula Category( "Conversion" ) // Set Formula Editor category
);
// Publish the function to the current installation of JMP
Add Custom Functions( myFunc );
腳本索引
如果在定義自定義函數時指定了腳本索引類別,請在腳本索引中查看新條目。以下是我在轉換類別中的新自定義功能。看看這個可能是一個好主意,以確保一切按計劃進行,你可以測試你自己的例子!

公式編輯器
自定義功能的另一個很酷的功能是你甚至可以擁有自己的功能

與他人分享