Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 787
Plzak Avatar asked Nov 16 '25 19:11

Plzak


1 Answers

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

like image 170
Marco van de Voort Avatar answered Nov 18 '25 19:11

Marco van de Voort



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!