I have a text file that I would like to read into a string array and then perform a string compare on all of the entries. How can I do this?

First, the *SREAD command can be used to read text from a file into an array. This is well documented.


Since vector operations are not applicable to string arrays, the length of the array can be retrieved using *GET,,PARM.


While there are no GET functions to directly compare two strings, an *IF statement can be used for the comparison. Also, the GET function, STRCOMP, can be used to remove blank lines from the string. Note how the string array is indexed in the following snippet.

! string arrays are indexed with row = 1 and col = line
! if the strings match, perform some operation

Show Form
No comments yet. Be the first to add a comment!