DEFINE str_hitext CHAR(130), str_text CHAR(130), str_escape CHAR(1) LET str_escape = ASCII 27 FUNCTION replace_algorithm() DEFINE int_temp2 INTEGER, int_hipos INTEGER, int_hipos_old INTEGER, int_pos INTEGER # remove highlight characters from text LET int_temp2 = LENGTH(str_hitext) LET int_pos = 1 LET str_text = " " # cycle through highlight string looking for highlight strings LET int_hipos = 1 LET int_hipos_old = 1 WHILE int_hipos <= int_temp2 - 7 # if we found an escape character (start of highlight sequence) IF str_hitext[int_hipos, int_hipos] = str_escape THEN # if a highlight sequence IF str_hitext[int_hipos + 1, int_hipos + 7] = "[32703m" OR str_hitext[int_hipos + 1, int_hipos + 7] = "[32723m" THEN # if there is previous data to copy over IF int_hipos - 1 >= int_hipos_old THEN # copy data over LET str_text[int_pos, int_pos + int_hipos - 1 - int_hipos_old] = str_hitext[int_hipos_old, int_hipos - 1] LET int_pos = int_pos + int_hipos - int_hipos_old END IF # move source positions - don't copy this over LET int_hipos = int_hipos + 8 LET int_hipos_old = int_hipos # if not a highlight sequence ELSE # move source position LET int_hipos = int_hipos + 1 END IF # if we didn't find an escape character ELSE # move source position LET int_hipos = int_hipos + 1 END IF END WHILE # if there is previous data to copy over IF int_temp2 >= int_hipos_old THEN # copy data over LET str_text[int_pos, int_pos + int_temp2 - int_hipos_old] = str_hitext[int_hipos_old, int_temp2] END IF END FUNCTION
You need to create an account or log in to post comments to this site.