ezeio2:scriptref:strformat

This is an old revision of the document!


Formats a string with placehoders

Description

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

Parameters

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.1560627323.txt.gz
  • Last modified: 2019-06-15 19:35
  • by andreh