Skip to content

Commit b400252

Browse files
committed
SF_CheckInputCode: Preprocess code
We need to preprocess the code before we can extract the variables and the formula. Broken since 8ec6945 (SF: Add support to check also variables with the check button, 2023-03-29).
1 parent dcadaf1 commit b400252

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

Packages/MIES/MIES_SweepFormula.ipf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2915,16 +2915,18 @@ End
29152915
static Function SF_CheckInputCode(string code, string graph)
29162916

29172917
variable i, numGraphs, jsonIDy, jsonIDx, subFormulaCnt
2918-
string jsonPath, xFormula, yFormula, formulasRemain, subPath, yAndXFormula
2918+
string jsonPath, xFormula, yFormula, formulasRemain, subPath, yAndXFormula, codeWithoutVariables, preProcCode
29192919

29202920
NVAR jsonID = $GetSweepFormulaJSONid(SF_GetBrowserDF(graph))
29212921
JSON_Release(jsonID, ignoreErr = 1)
29222922
jsonID = JSON_New()
29232923
JSON_AddObjects(jsonID, "")
29242924

2925-
code = SF_CheckVariableAssignments(code, jsonID)
2925+
preProcCode = SF_PreprocessInput(code)
29262926

2927-
WAVE/T graphCode = SF_SplitCodeToGraphs(SF_PreprocessInput(code))
2927+
codeWithoutVariables = SF_CheckVariableAssignments(preProcCode, jsonID)
2928+
2929+
WAVE/T graphCode = SF_SplitCodeToGraphs(codeWithoutVariables)
29282930

29292931
numGraphs = DimSize(graphCode, ROWS)
29302932
for(i = 0; i < numGraphs; i += 1)

Packages/tests/Basic/UTF_SweepFormula.ipf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,13 @@ static Function TestInputCodeCheck()
12671267
JSON_Release(jsonId)
12681268
CHECK_EQUAL_STR(jsonRef, jsonTxt)
12691269

1270+
formula = "# comment\r var = 1\r\r $var"
1271+
jsonRef = "{\n\"graph_0\": {\n\"pair_0\": {\n\"formula_y\": \"$var\"\n}\n},\n\"variable:var\": 1\n}"
1272+
MIES_SF#SF_CheckInputCode(formula, win)
1273+
jsonTxt = JSON_Dump(jsonId)
1274+
JSON_Release(jsonId)
1275+
CHECK_EQUAL_STR(jsonRef, jsonTxt)
1276+
12701277
formula = "[*]"
12711278
try
12721279
MIES_SF#SF_CheckInputCode(formula, win)

0 commit comments

Comments
 (0)