scripting@wanadoo.nl




Flip_Currency()

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
12 February 2002 Flip_Currency()
AuthorW.M. Hinsch (New Mexico Mark)
Action Add or remove the currency symbol (as defined in your system setup) in a number.
SyntaxFlip_Currency (String) 
Parameters
  • String (Required / String) Any string of numbers or a number that can be directly converted to a string. 
  • RemarksThis works fine as a stand-alone function, but it may be called from Fmt(), Flip_Numsep(), or Flip_Dec()
    ReturnsA string. 
    DependenciesNone. 
    Examples
    "Flip_Currency($123.00) = " + Flip_Currency("$123.00") ?
    "Flip_Currency(123.00) = " + Flip_Currency("123.00") ?
    
    ; Console Output (Example)
    
    ;  Flip_Currency($123.00) = 123.00
    ;  Flip_Currency(123.00) = $123.00
    
     
    Source
    FUNCTION Flip_Currency ($svar)
      ; This function takes an expression that evaluates to a string or that
      ; can be directly converted to a string. It adds (or removes if present)
      ; the system currency symbol in the place specified by the system and
      ; returns the modified string.
      ;
      IF VarType($svar) < 2 OR VarType($svar) > 8
        EXIT -1
      ENDIF
    
      DIM $ccur, $iloc, $ilen, $sreg
      $svar = "" + $svar
      $sreg = 'HKCU\Control Panel\International'
      $ccur = ReadValue($sreg,'sCurrency')
      $iloc = Val(ReadValue($sreg,'iCurrency'))
      $ilen = Len($svar)
      SELECT
        CASE $iloc = 0 ; "$2"
          IF Substr($svar,1,1) = $ccur
            $flip_currency = Substr($svar,2)
          ELSE
            $flip_currency = $ccur + $svar
          ENDIF
        CASE $iloc = 1 ; "2$"
          IF $ilen > 1
            IF Substr($svar,$ilen - 1,1) = $ccur
              $flip_currency = Substr($svar,1,$ilen - 1)
            ELSE
              $flip_currency = $svar + $ccur
            ENDIF
          ENDIF
        CASE $iloc = 2 ; "$ 2"
          IF Substr($svar,1,2) = $ccur + " "
            $flip_currency = Substr($svar,3)
          ELSE
            $flip_currency = $ccur + " " + $svar
          ENDIF
        CASE $iloc = 3 ; "2 $"
          IF $ilen > 2
            IF Substr($svar,$ilen - 2,2) = " " + $ccur
              $flip_currency = Substr($svar,1,$ilen - 2)
            ELSE
              $flip_currency = $svar + " " + $ccur
            ENDIF
          ELSE
            $flip_currency = $svar + " " + $ccur
          ENDIF
      ENDSELECT
    ENDFUNCTION ; - Flip_Currency -
     
      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