gm-docs-parser 1.0.0

A collection of typings for GameMaker Studio 2 manual pages
Documentation
<?xml version="1.0" encoding="utf-8" ?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head>

  <script type="text/javascript" language="JavaScript">
    //<![CDATA[
    function reDo() {
      if (innerWidth != origWidth || innerHeight != origHeight)
        location.reload();
    }
    if ((parseInt(navigator.appVersion) == 4) && (navigator.appName == "Netscape")) {
      origWidth = innerWidth;
      origHeight = innerHeight;
      onresize = reDo;
    }
    onerror = null;
  //]]>
  </script>
  <style type="text/css">/*<![CDATA[*/

    < !-- div.WebHelpPopupMenu {
      position: absolute;
      left: 0px;
      top: 0px;
      z-index: 4;
      visibility: hidden;
    }

    p.WebHelpNavBar {
      text-align: right;
    }

    -->
  
/*]]>*/</style>

  <script type="text/javascript">//<![CDATA[

    gRootRelPath = "../../..";
    gCommonRootRelPath = "../../..";
    gTopicId = "9.2.9.0_15";
  
//]]></script>

  <script type="text/javascript" src="../../../template/scripts/rh.min.js"></script>
  <script type="text/javascript" src="../../../template/scripts/common.min.js"></script>
  <script type="text/javascript" src="../../../template/scripts/topic.min.js"></script>
  <script type="text/javascript" src="../../../template/scripts/topicwidgets.min.js"></script>
<script type="text/javascript" src="../../../whxdata/projectsettings.js"></script>
  <link rel="stylesheet" type="text/css" href="../../../template/styles/topic.min.css"/>
  <link rel="stylesheet" type="text/css" href="../../../template/Charcoal_Grey/topicheader.css"/>
  <meta name="topic-status" content="Draft"/>

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <title>string_format</title>
  <meta name="generator" content="Adobe RoboHelp 2019"/>
  <link rel="stylesheet" href="../../../assets/css/default.css" type="text/css"/>
  <meta name="rh-authors" content="Mark Alexander"/>
  <meta name="topic-comment" content="Reference page for string_format"/>
  <meta name="rh-index-keywords" content="string_format"/>
  <meta name="search-keywords" content="string_format"/>
</head>

<body>
  <div class="topic-header rh-hide" id="rh-topic-header" onclick="rh._.goToFullLayout()">
    <div class="logo">
    </div>
    <div class="nav">
      <div class="title" title="string_format">
        <span>string_format</span>
      </div>
      <div class="gotohome" title="Click here to see this page in full context">
        <span>Click here to see this page in full context</span>
      </div>
    </div>
  </div>
  <div class="topic-header-shadow rh-hide" id="rh-topic-header-shadow"></div>



  <!--<div class="body-scroll" style="top: 150px;">-->
  <h1>string_format</h1>
  <p>Turns a real number into a string using your own formatting, where you can choose how many &quot;places&quot; are saved to the string and how many decimal places are saved also. Both can be very handy, some games prefer to display a score as a set number
    of digits, while control over decimal places can be good for a high accuracy the two decimal places of <a href="string.htm"><tt>string()</tt></a> cannot provide. If the number of places specified is greater than the value to be shown and/or the number
    plus the decimal places that have been specified is less than the total places, then spaces will be added before the value to make up the difference (see the example below). Zeros will be added to the right of the decimal point if the value given
    is less than the total and the number of decimal places to include. The default format is no extra spaces on the left, and only two decimal places on the right, eg &quot;265.73&quot;.</p>
  <p> </p>
  <h4>Syntax:</h4>
  <p class="code">string_format(val, tot, dec);</p>
  <table>
    <tbody>
      <tr>
        <th>Argument</th>
        <th>Description</th>
      </tr>
      <tr>
        <td>val</td>
        <td>The real number to be turned into a string.</td>
      </tr>
      <tr>
        <td>tot</td>
        <td>The total number of places of the main number to be shown. Zeroes or spaces will be inserted to match this.</td>
      </tr>
      <tr>
        <td>dec</td>
        <td>The number of decimal places to be included.</td>
      </tr>
    </tbody>
  </table>
  <p> </p>
  <h4>Returns:</h4>
  <p class="code">String</p>
  <p> </p>
  <h4>Example:</h4>
  <p class="code">str1 = string_format(1234, 8, 0);<br/> str2 = string_format(pi, 1, 10);<br/> str3 = string_format(pi, 5, 5);</p>
  <p>This will set <tt>str1</tt> to &quot;    1234&quot;, <tt>str2</tt> to &quot;3.1415926535&quot; and <tt>str3</tt> to &quot;    3.14159&quot;.</p>
  <p> </p>
  <p> </p>
  <p> </p>
  <div class="footer">
    <div class="buttons">
      <div class="clear">
        <div style="float:left">Back: <a href="Strings.htm">Strings</a></div>
        <div style="float:right">Next: <a href="string_insert.htm">string_insert</a></div>
      </div>
    </div>
    <h5>© Copyright YoYo Games Ltd. 2020 All Rights Reserved</h5>
  </div>
  <!-- KEYWORDS
string_format
-->
  <!-- TAGS
string_format
-->

</body></html>