For users of Free Pascal (not sure about Delphi), in the Sysutils unit you'll find the following function:
which is very useful for scanning a string, and extracting information from it in a format that you have the freedom to specify. Very simple to use, too. For example, to parse the following string: s = '200x300+10-10' (a common geometry specification) you would call something like:Code:function SScanf(const s: String; const fmt: String; const Pointers: Array[] of Pointer): Integer
which would return FWidth = 200, FHeight = 300, FLeft = 10, and FTop = -10.Code:SScanf(s, '%dx%d%d%d', [@FWidth, @FHeight, @FLeft, @FTop]);
Bookmarks