Recent

Author Topic: [SOLVED] printf() equivalent  (Read 11029 times)

fatmonk

  • Sr. Member
  • ****
  • Posts: 252
[SOLVED] printf() equivalent
« on: February 12, 2015, 02:57:34 pm »
This is a simple one...

Is there a printf() in Lazarus/fpc? If so, where can I find it?

If not, is there an equivalent or am I looking at a world of pain to implement something similar?

I'm looking for something that can be used as a resource string for translations which allows the order of the words around a variable to be changed.. with printf I would simply use:

Code: [Select]
subject:='cat';
translationString:='The %s sat on the mat.';
printf(translationString,subject);
translationString:='On the mat, the %s sat.';
printf(translationString,subject);



-FM
« Last Edit: February 12, 2015, 06:02:31 pm by fatmonk »

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: printf() equivalent
« Reply #1 on: February 12, 2015, 03:19:52 pm »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8836
  • Programming + Glam Metal + Tae Kwon Do = Me

fatmonk

  • Sr. Member
  • ****
  • Posts: 252
Re: printf() equivalent
« Reply #3 on: February 12, 2015, 06:02:20 pm »
format() is exactly what I was after - and more powerful than printf()/sprintf() as well by the look of things (ie specifying which variable for each placeholder).

Brilliant, thanks both.

-FM

 

TinyPortal © 2005-2018