formatted input from string in Pascal

1k views Asked by At

In Pascal (Delphi, Lazarus), there is the Format() function for creating a formatted string from a list of variables. It works in a similar way to sprintf() function in C/C++.

On the other hand, I am not aware of any function which would set variables using a formatted string as sscanf() does in C/C++. Did I miss something? How would you achieve a similar effect?

1

There are 1 answers

0
Marco van de Voort On BEST ANSWER

Free Pascal has a simple sscanf and a special scandatetime to reverse date format strings (formatdatetime opposite)

From what I see these routines should work with Delphi too with at worst token modifications.

Note that there is also writestr and readstr which are more pascal like formatted I/O concepts similar to write/readln but then to/from strings. These are compiler builtin, so won't work with Delphi