Plzak
Plzak

Reputation: 53

formatted input from string in Pascal

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?

Upvotes: 4

Views: 1264

Answers (1)

Marco van de Voort
Marco van de Voort

Reputation: 26356

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

Upvotes: 4

Related Questions