|
STRING REPLACEName:
and the insertion string is
and the replacement position is given as 5, then the resulting string would be
Note that the replacement string overwrites the contents of the original string. Also note that if the the replacement position is 5, then the replacement string starts at position 5 (i.e., the position parameter is the before position rather than the after position). The STRING MERGE command performs a similar function. However, the original string is shifted to the right at the replacement position rather than overwritten. In the above example, the resulting string from the STRING MERGE command would be
The STRING EDIT command can be used to perform more general edits of a string.
where <sout> is the name of the resulting string; <sorg> is the name of the original string; <snew> is the name of the replacement string; and <nstart> is the replacement position.
you need to do
LET FNAME = STRING REPLACE FNAME SNEW NSTART The starting position can be either a parameter or a numeric value. However, it cannot be a numeric expression. So
are both allowed but
is not allowed. You would need to enter this as
LET FNAME = STRING REPLACE FNAME SNEW NSTART
LET STRING S1 = filexx.dat LET STRING S2 = 23 LET NPOS = 5 LET SOUT = STRING REPLACE S1 S2 NPOSThe resulting string SOUT will contain
. Assume we have variables X and Y in the files "file1.dat" to . "file10.dat" and we want to plot each of these in turn. . LET STRING SOLD = filex.dat LET NPOS = 5 TITLE CASE ASIS LOOP FOR K = 1 1 9 LET STRING S2 = ^K LET FNAME = STRING REPLACE SOLD S2 NPOS READ ^FNAME Y X TITLE Data from File ^SOUT PLOT Y X DELETE Y X END OF LOOP
Date created: 12/4/2008 |