scripting@wanadoo.nl




NumSep()

http://www.scriptlogic.com/kixtart/FunctionLibrary_FunctionList.aspx


actual FunctionLibrary list on 'Scriptlogic' site printer-friendly mirror of UDF topic on 'scripting@wanadoo.nl' site close
9 January 2002 NumSep()
AuthorW.M. Hinsch (New Mexico Mark)
Action Inserts thousand separators in a number.
SyntaxNumSep (String [,Character]) 
Parameters
  • String (Required / String) the number (in string format) to which commas should be inserted.
  • Character (Optional / String) the optional character to insert. If not specified, the character specified by the client's regional settings in the Control Panel will be used (typically a comma for US/Canada and a period for European numbers). 
  • RemarksIf someone felt ambitious, they might try rewriting this function to leave existing separators in place transparently.
    Original Comma() UDF code provided by WM Hinsch. Enhanced to read default thousands separator character from registry (Control Panel / Regional Settings) by ScriptLogic Corp. 
    ReturnsA string with the separation character inserted in the 3rd, 6th, 9th, ... Nth places of String. 
    DependenciesNone. 
    Examples
    FOR $i = 1 to 7
      $tmpNum = ""+$i+$tmpNum
      "The original number is: "+$tmpNum ?
      "The number with thousand separators is: "+NumSep($tmpNum) ?
      ?
    NEXT
    
     
    Source
    FUNCTION NumSep ($strnum, OPTIONAL $strchar)
      ; Inserts Thousand Separator characters (or any other character) into a 'numeric' string.
    
      DIM $intctr, $intlen
      $strnum = "" + $strnum
      $strchar = "" + Substr($strchar,1,1)
      IF ($strchar = "")
        $strchar = ReadValue('HKCU\Control Panel\International','sThousand')
      ENDIF
      $intlen = Len($strnum)
      FOR $intctr = 1 TO $intlen
        $numsep = "" + Substr($strnum,$intlen - ($intctr - 1),1) + $numsep
        IF ($intctr - (($intctr / 3) * 3) = 0) AND ($intctr <> $intlen)
          $numsep = $strchar + $numsep
        ENDIF
      NEXT
    ENDFUNCTION ; - NumSep -
     
      original source of UDF topic. show actual FunctionLibrary list on Scriptlogic site close top
              printer-friendly mirror of UDF topic on scripting@wanadoo.nl site  




    Copyright © 2003 www.scriptlogic.com & scripting@wanadoo.nl - last updated on 20 May 2003


    Site Meter