Extract Text From Plain Text File Using Notebook
hrodstein
// This function shows how to extract each line of text from a plain text file using a notebook.
Function PrintTextFileContents()
String nb = UniqueName("TempNB", 10, 0)
OpenNotebook /N=$nb "" // Display open file dialog
DoWindow $nb // Check if notebook exists
if (V_flag == 0)
return -1 // User canceled
endif
Notebook $nb, selection={startOfParagraph,endOfParagraph}
do
GetSelection Notebook, $nb, 2 // Sets S_selection to paragraph's text
if (strlen(S_selection) == 0)
break
endif
String text = S_selection
text = ReplaceString("\r\n", text, "\r") // Replace CRLF with CR
text = ReplaceString("\n", text, "\r") // Replace LF with CR
Print strlen(text), text
Notebook $nb, selection={startOfNextParagraph,endOfNextParagraph}
while (1)
DoWindow/K $nb
return 0
End
Function PrintTextFileContents()
String nb = UniqueName("TempNB", 10, 0)
OpenNotebook /N=$nb "" // Display open file dialog
DoWindow $nb // Check if notebook exists
if (V_flag == 0)
return -1 // User canceled
endif
Notebook $nb, selection={startOfParagraph,endOfParagraph}
do
GetSelection Notebook, $nb, 2 // Sets S_selection to paragraph's text
if (strlen(S_selection) == 0)
break
endif
String text = S_selection
text = ReplaceString("\r\n", text, "\r") // Replace CRLF with CR
text = ReplaceString("\n", text, "\r") // Replace LF with CR
Print strlen(text), text
Notebook $nb, selection={startOfNextParagraph,endOfNextParagraph}
while (1)
DoWindow/K $nb
return 0
End
Forum
Support
Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More