daily pastebin goal
24%
SHARE
TWEET

Untitled

a guest May 9th, 2017 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /// string_insert_commas(real)
  2.  
  3. /*
  4.     Inserts , into places it belongs.
  5.     Before: 1000000
  6.     After: 1,000,000
  7. */
  8.  
  9. if ( is_real(argument0) )
  10. {
  11.     var str = string(argument0);
  12. }
  13. else
  14. {
  15.     var str = argument0;
  16. }
  17.  
  18. var str_ = "";
  19.  
  20. var str_length = string_length(str);
  21.  
  22. var space_count = 0;
  23.  
  24. for ( var i = str_length; i > 0; i --; )
  25. {
  26.     str_ = string_char_at(str,i) + str_;
  27.     space_count ++;
  28.     if ( space_count == 3 )
  29.     {
  30.         space_count = 0;
  31.         if ( i > 1 )
  32.         {
  33.             str_ = "," + str_;
  34.         }
  35.     }
  36. }
  37.  
  38. return str_;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top