Formats a string with placehoders


strformat( dest[], size, bool:pack, const format[], {Fixed,Float,_}:... )

Formats a string with C-style printf placeholders.

Possible placeholders are:

  • %d : integer number
  • %c : character
  • %f : floating point number
  • %x : hexadecimal number
  • %s : string

Insert a number between the % and the letter to pad the field with spaces to a specific length.
Example: %4d


dest Destination buffer
size Size of the destination buffer in 'cells'.
pack Creates a packed string if set to true
format String with placeholders
Variable number of parameters

Return value

Returns 1 if successful.
Returns 0 on error.

Example usage

    new s{40};
    new a = 5;
    new b{20} = "cats";
    strformat(s, sizeof s, true, "The dog likes %d %s.", a, b); // returns 1
    // s now contains "The dog chased 5 cats."
  • ezeio2/scriptref/strformat.txt
  • Last modified: 2019-09-02 21:43
  • by andreh