IntegerToString

Bu fonksiyon, tam-sayı tipli bir değeri, belirtilen uzunluktaki bir dizgiye kopyalar ve elde edilen dizgiye dönüş yapar.

string  IntegerToString(
   long    number,              // sayı
   int     str_len=0,           // sonuç dizgisinin uzunluğu
   ushort  fill_symbol=' '      // dolgu sembolü
   );

Parametreler

number

[in]  Dönüştürülecek sayı.

str_len=0

[in]  Dizgi uzunluğu. Sonuç dizgisinin uzunluğu belirtilenden daha büyükse, dizgi budanır. Eğer daha küçükse, dizginin soluna dolgu sembolleri eklenir.

fill_symbol=' '

[in]  Dolgu sembolü. Varsayılan olarak bir boşluktur.

Dönüş değeri

Dizgi.

 

Example:

#define DATA_TOTAL 1001
 
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- display rows with the index multiple of 100 in the loop by DATA_TOTAL
//--- the string displays the index value in the four-character format
//--- if the string length is less than 4 characters, then the value of the loop index
//--- in the string is preceded by leading zeros
   for(int i=0; i<DATA_TOTAL; i++)
     {
      if(i%100==0)
         Print("Converted index value: ",IntegerToString(i,4,'0'));
     }
   /*
   result:
   Converted index value: 0000
   Converted index value: 0100
   Converted index value: 0200
   Converted index value: 0300
   Converted index value: 0400
   Converted index value: 0500
   Converted index value: 0600
   Converted index value: 0700
   Converted index value: 0800
   Converted index value: 0900
   Converted index value: 1000
   */
  }

Ayrıca Bakınız

StringToInteger