Hi Jarmo,
Thanks for the response.
I am able to read the file using Load File function. How do I parse data and extract information. The split function doesn't work in JMP.
initial_ECN = ""; // Define initial_ECN outside of the function
initial_PIDTag = "";
// Define a function to create the input window
WinInput = Function({},
ECN = initial_ECN;
PIDTag = initial_PIDTag;
New Window( "Input", <<Modal,
V List Box(
Border Box( Left( 10 ), Right( 94 ), Bottom( 10 ), Top( 10 ), Sides( 15 ),
V List Box(
Lineup Box( N Col( 3 ),
//System ECN
Text Box( "System ECN:" ),
S1 = Text Edit Box( ECN , Justify Text( "left" ), <<Set Width(100)),
Spacer Box( Size( 1, 1 ) ),
//System P&ID Tag
Text Box( "P&ID Tag:" ),
S2 = Text Edit Box( PIDTag, Justify Text( "left" ), <<Set Width(100) ),
S2_note = Text Box( " Attach system P&ID indicating boundaries included in these calculations.", Set Wrap( 400 ),Justify Text( "center" )),
S2_note << Set Font Style( "Italic" ),
Spacer Box( Size( 1, 1 ) ),
teb5 = Text Edit Box("", <<Set Width(100), << Set Hint("e.g. /Tech/")),
/*Button Box("Browse",<<Set Function(Function({},
{Default Local},
fileName = Pick File("Select Text File", "$DESKTOP", {"Text Files|*.txt", "All Files|*"}, 1, 0, ""); // Pick the text file
If(fileName != "", // If a file is selected
teb5 << Set Text(Read File(fileName)) // Read the file and set its content in the text edit box
)
)
)
)*/
Button Box("Browse",<<Set Function(Function({},
{Default Local},
fileName = Pick File("Select Text File", "$DESKTOP", {"All Files|*"}, 1, 0, ""); // Pick the text file
//fileName = Load Text File(Get Path Variable("D:\Punit Documents\Projects\2024\2303196A - Regeneron/surface_area_output.txt"), Charset("utf-8")); // Pick the text file
If(fileName != "", // If a file is selected
fileContent = Load Text File(fileName, Charset("utf-8")); // Load text file content
ExtractAndSetData(fileContent); // Extract data and set it in S1
)
)
)
)
)
)
)
),
Button Box( "OK",
RunTimestamp = Today();
System_info = {S1, S2} << Get Text;
initial_ECN = System_info[1]; // Update the global variable
initial_PIDTag = System_info[2]; // Update the global variable
OutputWindow(initial_ECN, initial_PIDTag); // After getting input, open the output window
)
)
);
// Function to extract data from file content and set it in S1 and S2
ExtractAndSetData = Function({fileContent},
lines = Split(fileContent, "\n");
For Each(line, fileContent,
if(Contains(line, ":"),
parts = Split(line, ":");
fieldName = Trim(parts[1]);
fieldValue = Trim(parts[2]);
if(fieldName == "System ECN", S1 << Set Text(fieldValue));
if(fieldName == "P&ID Tag", S2 << Set Text(fieldValue));
)
)
);
// Function to create the output window
OutputWindow = Function({ECN, PIDTag},
OutputContent = New Window( "Final Output",
V List Box(
Border Box( Left( 10 ), Right( 50 ), bottom( 10 ), top( 10 ), sides( 15 ),
V List Box(
Lineup Box( N Col( 3 ), Spacing( 10 ),
//System ECN
Text Box( "System ECN:", Justify Text( "right" ) ),
S1 = Text Box( ECN, <<Set Width(100), Justify Text( "center" ) ),
Spacer Box( Size( 10, 10 ) ),
S1 << Background color( "yellow" ),
//System P&ID Tag
Text Box( "P&ID Tag:", Justify Text( "right" ) ),
S2 = Text Box( PIDTag, <<Set Width(100), Justify Text( "center" ) ),
S2_note = Text Box( " Attach system P&ID indicating boundaries included in these calculations.", Set Wrap( 500 ) ),
S2_note << Set Font Style ("Italic"),
S2 << Background color( "yellow" ),
)
)
),
H List Box(3,
Button Box( "Print PDF",
OutputContent << Set Page Setup(margins( 1, 1, 1, 1 ), scale( 0.80 ), portrait( 1 ), paper size( "Letter" ));
// OutputContent << Save PDF( "C:\Users\panjwanip\OneDrive - Barry-Wehmiller\Desktop\surface_area_output.pdf" )
OutputContent << Save Text( "C:\Users\panjwanip\OneDrive - Barry-Wehmiller\Desktop\surface_area_output.txt" )
//OutputContent << Save Excel File( "C:\Users\panjwanip\OneDrive - Barry-Wehmiller\Desktop\surface_area_output.xlsx" )
),
Spacer Box( size( 520, 20 ) ),
Button Box( "Back",
Current Window() << Close Window;
WinInput(); // Pass the current value of ECN back to the input window
),
)
)
)
);
// Initially open the input window with initial_ECN
WinInput();