Comment by card_zero
Source (or source of an earlier version at least), in BASIC:
https://archive.org/details/BYTE_Vol_10-07_1985-07_Computers...
I couldn't find the Nov 1984 Pascal version, but like they say, Basic is easier for working with strings.