전체 스크립트 대신 특정 기능을 포함하는 방법안녕하세요,
JSL 파일에서 특정 기능만 가져오는 방법이 있습니까?
예를 들어 파이썬에서는 "from pandas import read_csv"라고 작성하여 read_csv 함수만 가져올 수 있습니다. 현재 JMP에서는 항상 많은 함수가 정의된 전체 JSL 파일을 가져오는데 명확성(및 성능)을 위해 필요한 함수만 가져오는 것이 더 나을 것 같습니다.
감사해요
리차드
데이터 접근Re: 전체 스크립트 대신 특정 기능을 포함하는 방법실제로 작동합니다. 정말 감사합니다!Re: 전체 스크립트 대신 특정 기능을 포함하는 방법죄송합니다. 함수를 복사할 때 이름 expr( 함수가 필요합니다.수정된 예는 다음과 같습니다.
포함.jsl:
f = function({x,y}, x + y);함수를 로드하는 스크립트:
names default to here(1);
//load the new file in a local here namespace
Eval( Eval Expr( local here(
include("included.jsl");
//Reference the original script's here namespace in this new here namespace
//Eval, Eval Expr, and Expr cause the namespace("here") to be evaluated
//outside of this 'local here' context.
//from the other.
ns = Expr( namespace("here") );
//copy and functions you want to keep
ns:f = Name expr( here:f );
) ) );
//Now functions are in here namespace
f(1,2);Re: 전체 스크립트 대신 특정 기능을 포함하는 방법도움을 주셔서 감사합니다. 이것은 인수가 없는 함수에서 확실히 작동합니다.
불행히도 두 개의 인수가 있는 함수를 가져오려고 할 때 오류가 발생합니다. 오류는 함수에 두 개의 인수가 필요할 때 인수를 제공하지 않는다는 것입니다(사실입니다). 샘플 코드는 다음과 같습니다.
names default to here(1);
MyRejet = 1;
Lot_nom = "G123456";
//load the new file in a local here namespace
Eval( Eval Expr( local here(
Include("include.jsl");;
//Reference the original script's here namespace in this local here namespace
//Eval, Eval Expr, and Expr cause the namespace("here") to be evaluated
//outside of this 'local here' context.
ns = Expr( namespace("here") );
print(ns);
//copy and functions you want to keep
ns:DataExtraction = here:DataExtraction;
) ) );
//Now functions are in this namespace
DataExtraction(Lot_nom, MyRejet);오류가 어디에 있는지 아십니까? 함수를 복사할 때 인수를 지정하려고 했지만 문제가 해결되지 않는 것 같습니다.
감사해요
리차드
Re: 전체 스크립트 대신 특정 기능을 포함하는 방법나는 파이썬이 제공하는 것만큼 직접적인 것을 알지 못하지만 여기에 작업을 완료하는 두 가지 옵션이 있습니다.
included.jsl이라는 파일을 고려하십시오.
a = function({}, 1);
b = function({}, 2);스크립트 컨텍스트에서 함수를 직접 로드하려면 다음을 수행하십시오.
names default to here(1);
//load the new file in a local here namespace
Eval( Eval Expr( local here(
include("included.jsl");
//Reference the original script's here namespace in this local here namespace
//Eval, Eval Expr, and Expr cause the namespace("here") to be evaluated
//outside of this 'local here' context.
ns = Expr( namespace("here") );
//copy and functions you want to keep
ns:a = here:a;
) ) );
//Now functions are in this namespace
a();
또는 함수를 별도의 네임스페이스에 보관하려면 다음을 수행하십시오.
names default to here(1);
//create namespace to hold functions you want to keep from included file
ns = new namespace();
//load the new file in a local here namespace
Eval( Eval Expr( local here(
include("included.jsl");
//Reference the ns namespace in this new here namespace
ns = Expr( ns );
//pick and choose any functions you want to keep
ns:a = here:a
) ) );
//Now either call the functions from the ns namespace
ns:a();
//or copy them to the here namespace
a = ns:a;
a();
Re: 전체 스크립트 대신 특정 기능을 포함하는 방법포함 파일의 하위 집합만 포함하는 방법을 모르겠습니다.